-
Notifications
You must be signed in to change notification settings - Fork 4.5k
chore: add tests for anvil modal. #34347
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ba6956e
chore: add tests for modal.
marks0351 36727bc
chore: addressing code review comments.
marks0351 cc291be
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
marks0351 a1b6acd
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
marks0351 75d8ffb
add modal snaps
bcc4bbd
update snaps
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
167 changes: 167 additions & 0 deletions
167
app/client/cypress/e2e/Regression/ClientSide/Anvil/AnvilModal_spec.ts
This file contains hidden or 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,167 @@ | ||
| import { | ||
| agHelper, | ||
| anvilLayout, | ||
| locators, | ||
| propPane, | ||
| } from "../../../../support/Objects/ObjectsCore"; | ||
| import { ANVIL_EDITOR_TEST } from "../../../../support/Constants"; | ||
| import { anvilLocators } from "../../../../support/Pages/Anvil/Locators"; | ||
| import EditorNavigation, { | ||
| EntityType, | ||
| } from "../../../../support/Pages/EditorNavigation"; | ||
|
|
||
| describe( | ||
| `${ANVIL_EDITOR_TEST}: Anvil tests for Modals`, | ||
| { tags: ["@tag.Anvil"] }, | ||
| () => { | ||
| before(() => { | ||
| // Cleanup the canvas before each test | ||
| agHelper.SelectAllWidgets(); | ||
| agHelper.PressDelete(); | ||
| }); | ||
| it("1. Verify opening a modal by clicking on a button", () => { | ||
| // drop a modal widget | ||
| anvilLayout.dnd.DragDropNewAnvilWidgetNVerify( | ||
| anvilLocators.WDSMODAL, | ||
| 10, | ||
| 10, | ||
| { | ||
| skipWidgetSearch: true, | ||
| dropTargetDetails: { | ||
| dropModal: true, | ||
| }, | ||
| }, | ||
| ); | ||
| // press escape and close modal | ||
| agHelper.PressEscape(); | ||
| // add a button | ||
| anvilLayout.dnd.DragDropNewAnvilWidgetNVerify( | ||
| anvilLocators.WDSBUTTON, | ||
| 10, | ||
| 10, | ||
| { | ||
| skipWidgetSearch: true, | ||
| }, | ||
| ); | ||
| propPane.EnterJSContext("onClick", "{{showModal(Modal1.name);}}"); | ||
| agHelper.GetNClick(locators._enterPreviewMode); | ||
| agHelper.GetNClick(anvilLocators.anvilWidgetNameSelector("Button1")); | ||
| agHelper.AssertElementExist( | ||
| anvilLocators.anvilWidgetNameSelector("Modal1"), | ||
| ); | ||
| }); | ||
| it("2. Verify closing a modal using the close icon button", () => { | ||
| agHelper.GetNClick( | ||
| anvilLocators.anvilModalCloseIconButtonSelector("Modal1"), | ||
| ); | ||
| agHelper.AssertElementAbsence( | ||
| anvilLocators.anvilWidgetNameSelector("Modal1"), | ||
| ); | ||
| }); | ||
| it("3. Verify closing a modal by clicking outside the modal area", () => { | ||
| // open modal | ||
| agHelper.GetNClick(anvilLocators.anvilWidgetNameSelector("Button1")); | ||
| agHelper.AssertElementExist( | ||
| anvilLocators.anvilWidgetNameSelector("Modal1"), | ||
| ); | ||
| // click on overlay top position | ||
| agHelper.GetNClick( | ||
| anvilLocators.anvilModalOverlay, | ||
| 0, | ||
| false, | ||
| 500, | ||
| false, | ||
| false, | ||
| "top", | ||
| ); | ||
| agHelper.AssertElementAbsence( | ||
| anvilLocators.anvilWidgetNameSelector("Modal1"), | ||
| ); | ||
| }); | ||
| it("4. Verify closing a modal using the ESC key", () => { | ||
| // open modal | ||
| agHelper.GetNClick(anvilLocators.anvilWidgetNameSelector("Button1")); | ||
| agHelper.AssertElementExist( | ||
| anvilLocators.anvilWidgetNameSelector("Modal1"), | ||
| ); | ||
| // press escape | ||
| agHelper.PressEscape(); | ||
| agHelper.AssertElementAbsence( | ||
| anvilLocators.anvilWidgetNameSelector("Modal1"), | ||
| ); | ||
| agHelper.GetNClick(locators._exitPreviewMode); | ||
| }); | ||
| it("5. verify onClose function of Modal", () => { | ||
| EditorNavigation.SelectEntityByName("Modal1", EntityType.Widget); | ||
| propPane.EnterJSContext("onClose", "{{showAlert('onCloseTest');}}"); | ||
| agHelper.GetNClick(locators._enterPreviewMode); | ||
| //close modal via footer close button | ||
| agHelper.GetNClick( | ||
| anvilLocators.anvilModalFooterCloseButtonSelector("Modal1"), | ||
| ); | ||
| //verify alert | ||
| agHelper.ValidateToastMessage("onCloseTest"); | ||
| agHelper.GetNClick(locators._exitPreviewMode); | ||
| }); | ||
| it("6. Verify onSubmit function on Modal", () => { | ||
| EditorNavigation.SelectEntityByName("Modal1", EntityType.Widget); | ||
| propPane.EnterJSContext("onSubmit", "{{showAlert('onSubmitTest');}}"); | ||
| agHelper.GetNClick(locators._enterPreviewMode); | ||
| //close modal via submit button | ||
| agHelper.GetNClick( | ||
| anvilLocators.anvilModalFooterSubmitButtonSelector("Modal1"), | ||
| ); | ||
| //verify alert | ||
| agHelper.ValidateToastMessage("onSubmitTest"); | ||
| agHelper.GetNClick(locators._exitPreviewMode); | ||
| }); | ||
| it("7. Verify DnD on Modal", () => { | ||
| EditorNavigation.SelectEntityByName("Modal1", EntityType.Widget); | ||
| // add a widget to modal | ||
| anvilLayout.dnd.DragDropNewAnvilWidgetNVerify( | ||
| anvilLocators.WDSBUTTON, | ||
| 10, | ||
| 10, | ||
| { | ||
| skipWidgetSearch: true, | ||
| dropTargetDetails: { | ||
| name: "Modal1", | ||
| }, | ||
| }, | ||
| ); | ||
| // verify newly added button | ||
| agHelper.AssertElementExist( | ||
| anvilLocators.anvilWidgetNameSelector("Button2"), | ||
| ); | ||
| }); | ||
| it("8. Verify different modal sizes", () => { | ||
| // select all widgets and delete | ||
| agHelper.PressEscape(); | ||
| agHelper.SelectAllWidgets(); | ||
| agHelper.PressDelete(); | ||
| // add a modal widget | ||
| anvilLayout.dnd.DragDropNewAnvilWidgetNVerify( | ||
| anvilLocators.WDSMODAL, | ||
| 10, | ||
| 10, | ||
| { | ||
| skipWidgetSearch: true, | ||
| dropTargetDetails: { | ||
| dropModal: true, | ||
| }, | ||
| }, | ||
| ); | ||
| agHelper | ||
| .GetElement(anvilLocators.anvilWidgetNameSelector("Modal1")) | ||
| .matchImageSnapshot("anvilModalMediumSize"); | ||
| propPane.SelectPropertiesDropDown("size", "Small"); | ||
| agHelper | ||
| .GetElement(anvilLocators.anvilWidgetNameSelector("Modal1")) | ||
| .matchImageSnapshot("anvilModalSmallSize"); | ||
| propPane.SelectPropertiesDropDown("size", "Large"); | ||
| agHelper | ||
| .GetElement(anvilLocators.anvilWidgetNameSelector("Modal1")) | ||
| .matchImageSnapshot("anvilModalLargeSize"); | ||
| }); | ||
| }, | ||
| ); |
Binary file added
BIN
+16.5 KB
app/client/cypress/snapshots/AnvilModal_spec.ts/anvilModalLargeSize.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+13.3 KB
app/client/cypress/snapshots/AnvilModal_spec.ts/anvilModalMediumSize.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+12.2 KB
app/client/cypress/snapshots/AnvilModal_spec.ts/anvilModalSmallSize.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Tip
Codebase Verification
The search results indicate that the new widget type
WDSMODALis only defined inindex.tsand referenced in test files, but there are no indications of its handling in the main widget system logic.app/client/cypress/support/Pages/Anvil/Locators/index.ts: Definition ofWDSMODAL.This suggests that the new widget type
WDSMODALmight not be integrated into the widget system logic yet.Analysis chain
Added a new widget type for modals. Confirm that this widget type is integrated into the widget system and handled appropriately in widget-related logic.
Let's address the issue with the
rgcommand by specifying a recognized file type and ensuring we capture all relevant instances ofWDSMODAL.The search results show that the new widget type
WDSMODALis defined inindex.tsand referenced in theAnvilModal_spec.tstest files. However, to confirm proper integration and handling in the widget system logic, we need to verify its usage beyond just test files.Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 66
Script:
Length of output: 335
Script:
Length of output: 153