Skip to content

Commit

Permalink
test: new cypress
Browse files Browse the repository at this point in the history
  • Loading branch information
emilyjablonski committed Nov 25, 2024
1 parent 506be79 commit b7dc642
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions sites/public/cypress/e2e/pages/listings-map.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// When testing this locally, ensure your screen size compares to Cypress's screen size as it will affect the way the map creates clusters
describe("Listings map", function () {
it("renders the listing map", function () {
cy.viewport(905, 1100)
cy.viewport(1500, 1100)
cy.intercept("**/listings/mapMarkers", (req) => {
req.headers["language"] = "en"
}).as("markersSearch")
Expand All @@ -19,28 +19,26 @@ describe("Listings map", function () {
// Initial map load
cy.getByTestId("map-total-results").contains("Total results 249")
cy.getByTestId("map-pagination").contains("Page 1 of 10")
cy.getByTestId("map-cluster").should("have.length", 8)
cy.getByTestId("map-cluster").should("have.length", 17)

cy.getByTestId("loading-overlay").should("not.exist")
// Fetch markers + listings once on page load
cy.get("@markersSearch.all").should("have.length", 1)
cy.get("@listingsSearch.all").should("have.length", 1)

// Click into one cluster
cy.get('[aria-label="109 listings in this cluster"]').contains("109").click({ force: true })
cy.get('[aria-label="32 listings in this cluster"]').contains("32")
cy.getByTestId("map-cluster").should("have.length", 25)
cy.getByTestId("map-total-results").contains("Total results 182")
cy.getByTestId("map-pagination").contains("Page 1 of 8")
cy.get('[aria-label="58 listings in this cluster"]').contains("58").click({ force: true })
cy.getByTestId("map-total-results").contains("Total results 83")
cy.getByTestId("map-pagination").contains("Page 1 of 4")

cy.getByTestId("loading-overlay").should("not.exist")
// Not filtering, just panning - only fetch listings
cy.get("@markersSearch.all").should("have.length", 1)
cy.get("@listingsSearch.all").should("have.length", 2)

// Click into another cluster
cy.get('[aria-label="5 listings in this cluster"]').contains("5").click()
cy.getByTestId("map-total-results").contains("Total results 5")
cy.get('[aria-label="3 listings in this cluster"]').contains("3").click()
cy.getByTestId("map-total-results").contains("Total results 4")
cy.getByTestId("map-pagination").contains("Page 1 of 1")

cy.getByTestId("loading-overlay").should("not.exist")
Expand Down Expand Up @@ -85,7 +83,10 @@ describe("Listings map", function () {
cy.getByTestId("map-total-results").contains("Total results 4")
cy.getByTestId("loading-overlay").should("not.exist")
cy.getByTestId("map").dblclick(100, 20)
cy.getByTestId("map-total-results").contains("Total results 0")
cy.getByTestId("map-total-results").contains("Total results 2")
cy.getByTestId("loading-overlay").should("not.exist")
cy.getByTestId("map").dblclick(100, 20)
cy.getByTestId("map-total-results").contains("Total results 2")
cy.contains("No matching listings")
cy.getByTestId("loading-overlay").should("not.exist")

Expand All @@ -97,7 +98,7 @@ describe("Listings map", function () {
cy.getByTestId("loading-overlay").should("not.exist")
cy.getByTestId("map-zoom-out").click()
cy.getByTestId("loading-overlay").should("not.exist")
cy.getByTestId("map-total-results").contains("Total results 5")
cy.getByTestId("map-total-results").contains("Total results 4")
cy.get("@listingsSearch.all").should("have.length", 6)
})
})

0 comments on commit b7dc642

Please sign in to comment.