From 1c6f3a15dd65337184952756aa27502ec7d00e9a Mon Sep 17 00:00:00 2001 From: Dan Gowans Date: Tue, 20 Sep 2022 15:59:52 -0400 Subject: [PATCH] create map test --- cypress/e2e/02-update/maps.cy.d.ts | 1 + cypress/e2e/02-update/maps.cy.js | 57 ++++++++++++++++++++ cypress/e2e/02-update/maps.cy.ts | 86 ++++++++++++++++++++++++++++++ cypress/fixtures/map.json | 10 ++++ 4 files changed, 154 insertions(+) create mode 100644 cypress/e2e/02-update/maps.cy.d.ts create mode 100644 cypress/e2e/02-update/maps.cy.js create mode 100644 cypress/e2e/02-update/maps.cy.ts create mode 100644 cypress/fixtures/map.json diff --git a/cypress/e2e/02-update/maps.cy.d.ts b/cypress/e2e/02-update/maps.cy.d.ts new file mode 100644 index 00000000..cb0ff5c3 --- /dev/null +++ b/cypress/e2e/02-update/maps.cy.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/cypress/e2e/02-update/maps.cy.js b/cypress/e2e/02-update/maps.cy.js new file mode 100644 index 00000000..98b4ceca --- /dev/null +++ b/cypress/e2e/02-update/maps.cy.js @@ -0,0 +1,57 @@ +import { testUpdate } from "../../../test/_globals.js"; +import { logout, login } from "../../support/index.js"; +import * as configFunctions from "../../../helpers/functions.config.js"; +describe("Update - Maps", () => { + before(() => { + logout(); + login(testUpdate); + }); + it('Has a "Create" link on the Map Search', () => { + cy.visit("/maps"); + cy.get("a[href$='/maps/new']").should("exist"); + }); + describe("Update a New Map", () => { + before(() => { + cy.visit("/maps/new"); + }); + it("Has no detectable accessibility issues", () => { + cy.injectAxe(); + cy.checkA11y(); + }); + it("Can populate basic details", () => { + cy.fixture("map.json").then((mapJSON) => { + cy.get("input[name='mapName']").clear().type(mapJSON.mapName); + cy.get("textarea[name='mapDescription']").clear().type(mapJSON.mapDescription); + cy.get("input[name='mapAddress1']").clear().type(mapJSON.mapAddress1); + cy.get("input[name='mapAddress2']").clear().type(mapJSON.mapAddress2); + cy.get("input[name='mapPostalCode']").clear().type(mapJSON.mapPostalCode); + cy.get("input[name='mapPhoneNumber']").clear().type(mapJSON.mapPhoneNumber); + cy.get("input[name='mapLatitude']").clear().type(mapJSON.mapLatitude.toString()); + cy.get("input[name='mapLongitude']").clear().type(mapJSON.mapLongitude.toString()); + }); + }); + it("Should use the default map city and province", () => { + cy.get("input[name='mapCity']").should("have.value", configFunctions.getProperty("settings.map.mapCityDefault")); + cy.get("input[name='mapProvince']").should("have.value", configFunctions.getProperty("settings.map.mapProvinceDefault")); + }); + it("Should submit form and create the map", () => { + cy.get("#form--map").submit(); + cy.wait(1000); + cy.location("pathname").should("not.contain", "/new").should("contain", "/edit"); + }); + it("Should be populated as expected", () => { + cy.fixture("map.json").then((mapJSON) => { + cy.get("input[name='mapName']").should("have.value", mapJSON.mapName); + cy.get("textarea[name='mapDescription']").should("have.value", mapJSON.mapDescription); + cy.get("input[name='mapAddress1']").should("have.value", mapJSON.mapAddress1); + cy.get("input[name='mapAddress2']").should("have.value", mapJSON.mapAddress2); + cy.get("input[name='mapCity']").should("have.value", configFunctions.getProperty("settings.map.mapCityDefault")); + cy.get("input[name='mapProvince']").should("have.value", configFunctions.getProperty("settings.map.mapProvinceDefault")); + cy.get("input[name='mapPostalCode']").should("have.value", mapJSON.mapPostalCode); + cy.get("input[name='mapPhoneNumber']").should("have.value", mapJSON.mapPhoneNumber); + cy.get("input[name='mapLatitude']").should("have.value", mapJSON.mapLatitude.toString()); + cy.get("input[name='mapLongitude']").should("have.value", mapJSON.mapLongitude.toString()); + }); + }); + }); +}); diff --git a/cypress/e2e/02-update/maps.cy.ts b/cypress/e2e/02-update/maps.cy.ts new file mode 100644 index 00000000..06dce554 --- /dev/null +++ b/cypress/e2e/02-update/maps.cy.ts @@ -0,0 +1,86 @@ +import { testUpdate } from "../../../test/_globals.js"; + +import { logout, login } from "../../support/index.js"; + +import * as configFunctions from "../../../helpers/functions.config.js"; + +import * as recordTypes from "../../../types/recordTypes"; + +describe("Update - Maps", () => { + before(() => { + logout(); + login(testUpdate); + }); + + it('Has a "Create" link on the Map Search', () => { + cy.visit("/maps"); + cy.get("a[href$='/maps/new']").should("exist"); + }); + + describe("Update a New Map", () => { + before(() => { + cy.visit("/maps/new"); + }); + + it("Has no detectable accessibility issues", () => { + cy.injectAxe(); + cy.checkA11y(); + }); + + it("Can populate basic details", () => { + // eslint-disable-next-line promise/catch-or-return, promise/always-return + cy.fixture("map.json").then((mapJSON: recordTypes.Map) => { + cy.get("input[name='mapName']").clear().type(mapJSON.mapName); + cy.get("textarea[name='mapDescription']").clear().type(mapJSON.mapDescription); + + cy.get("input[name='mapAddress1']").clear().type(mapJSON.mapAddress1); + cy.get("input[name='mapAddress2']").clear().type(mapJSON.mapAddress2); + cy.get("input[name='mapPostalCode']").clear().type(mapJSON.mapPostalCode); + cy.get("input[name='mapPhoneNumber']").clear().type(mapJSON.mapPhoneNumber); + + cy.get("input[name='mapLatitude']").clear().type(mapJSON.mapLatitude.toString()); + cy.get("input[name='mapLongitude']").clear().type(mapJSON.mapLongitude.toString()); + }); + }); + + it("Should use the default map city and province", () => { + cy.get("input[name='mapCity']").should( + "have.value", + configFunctions.getProperty("settings.map.mapCityDefault") + ); + + cy.get("input[name='mapProvince']").should( + "have.value", + configFunctions.getProperty("settings.map.mapProvinceDefault") + ); + }); + + it("Should submit form and create the map", () => { + cy.get("#form--map").submit(); + + cy.wait(1000); + + cy.location("pathname").should("not.contain", "/new").should("contain", "/edit"); + }); + + it("Should be populated as expected", () => { + // eslint-disable-next-line promise/catch-or-return, promise/always-return + cy.fixture("map.json").then((mapJSON: recordTypes.Map) => { + cy.get("input[name='mapName']").should("have.value",mapJSON.mapName); + cy.get("textarea[name='mapDescription']").should("have.value",mapJSON.mapDescription); + + cy.get("input[name='mapAddress1']").should("have.value",mapJSON.mapAddress1); + cy.get("input[name='mapAddress2']").should("have.value",mapJSON.mapAddress2); + + cy.get("input[name='mapCity']").should("have.value", configFunctions.getProperty("settings.map.mapCityDefault")); + cy.get("input[name='mapProvince']").should("have.value", configFunctions.getProperty("settings.map.mapProvinceDefault")); + + cy.get("input[name='mapPostalCode']").should("have.value",mapJSON.mapPostalCode); + cy.get("input[name='mapPhoneNumber']").should("have.value",mapJSON.mapPhoneNumber); + + cy.get("input[name='mapLatitude']").should("have.value",mapJSON.mapLatitude.toString()); + cy.get("input[name='mapLongitude']").should("have.value",mapJSON.mapLongitude.toString()); + }); + }); + }); +}); diff --git a/cypress/fixtures/map.json b/cypress/fixtures/map.json new file mode 100644 index 00000000..f419855a --- /dev/null +++ b/cypress/fixtures/map.json @@ -0,0 +1,10 @@ +{ + "mapName": "Holy Sepulchre", + "mapDescription": "Operated by the City of Sault Ste. Marie" , + "mapAddress1": "Fourth Line and Peoples Road", + "mapAddress2": "27 Fourth Line East", + "mapPostalCode": "P6A 5K8", + "mapPhoneNumber": "705-759-5336", + "mapLatitude": 46.56874795, + "mapLongitude": -84.34842824 +} \ No newline at end of file