This repository has been archived by the owner on Jul 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
EVG-20833 Update modal to latest version #2039
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b161419
Update modal
khelif96 28cf1e7
Fix cypress test
khelif96 6f32c74
Mock tabbable
khelif96 8a694a5
Remove unused dep
khelif96 f6c76ec
move focus-trap-react mock
khelif96 fe18c09
Merge branch 'main' into EVG-20833-2
khelif96 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Mock focus-trap-react to prevent errors in tests that use modals. focus-trap-react is a package used | ||
// by LeafyGreen and is not a direct dependency of Spruce. | ||
const lib = jest.requireActual("focus-trap-react"); | ||
|
||
lib.prototype.setupFocusTrap = () => null; | ||
|
||
module.exports = lib; |
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,16 @@ | ||
// https://github.com/focus-trap/tabbable#testing-in-jsdom | ||
const lib = jest.requireActual("tabbable"); | ||
|
||
const tabbable = { | ||
...lib, | ||
tabbable: (node, options) => | ||
lib.tabbable(node, { ...options, displayCheck: "none" }), | ||
focusable: (node, options) => | ||
lib.focusable(node, { ...options, displayCheck: "none" }), | ||
isFocusable: (node, options) => | ||
lib.isFocusable(node, { ...options, displayCheck: "none" }), | ||
isTabbable: (node, options) => | ||
lib.isTabbable(node, { ...options, displayCheck: "none" }), | ||
}; | ||
|
||
module.exports = tabbable; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,14 +8,16 @@ describe("Name change modal", () => { | |
cy.contains(originalName); | ||
cy.dataCy("name-change-modal-trigger").click(); | ||
const newName = "a different name"; | ||
cy.get("textarea").clear().type(newName); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ty for fixing these! |
||
cy.get("textarea").clear(); | ||
cy.get("textarea").type(newName); | ||
cy.contains("Confirm").click(); | ||
cy.get("textarea").should("not.exist"); | ||
cy.contains(newName); | ||
cy.validateToast("success", "Patch name was successfully updated.", true); | ||
// revert name change | ||
cy.dataCy("name-change-modal-trigger").click(); | ||
cy.get("textarea").clear().type(originalName); | ||
cy.get("textarea").clear(); | ||
cy.get("textarea").type(originalName); | ||
cy.contains("Confirm").click(); | ||
cy.get("textarea").should("not.exist"); | ||
cy.validateToast("success", "Patch name was successfully updated.", true); | ||
|
@@ -25,13 +27,25 @@ describe("Name change modal", () => { | |
it("The confirm button is disabled when the text area value is empty or greater than 300 characters", () => { | ||
cy.dataCy("name-change-modal-trigger").click(); | ||
cy.get("textarea").clear(); | ||
cy.contains("button", "Confirm").should("be.disabled"); | ||
cy.contains("button", "Confirm").should( | ||
"have.attr", | ||
"aria-disabled", | ||
"true" | ||
); | ||
cy.get("textarea").type("lol"); | ||
cy.contains("button", "Confirm").should("not.be.disabled"); | ||
cy.contains("button", "Confirm").should( | ||
"have.attr", | ||
"aria-disabled", | ||
"false" | ||
); | ||
const over300Chars = | ||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; | ||
cy.get("textarea").type(over300Chars); | ||
cy.contains("button", "Confirm").should("be.disabled"); | ||
cy.contains("button", "Confirm").should( | ||
"have.attr", | ||
"aria-disabled", | ||
"true" | ||
); | ||
cy.contains("Value cannot exceed 300 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
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
Oops, something went wrong.
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.
makes me so sad 😭 ... btw, do we want to try to consolidate it with the other
focus-trap
mock so they're in the same file?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.
good call moved it to the mocks directory so they get picked up by jest