Skip to content
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

test: flaky cypress listing search (#4335) #830

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions sites/partners/cypress/e2e/default/03-listing.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,7 @@ describe("Listing Management Tests", () => {

// eslint-disable-next-line @typescript-eslint/no-explicit-any
function verifyDetails(cy: Cypress.cy, listing: any): void {
cy.visit("/")
cy.getByTestId("ag-search-input").type(listing["name"])
cy.getByTestId(listing["name"]).first().click()
cy.findAndOpenListing(listing["name"])
cy.getByID("jurisdictions.name").contains(listing["jurisdiction.id"])
cy.getByID("name").contains(listing["name"])
cy.getByID("developer").contains(listing["developer"])
Expand Down Expand Up @@ -386,9 +384,7 @@ describe("Listing Management Tests", () => {

// eslint-disable-next-line @typescript-eslint/no-explicit-any
function verifyOpenListingWarning(cy: Cypress.cy, listing: any): void {
cy.visit("/")
cy.getByTestId("ag-search-input").type(listing["name"])
cy.getByTestId(listing["name"]).first().click()
cy.findAndOpenListing(listing["name"])
cy.getByID("listingEditButton").contains("Edit").click()
cy.getByTestId("nameField")
.should("be.visible")
Expand Down
24 changes: 7 additions & 17 deletions sites/partners/cypress/e2e/default/09-lottery.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ describe("Lottery Tests", () => {
cy.addMinimalApplication(uniqueListingName)

// Close the listing and view lottery tab
cy.visit("/")
cy.contains("Listings")
cy.getByTestId("ag-search-input").type(uniqueListingName)
cy.getByTestId(uniqueListingName).first().click()
cy.findAndOpenListing(uniqueListingName)
cy.getByID("listingEditButton").contains("Edit").click()
cy.getByID("closeButton").contains("Close").click()
cy.getByID("close-listing-modal-button").contains("Close").click()
Expand All @@ -45,18 +42,17 @@ describe("Lottery Tests", () => {
cy.visit("/")
cy.getByTestId("Users-1").click()
cy.contains("Users")
cy.getByTestId("ag-search-input").type("[email protected]")
cy.getByTestId("ag-search-input")
.should("be.visible")
.type("[email protected]", { force: true })
cy.getByID("[email protected]").first().click()
cy.getByTestId("listings-all-Bay Area").check({ force: true })
cy.getByID("save-user").click()

// Login as partner and view lottery tab
cy.signOut()
cy.login("partnerUser")
cy.visit("/")
cy.contains("Listings")
cy.getByTestId("ag-search-input").type(uniqueListingName)
cy.getByTestId(uniqueListingName).first().click()
cy.findAndOpenListing(uniqueListingName)
cy.get(`[role="tab"]`).eq(2).click()
cy.get("h2").contains("Publish lottery data")

Expand All @@ -68,10 +64,7 @@ describe("Lottery Tests", () => {
// Login as admin and view lottery tab
cy.signOut()
cy.login()
cy.visit("/")
cy.contains("Listings")
cy.getByTestId("ag-search-input").type(uniqueListingName)
cy.getByTestId(uniqueListingName).first().click()
cy.findAndOpenListing(uniqueListingName)
cy.get(`[role="tab"]`).eq(2).click()
cy.get("h2").contains("Export lottery data")

Expand All @@ -83,10 +76,7 @@ describe("Lottery Tests", () => {
// Login as partner and view lottery tab, ensure no data
cy.signOut()
cy.login("partnerUser")
cy.visit("/")
cy.contains("Listings")
cy.getByTestId("ag-search-input").type(uniqueListingName)
cy.getByTestId(uniqueListingName).first().click()
cy.findAndOpenListing(uniqueListingName)
cy.get(`[role="tab"]`).eq(2).click()
cy.get("h2").contains("No lottery data")
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe("Listings approval feature", () => {

// Admin: Request changes
cy.login("user")
searchAndOpenListing(cy, uniqueListingName)
cy.findAndOpenListing(uniqueListingName)
cy.getByID("listing-status-pending-review").should("be.visible")
cy.getByID("listingEditButton").click()
cy.getByID("requestChangesButton").click()
Expand All @@ -29,7 +29,7 @@ describe("Listings approval feature", () => {

// Partner: Can see the requested changes, edit the listing, and resubmit for approval
cy.login("jurisdictionalAdminUser")
searchAndOpenListing(cy, uniqueListingName)
cy.findAndOpenListing(uniqueListingName)
cy.getByID("listing-status-changes-requested").should("be.visible")
cy.getByID("requestedChanges").contains("Requested changes test summary")
cy.getByID("requestedChangesUser").contains("First Last")
Expand All @@ -42,17 +42,12 @@ describe("Listings approval feature", () => {

// Admin: Approve and publish
cy.login("user")
searchAndOpenListing(cy, uniqueListingNameEdited)
cy.findAndOpenListing(uniqueListingNameEdited)
cy.getByID("listingEditButton").click()
cy.getByID("saveAndContinueButton").should("be.visible")
cy.getByID("listing-status-pending-review").should("be.visible")
cy.getByID("approveAndPublishButton").click()
cy.getByID("listing-status-active").should("be.visible")
cy.signOut()
})

function searchAndOpenListing(cy: Cypress.cy, name: string): void {
cy.getByTestId("ag-search-input").type(name)
cy.getByTestId(name).click()
}
})
7 changes: 7 additions & 0 deletions sites/partners/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,3 +474,10 @@ Cypress.Commands.add("addMinimalApplication", (listingName) => {
})
cy.getByID("submitApplicationButton").click()
})

Cypress.Commands.add("findAndOpenListing", (listingName) => {
cy.visit("/")
cy.contains("Listings")
cy.getByTestId("ag-search-input").should("be.visible").type(listingName, { force: true })
cy.getByTestId(listingName).first().click()
})
1 change: 1 addition & 0 deletions sites/partners/cypress/support/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ declare namespace Cypress {
jurisdiction: boolean
): Chainable
addMinimalApplication(listingName: string): Chainable
findAndOpenListing(listingName: string): Chainable
}
}
/* eslint-enable @typescript-eslint/no-unused-vars */
Loading