Files
growstuff/spec/features/seeds/misc_seeds_spec.rb
T
Brenda WallaceandDaniel O'Connor 75595350bc Easier recording of harvests from the front page (#5077)
* Implement AddSeedsPicker component and enhance planting selection UI; update styles and serializers for better seed management

* Enhance PlantingPicker component: add hints and titles for harvest and seed actions; update test to reflect changes in seed saving behavior

* Enhance harvest recording: allow harvesting from crops without plantings; update forms and modals for better user experience

* Refactor code structure for improved readability and maintainability

* Remove AddSeedsPicker component and its associated tests

* Add planting picker functionality for harvesting and seed saving

- Introduced PlantingPickersController to handle JSON responses for member's plantings.
- Updated HomeHelper to include crop ID in planting picker properties.
- Refactored PlantPicker and PlantSomethingModal components to support multiple gardens.
- Created PlantingFlow component to manage planting actions (harvest and save seeds).
- Implemented RecordDialog component to handle server-rendered links for harvesting and seed saving.
- Updated various views to include data attributes for triggering the record dialog.
- Added routes for planting picker and corresponding request specs for testing.
- Adjusted styles in _plantings.scss for better layout and spacing.

* Add job management features including job creation and wishlist functionality

* Remove WishlistJobsController and associated views and tests

* Add suggestion links rendering and fix routes formatting

* Refactor AddJobModal and JobPicker components to simplify props and enhance user experience

* Update seed addition test to check dialog presence and current path

* Apply suggestion from @CloCkWeRX

---------

Co-authored-by: Daniel O'Connor <daniel.oconnor@gmail.com>
2026-10-26 21:38:12 +10:30

109 lines
3.3 KiB
Ruby
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# frozen_string_literal: true
require 'rails_helper'
describe "seeds", :js do
context "signed in user" do
include_context 'signed in member'
xit "button on index to edit seed" do
let!(:seed) { create(:seed, owner: member) }
before do
visit seeds_path
click_link 'Actions'
click_link "Edit"
end
it { expect(page).to have_current_path edit_seed_path(seed), ignore_query: true }
it { expect(page).to have_content 'Editing seeds' }
end
describe "button on front page to add seeds" do
before do
visit root_path
click_link '+ Add'
within('#navbarSupportedContent') { click_link(href: new_seed_path) }
end
it { expect(page).to have_css '[role=dialog]', text: 'Where did these seeds come from?' }
it { expect(page).to have_current_path root_path, ignore_query: true }
end
describe "Clicking link to owner's profile" do
before do
visit member_seeds_path(member)
within '.login-name' do
click_link member.login_name
end
end
it { expect(page).to have_current_path member_path(member), ignore_query: true }
end
# actually adding seeds is in spec/features/seeds_new_spec.rb
it "edit seeds" do
seed = create(:seed, owner: member)
doubled = seed.quantity * 2
visit seed_path(seed)
click_link 'Actions'
click_link 'Edit'
# Editing happens in a dialog over the page now, rather than on a form of
# its own, so the member never leaves the seed.
within '#seed-edit-modal' do
fill_in 'How many seeds?', with: doubled
select 'traded from another person', from: 'Where did they come from?'
click_button 'Save'
end
# The page is already the seed's, so wait for the saved value to show
# before looking at the database.
expect(page).to have_css '.seedfacts--source', text: 'traded from another person'
expect(seed.reload).to have_attributes(quantity: doubled, source: 'traded from another person')
end
describe "delete seeds" do
let(:seed) { create(:seed, owner: member) }
before do
visit seed_path(seed)
click_link 'Actions'
accept_confirm do
click_link 'Delete'
end
end
it { expect(page).to have_current_path seeds_path, ignore_query: true }
end
describe '#show' do
before { visit seed_path(seed) }
describe "view seeds with max and min days until maturity" do
let(:seed) { create(:seed, days_until_maturity_min: 5, days_until_maturity_max: 7) }
it { expect(find('.seedfacts--maturity')).to have_content("5–7") }
end
describe "view seeds with only max days until maturity" do
let(:seed) { create(:seed, days_until_maturity_max: 7) }
it { expect(find('.seedfacts--maturity')).to have_content("7") }
end
describe "view seeds with only min days until maturity" do
let(:seed) { create(:seed, days_until_maturity_min: 5) }
it { expect(find('.seedfacts--maturity')).to have_content("5") }
end
describe "view seeds with neither max nor min days until maturity" do
let(:seed) { create(:seed) }
it { expect(find('.seedfacts--maturity')).to have_content "unknown" }
end
end
end
end