create map test

deepsource-autofix-76c6eb20
Dan Gowans 2022-09-20 15:59:52 -04:00
parent b0a6e1b085
commit 1c6f3a15dd
4 changed files with 154 additions and 0 deletions

View File

@ -0,0 +1 @@
export {};

View File

@ -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());
});
});
});
});

View File

@ -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());
});
});
});
});

View File

@ -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
}