Skip to content

[1003] Add more feature tests#355

Closed
goldsmithb wants to merge 1 commit intomainfrom
1003
Closed

[1003] Add more feature tests#355
goldsmithb wants to merge 1 commit intomainfrom
1003

Conversation

@goldsmithb
Copy link
Copy Markdown
Contributor

Jira Ticket


This PR adds more feature tests to AC, focusing on the features listed in the top AC features to test document that was compiled by Eric, Jack, and myself.

  • That google doc also lists the feature tests that are currently planned and those that have been implemented in this PR.

Many of the tests focus on the admin-only interface UI interactions.

@goldsmithb goldsmithb marked this pull request as ready for review March 24, 2026 17:20
Copy link
Copy Markdown
Contributor

@JackBlackLight JackBlackLight left a comment

Choose a reason for hiding this comment

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

This is so great to have all these tests! Thanks for doing this @goldsmithb. I added a couple minor questions/comments but these are good to go.

@@ -1,5 +1,5 @@

<%= form_with model: [:admin, @email_preference], local: true, data: { turbo: false } do |f| %>
<%= form_with model: [:admin, @email_preference], local: true, data: { turbo: false, testid: 'email-preference-form' } do |f| %>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is a matter of preference, but when I saw 'testid', I thought it might have been left in the code by mistake. I see that at present it is being used by a test and that's why it has this name, which makes sense, but I think I'll be confused by it each time i see it :)

It could conceivably be used outside of a test at some future point, right? Would it be bad to rename it as just 'id'?

<h3>Pending Works</h3>
<table class="table small">
<table class="table small" data-testid="pending-works-table">
<% @pending_works.each do |document| %>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

See rationale above - could this become 'data-id'?

page.find('a[href="/download/fedora_content/show_pretty/actest:1/descMetadata/actest1_description.xml?data=meta"]', text: 'text').click
expect(page).to have_text('Alice\'s Adventures in Wonderland')
# TODO: Only for administrators - not sure how to test this right now
context 'when admin' do
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm curious about the challenge you're encountering here. Don't know if I can help, but would be happy to talk it over.

@goldsmithb
Copy link
Copy Markdown
Contributor Author

Thanks for the review @JackBlackLight ! I will respond to your comments here.

For the data-testids, I could see reasons to go either way. I used them here because there were no convenient Capybara selectors I could find for writing certain browser-driven tests that verify the presence of these elements. Currently, they aren't used by any JS code or style rules (and also don't need to follow uniqueness requirement for normal HTML ids), but you are right that we could always use them for more/more tests in the future, and there isn't much of a practical difference. In past codebases I have worked where these were used more extensively for this type of testing, we had a step in our deployment process that removed all the data-test attributes from the source, because there was a concern that leaving them in could expose our test surface to malicious users (though I'm not sure I find this entirely convincing -- because I only include them when there isn't a more convenient way to test these elements, it doesn't really expose much anyways). I think it is worth converting them to normal IDs, specially because we don't use them extensively.

For the admin-only item tests, I'm not sure what is causing the trouble, but it seems that elements that should render in an admin-user context are not being selected properly in the Capybara tests. Sometimes they work and sometimes they don't, and I haven't been able to get them to pass consistently in the Github CI environment. These are as you know tricky to diagnose, so I would love to take a look with you when you are back. I will leave them as skipped for now.

@goldsmithb
Copy link
Copy Markdown
Contributor Author

For some reason, this wasn't picked up as merged, but I rebased and merged this into main last week.

Commit is here: 3b107da4aab21aef2d3df44d089176b2a3a0b918

Changes were deployed with v5.0.4

@goldsmithb goldsmithb closed this Apr 8, 2026
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.

2 participants