-
Notifications
You must be signed in to change notification settings - Fork 447
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
Refactor Facility Export & Add New Sidebar collapse & expand Test #9066
base: develop
Are you sure you want to change the base?
Changes from 6 commits
9ad063c
be0448e
eb07939
287e353
afa760c
5f57f05
3d06dba
8b2fb07
495a476
4503dae
9d65b4f
6383d75
19a6609
bbe15ed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -4,6 +4,9 @@ class FacilityHome { | |||||||||||||
searchButton = "#search"; | ||||||||||||||
menuItem = "[role='menuitem']"; | ||||||||||||||
|
||||||||||||||
sidebarToggle = () => cy.get('[data-testid="sidebar-toggle"]'); | ||||||||||||||
sidebarItems = () => cy.get('[data-testid="sidebar-item"]'); | ||||||||||||||
|
||||||||||||||
// Operations | ||||||||||||||
clickExportButton() { | ||||||||||||||
cy.get(this.exportButton).scrollIntoView(); | ||||||||||||||
|
@@ -104,6 +107,26 @@ class FacilityHome { | |||||||||||||
const encodedText = encodeURIComponent(searchText).replace(/%20/g, "+"); | ||||||||||||||
this.getURL().should("include", `search=${encodedText}`); | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
toggleSidebar() { | ||||||||||||||
this.sidebarToggle().click(); | ||||||||||||||
} | ||||||||||||||
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. 🛠️ Refactor suggestion Add visibility check before clicking To prevent flaky tests, consider adding a visibility check before clicking: toggleSidebar() {
- this.sidebarToggle().click();
+ this.sidebarToggle().should('be.visible').click();
} 📝 Committable suggestion
Suggested change
|
||||||||||||||
|
||||||||||||||
verifyIconsAndTextVisible() { | ||||||||||||||
this.sidebarItems().each(($item) => { | ||||||||||||||
cy.wrap($item).find('[data-testid="sidebar-icon"]').should("be.visible"); | ||||||||||||||
cy.wrap($item).find('[data-testid="sidebar-text"]').should("be.visible"); | ||||||||||||||
}); | ||||||||||||||
} | ||||||||||||||
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. 🛠️ Refactor suggestion Enhance verification methods reliability and reduce duplication Consider these improvements:
+ private verifySidebarElements(textVisibility: 'be.visible' | 'not.be.visible') {
+ this.sidebarItems().should('have.length.at.least', 1)
+ .each(($item) => {
+ cy.wrap($item, { timeout: 10000 })
+ .find('[data-testid="sidebar-icon"]')
+ .should('be.visible');
+ cy.wrap($item, { timeout: 10000 })
+ .find('[data-testid="sidebar-text"]')
+ .should(textVisibility);
+ });
+ }
verifyIconsAndTextVisible() {
- this.sidebarItems().each(($item) => {
- cy.wrap($item).find('[data-testid="sidebar-icon"]').should("be.visible");
- cy.wrap($item).find('[data-testid="sidebar-text"]').should("be.visible");
- });
+ this.verifySidebarElements('be.visible');
}
verifyIconsVisibleAndTextHidden() {
- this.sidebarItems().each(($item) => {
- cy.wrap($item).find('[data-testid="sidebar-icon"]').should("be.visible");
- cy.wrap($item)
- .find('[data-testid="sidebar-text"]')
- .should("not.be.visible");
- });
+ this.verifySidebarElements('not.be.visible');
} Also applies to: 122-129 |
||||||||||||||
|
||||||||||||||
verifyIconsVisibleAndTextHidden() { | ||||||||||||||
this.sidebarItems().each(($item) => { | ||||||||||||||
cy.wrap($item).find('[data-testid="sidebar-icon"]').should("be.visible"); | ||||||||||||||
cy.wrap($item) | ||||||||||||||
.find('[data-testid="sidebar-text"]') | ||||||||||||||
.should("not.be.visible"); | ||||||||||||||
}); | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
export default FacilityHome; |
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.