-
Notifications
You must be signed in to change notification settings - Fork 70
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
VACMS-15783: Alt-Text Validation Testing #16159
Merged
tonytaylor
merged 6 commits into
15785-alt-text-validation
from
VACMS-15783-alt-text-validation-testing
Nov 22, 2023
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1b37b5f
VACMS-15783 adds tests in support of alt-text validation
tonytaylor 19966d8
updates composer.json
tonytaylor cee1637
adds scenario where editor corrects after receiving error message
tonytaylor 99a2e5d
corrects command script (adjusted for local env)
tonytaylor 65bf775
adds hard validation tests
tonytaylor a4ce74f
refactors step definition to use action semantics
tonytaylor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
tests/cypress/integration/features/platform/alt_text_validation.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
Feature: Alt-Text Validation | ||
In order to enhance the veteran experience | ||
As an editor | ||
I need just-in-time guidance as to best practices surrounding alt-text content | ||
|
||
Scenario: An editor supplies verbose alt-text content (server-side validation) | ||
Given I am logged in as a user with the "administrator" role | ||
When I save an image with 152 characters of alt-text content | ||
Then I should see "Alternative text cannot be longer than 150 characters." | ||
|
||
Scenario: An editor supplies redundant alt-text content (server-side validation) | ||
Given I am logged in as a user with the "administrator" role | ||
When I save an image with "Image of polygon" as alt-text | ||
Then I should see "Alternative text cannot contain phrases like “image of”, “photo of”, “graphic of”, “picture of”, etc." | ||
|
||
Scenario: An editor supplies the name of the image file as alt-text content (server-side validation) | ||
Given I am logged in as a user with the "administrator" role | ||
When I save an image with "polygon_image.png" as alt-text | ||
Then I should see "Alternative text cannot contain file names." | ||
|
||
Scenario: An editor supplies verbose alt-text content (element blur validation) | ||
Given I am logged in as a user with the "administrator" role | ||
When I create an image with 152 characters of alt-text content | ||
Then I should see "Alternative text cannot be longer than 150 characters." | ||
|
||
Scenario: An editor supplies redundant alt-text content (element blur validation) | ||
Given I am logged in as a user with the "administrator" role | ||
When I create an image with "Image of polygon" as alt-text | ||
Then I should see "Alternative text cannot contain phrases like “image of”, “photo of”, “graphic of”, “picture of”, etc." | ||
|
||
Scenario: An editor supplies the name of the image file as alt-text content (element blur validation) | ||
Given I am logged in as a user with the "administrator" role | ||
When I create an image with "polygon_image.png" as alt-text | ||
Then I should see "Alternative text cannot contain file names." | ||
|
||
Scenario: An editor supplies the name of the image file and then correctly edits field | ||
Given I am logged in as a user with the "administrator" role | ||
When I create an image with "polygon_image.png" as alt-text | ||
Then I should see "Alternative text cannot contain file names." | ||
When I update alt-text content to display "a simple polygon placeholder" | ||
Then I should see no error message |
59 changes: 59 additions & 0 deletions
59
tests/cypress/integration/step_definitions/common/i_create_an_image_with_alt_text.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { When, Then } from "@badeball/cypress-cucumber-preprocessor"; | ||
import { faker } from "@faker-js/faker"; | ||
|
||
const navigateToAndFillMediaForm = () => { | ||
cy.visit("/media/add/image"); | ||
cy.injectAxe(); | ||
cy.scrollTo("top"); | ||
cy.findAllByLabelText("Name").type(`[Test Data] ${faker.lorem.sentence()}`, { | ||
force: true, | ||
}); | ||
cy.findAllByLabelText("Description").type(faker.lorem.sentence(), { | ||
force: true, | ||
}); | ||
cy.findAllByLabelText("Section").select("VACO"); | ||
cy.get("#edit-image-0-upload") | ||
.attachFile("images/polygon_image.png") | ||
.wait(1000); | ||
}; | ||
|
||
const focusOnNameField = () => { | ||
cy.findAllByLabelText("Name").focus(); | ||
}; | ||
|
||
When("I create an image with {string} as alt-text", (altTextContent) => { | ||
navigateToAndFillMediaForm(); | ||
cy.findAllByLabelText("Alternative text").type(altTextContent, { | ||
force: true, | ||
}); | ||
focusOnNameField(); | ||
}); | ||
|
||
When( | ||
"I create an image with {int} characters of alt-text content", | ||
(charCount) => { | ||
navigateToAndFillMediaForm(); | ||
cy.findAllByLabelText("Alternative text").type( | ||
faker.helpers.repeatString("a", charCount), | ||
{ | ||
force: true, | ||
} | ||
); | ||
focusOnNameField(); | ||
} | ||
); | ||
|
||
When("I update alt-text content to display {string}", (altTextContent) => { | ||
cy.findAllByLabelText("Alternative text").clear(); | ||
cy.findAllByLabelText("Alternative text").type(altTextContent, { | ||
force: true, | ||
}); | ||
}); | ||
|
||
Then("I should see no error message", () => { | ||
cy.get("div.form-item--error-message > strong").should( | ||
"have.attr", | ||
"style", | ||
"display: none;" | ||
); | ||
}); |
45 changes: 45 additions & 0 deletions
45
tests/cypress/integration/step_definitions/common/i_save_an_image_with_alt_text.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { When } from "@badeball/cypress-cucumber-preprocessor"; | ||
import { faker } from "@faker-js/faker"; | ||
|
||
const navigateToAndFillMediaForm = () => { | ||
cy.visit("/media/add/image"); | ||
cy.injectAxe(); | ||
cy.scrollTo("top"); | ||
cy.findAllByLabelText("Name").type(`[Test Data] ${faker.lorem.sentence()}`, { | ||
force: true, | ||
}); | ||
cy.findAllByLabelText("Description").type(faker.lorem.sentence(), { | ||
force: true, | ||
}); | ||
cy.findAllByLabelText("Section").select("VACO"); | ||
cy.get("#edit-image-0-upload") | ||
.attachFile("images/polygon_image.png") | ||
.wait(1000); | ||
}; | ||
|
||
const clickSaveButton = () => { | ||
cy.get("form.media-form input#edit-submit").click(); | ||
cy.wait(1000); | ||
}; | ||
|
||
When("I save an image with {string} as alt-text", (altTextContent) => { | ||
navigateToAndFillMediaForm(); | ||
cy.findAllByLabelText("Alternative text").type(altTextContent, { | ||
force: true, | ||
}); | ||
clickSaveButton(); | ||
}); | ||
|
||
When( | ||
"I save an image with {int} characters of alt-text content", | ||
(charCount) => { | ||
navigateToAndFillMediaForm(); | ||
cy.findAllByLabelText("Alternative text").type( | ||
faker.helpers.repeatString("a", charCount), | ||
{ | ||
force: true, | ||
} | ||
); | ||
clickSaveButton(); | ||
} | ||
); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strange, this should have been updated in 531ad7f. Can you double check why this change show up here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tonytaylor you might need to merge in a fresh copy of main?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This branch isn't based off
main
, but15785-alt-text-validation
. So it should merge from that branch, notmain
. If that branch is being used as an integration branch, then it needs to be kept updated to avoid freaking out passersby.Since this merged from
main
, it now includes changes tomain
that weren't in15785-alt-text-validation
, which makes this PR longer and weird AF to review.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, I also recommend for PRs to use rebase instead of merge to simplify the commit history for review purposes. Let me know if you need help with untangling this @tonytaylor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JunTaoLuo Thanks, I appreciate it. I could definitely stand to work on my git-fu.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to ping me on Slack whenever you want to sort out the git history tomorrow!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noting here that this is needed because the base Tugboat image is based off of main and the base branch 15785-alt-text-validation is out of date with main, hence the need to add this tactical fix. This change will go away when the base branch is updated but we won't be blocking on that to merge the PR.