Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accession edit feature #15

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open

Accession edit feature #15

wants to merge 13 commits into from

Conversation

kdimopulu
Copy link
Collaborator

No description provided.

@kdimopulu kdimopulu marked this pull request as draft October 4, 2024 09:02
@blacksmith-welder blacksmith-welder changed the title gherkin scenarios for edit accessions Accession edit features Oct 8, 2024
Accession edit step definitions
@blacksmith-welder blacksmith-welder marked this pull request as ready for review October 14, 2024 17:38
@@ -29,6 +29,13 @@
Capybara::Selenium::Driver.new(app, browser: :firefox, options:)
end

Capybara.register_driver :firefox_alternative_session do |app|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 didn't know you can do that!

@blacksmith-welder blacksmith-welder changed the title Accession edit features Accession edit feature Oct 21, 2024
Copy link
Collaborator

@balmas balmas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally this looks good, but I had a few requests for changes.

Given the Accession is opened in edit mode
When the user changes the 'Title' field
And the user clicks on 'Revert Changes'
Then the 'Title' field has the original value
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see my comments on this test in the accession_edit step definitions

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

end

When 'the user changes the {string} field' do |field|
fill_in field, with: "Updated Title #{SecureRandom.uuid}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this was meant to be a generic When function that works with any field but the test is explicit to the Title. Probably should change the function name to match the behavior.

Copy link
Collaborator

@blacksmith-welder blacksmith-welder Nov 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, That is correct. I missed that. It is generic now, and it's also moved inside shared/step_definitions.rb

end

Then 'the {string} field has the original value' do |field|
expect(page).to have_field(field, with: "Accession Title #{@uuid}")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as previous - function name should match the behavior, which is specific to the Title field.

end

Then 'all fields become editable' do
fill_in 'Identifier', with: 'Identifier'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks like it's just testing one field...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After discussing this @kdimopulu, we decided that this step is unnecessary. We only need to check that we are on the edit page. The phrase fields become editable, implies that an input field is disabled and it is enabled after some action or condition. In the edit page, everything is editable. I have removed this.

Then 'the Accession Date field has the original value' do
visit "#{STAFF_URL}/accessions/#{@accession_id}/edit"

expect(page).to have_field('Accession Date', with: '2000-01-01')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor point but it might be better to have the original values as constants in case we decide to change them for some reason.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

However, I believe that maybe there should be a consistency between the original values, since some of them use strings interpolated with variables (uuids, or maybe something else), and it's not clear to the step definition writer when to use what.

The writer also checks the original values from the form that sees in the screen, so it is more straightforward to directly copy the strings, rather than having an extra lookup to another file, which may grow quite a lot in the future. In addition to that, in the future, we may have multiple records/factories, which may have multiple original values that may differ slightly, which again can cause confusion.

We can always refactor this this if it causes issues in the future.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I see that you added ORIGINAL_ACCESSION_DATE as a constant, so can you change line 91 to use it in the test?

end

When 'User A changes the {string} field' do |field|
fill_in field, with: "Accession Title #{@uuid} updated"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to previous comments, function definition should match the functionality which is title field specific not generic

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated this to be more generic.

end

When 'User B changes the {string} field' do |field|
@session.fill_in field, with: "Accession Title #{@uuid} updated"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to previous comments, function definition should match the functionality which is title field specific not generic

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated this to be more generic.

end

Given 'the Accession is opened in edit mode by User B' do
@session = Capybara::Session.new(:firefox_alternative_session)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is maybe nitpicking, but I think it would be clearer to name this variable something that reflects that it is an alternative or headless session

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this makes sense. I wouldn't say it's nitpicking. It's good to have clarity and self-explanatory variable names in the code. This alternative session is defined here, and it may be headless or not, according to a command line option.

I have renamed this to @user_b_session, since all steps that make use of this session, refer to User B. Please let me know if you have a different name in mind.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that works for me. thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants