diff --git a/cypress/e2e/map.cy.ts b/cypress/e2e/map.cy.ts index 54b0ab7..f99d36c 100644 --- a/cypress/e2e/map.cy.ts +++ b/cypress/e2e/map.cy.ts @@ -74,12 +74,41 @@ describe("Map", () => { cy.url().should("not.contain", "lng=-82.401078"); }); + it("Map contents are redisplayed whenever returning to the page from another", () => { + loadMap("/?maps=adult-day-care"); + + cy.get(".leaflet-marker-icon").its("length").as("initialNumberOfMarkers"); + + // Go to the About page... + cy.contains("About").click(); + // ... and then back to the map page. + cy.get("nav > a:nth-child(1)").click(); + + // Check that the markers are all still there + cy.get("@initialNumberOfMarkers").then((initialCount) => { + cy.get(".leaflet-marker-icon") + .its("length") + .then((newCount) => { + expect(initialCount).to.eq(newCount); + }); + }); + + cy.url().should("contain", "maps=adult-day-care"); + + // Check that the layer checkbox is still checked + cy.get("[title='Layers']").trigger("mouseover"); + cy.get(".leaflet-control-layers-overlays label input[checked]").should( + "have.length", + 1, + ); + }); + describe("Attribution Control", () => { it("Attribution control displays the proper message", () => { loadMap("/"); cy.get(".leaflet-control-attribution").contains( - "Brought to you by HackGreenville Labs.", + "Brought to you by HackGreenville Labs", ); }); }); diff --git a/src/components/MainMap.vue b/src/components/MainMap.vue index f9f567e..7daaa51 100644 --- a/src/components/MainMap.vue +++ b/src/components/MainMap.vue @@ -2,10 +2,11 @@ import "leaflet/dist/leaflet.css"; import L, { LatLng } from "leaflet"; import type { Map, GeoJSON, LayersControlEvent } from "leaflet"; +import { createMarker, setTooltips } from "@/utils/map";