From b0a6e1b0851e4c57e935b79aec1e7269a5d73d16 Mon Sep 17 00:00:00 2001 From: Dan Gowans Date: Tue, 20 Sep 2022 15:13:34 -0400 Subject: [PATCH] initial testing --- cypress/e2e/01-admin/cleanupDatabase.cy.d.ts | 1 + cypress/e2e/01-admin/cleanupDatabase.cy.js | 25 ++++++++ cypress/e2e/01-admin/cleanupDatabase.cy.ts | 38 ++++++++++++ cypress/e2e/02-update/updateUser.cy.d.ts | 1 + cypress/e2e/02-update/updateUser.cy.js | 26 ++++++++ cypress/e2e/02-update/updateUser.cy.ts | 34 +++++++++++ cypress/e2e/03-readOnly/readOnlyUser.cy.d.ts | 1 + cypress/e2e/03-readOnly/readOnlyUser.cy.js | 50 +++++++++++++++ cypress/e2e/03-readOnly/readOnlyUser.cy.ts | 64 ++++++++++++++++++++ views/admin-cleanup.ejs | 2 +- 10 files changed, 241 insertions(+), 1 deletion(-) create mode 100644 cypress/e2e/01-admin/cleanupDatabase.cy.d.ts create mode 100644 cypress/e2e/01-admin/cleanupDatabase.cy.js create mode 100644 cypress/e2e/01-admin/cleanupDatabase.cy.ts create mode 100644 cypress/e2e/02-update/updateUser.cy.d.ts create mode 100644 cypress/e2e/02-update/updateUser.cy.js create mode 100644 cypress/e2e/02-update/updateUser.cy.ts create mode 100644 cypress/e2e/03-readOnly/readOnlyUser.cy.d.ts create mode 100644 cypress/e2e/03-readOnly/readOnlyUser.cy.js create mode 100644 cypress/e2e/03-readOnly/readOnlyUser.cy.ts diff --git a/cypress/e2e/01-admin/cleanupDatabase.cy.d.ts b/cypress/e2e/01-admin/cleanupDatabase.cy.d.ts new file mode 100644 index 00000000..cb0ff5c3 --- /dev/null +++ b/cypress/e2e/01-admin/cleanupDatabase.cy.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/cypress/e2e/01-admin/cleanupDatabase.cy.js b/cypress/e2e/01-admin/cleanupDatabase.cy.js new file mode 100644 index 00000000..595f4838 --- /dev/null +++ b/cypress/e2e/01-admin/cleanupDatabase.cy.js @@ -0,0 +1,25 @@ +import { testAdmin } from "../../../test/_globals.js"; +import { logout, login, ajaxDelayMillis } from "../../support/index.js"; +describe("Admin - Cleanup Database", () => { + before(() => { + logout(); + login(testAdmin); + }); + after(logout); + beforeEach("Loads page", () => { + cy.visit("/admin/cleanup"); + cy.location("pathname").should("equal", "/admin/cleanup"); + }); + it("Has no detectable accessibility issues", () => { + cy.injectAxe(); + cy.checkA11y(); + }); + it("Cleans up the database", () => { + cy.get("button[data-cy='cleanup']").click(); + cy.get(".modal").should("be.visible").should("contain.text", "Cleanup"); + cy.get(".modal button[data-cy='ok']").click(); + cy.wait(ajaxDelayMillis); + cy.get(".modal").should("contain.text", "Cleaned Up").should("contain.text", "Success"); + cy.get(".modal button[data-cy='ok']").click(); + }); +}); diff --git a/cypress/e2e/01-admin/cleanupDatabase.cy.ts b/cypress/e2e/01-admin/cleanupDatabase.cy.ts new file mode 100644 index 00000000..6709147c --- /dev/null +++ b/cypress/e2e/01-admin/cleanupDatabase.cy.ts @@ -0,0 +1,38 @@ +/* eslint-disable unicorn/filename-case, promise/catch-or-return, promise/always-return */ + +import { testAdmin } from "../../../test/_globals.js"; + +import { logout, login, ajaxDelayMillis } from "../../support/index.js"; + +describe("Admin - Cleanup Database", () => { + before(() => { + logout(); + login(testAdmin); + }); + + after(logout); + + beforeEach("Loads page", () => { + cy.visit("/admin/cleanup"); + cy.location("pathname").should("equal", "/admin/cleanup"); + }); + + it("Has no detectable accessibility issues", () => { + cy.injectAxe(); + cy.checkA11y(); + }); + + it("Cleans up the database", () => { + cy.get("button[data-cy='cleanup']").click(); + + cy.get(".modal").should("be.visible").should("contain.text", "Cleanup"); + + cy.get(".modal button[data-cy='ok']").click(); + + cy.wait(ajaxDelayMillis); + + cy.get(".modal").should("contain.text", "Cleaned Up").should("contain.text", "Success"); + + cy.get(".modal button[data-cy='ok']").click(); + }); +}); diff --git a/cypress/e2e/02-update/updateUser.cy.d.ts b/cypress/e2e/02-update/updateUser.cy.d.ts new file mode 100644 index 00000000..cb0ff5c3 --- /dev/null +++ b/cypress/e2e/02-update/updateUser.cy.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/cypress/e2e/02-update/updateUser.cy.js b/cypress/e2e/02-update/updateUser.cy.js new file mode 100644 index 00000000..6fcda5f5 --- /dev/null +++ b/cypress/e2e/02-update/updateUser.cy.js @@ -0,0 +1,26 @@ +import { testUpdate } from "../../../test/_globals.js"; +import { logout, login } from "../../support/index.js"; +describe("Update User", () => { + before(logout); + after(logout); + it("Logs In Successfully", () => { + login(testUpdate); + }); + describe("Dashboard", () => { + before(() => { + cy.visit("/dashboard"); + }); + it("Has no detectable accessibility issues", () => { + cy.injectAxe(); + cy.checkA11y(); + }); + it("Has no links to admin areas", () => { + cy.get("a[href*='/admin']").should("not.exist"); + }); + }); + it("Redirects to Dashboard when attempting to access admin area", () => { + cy.visit("/admin/cleanup"); + cy.wait(200); + cy.location("pathname").should("equal", "/dashboard"); + }); +}); diff --git a/cypress/e2e/02-update/updateUser.cy.ts b/cypress/e2e/02-update/updateUser.cy.ts new file mode 100644 index 00000000..c0efbd58 --- /dev/null +++ b/cypress/e2e/02-update/updateUser.cy.ts @@ -0,0 +1,34 @@ +import { testUpdate } from "../../../test/_globals.js"; + +import { logout, login } from "../../support/index.js"; + +describe("Update User", () => { + before(logout); + + after(logout); + + it("Logs In Successfully", () => { + login(testUpdate); + }); + + describe("Dashboard", () => { + before(() => { + cy.visit("/dashboard"); + }); + + it("Has no detectable accessibility issues", () => { + cy.injectAxe(); + cy.checkA11y(); + }); + + it("Has no links to admin areas", () => { + cy.get("a[href*='/admin']").should("not.exist"); + }); + }); + + it("Redirects to Dashboard when attempting to access admin area", () => { + cy.visit("/admin/cleanup"); + cy.wait(200); + cy.location("pathname").should("equal", "/dashboard"); + }); +}); diff --git a/cypress/e2e/03-readOnly/readOnlyUser.cy.d.ts b/cypress/e2e/03-readOnly/readOnlyUser.cy.d.ts new file mode 100644 index 00000000..cb0ff5c3 --- /dev/null +++ b/cypress/e2e/03-readOnly/readOnlyUser.cy.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/cypress/e2e/03-readOnly/readOnlyUser.cy.js b/cypress/e2e/03-readOnly/readOnlyUser.cy.js new file mode 100644 index 00000000..e530b4e7 --- /dev/null +++ b/cypress/e2e/03-readOnly/readOnlyUser.cy.js @@ -0,0 +1,50 @@ +import { testView } from "../../../test/_globals.js"; +import { logout, login } from "../../support/index.js"; +describe("Read Only User", () => { + before(logout); + after(logout); + it("Logs In Successfully", () => { + login(testView); + }); + describe("Dashboard", () => { + before(() => { + cy.visit("/dashboard"); + }); + it("Has no detectable accessibility issues", () => { + cy.injectAxe(); + cy.checkA11y(); + }); + it("Has no links to new areas", () => { + cy.get("a[href*='/new']").should("not.exist"); + }); + it("Has no links to admin areas", () => { + cy.get("a[href*='/admin']").should("not.exist"); + }); + }); + it("Has no link to create maps on Map Search", () => { + cy.visit("/maps"); + cy.get("a[href*='/new']").should("not.exist"); + }); + it("Has no link to create lots on Lot Search", () => { + cy.visit("/lots"); + cy.get("a[href*='/new']").should("not.exist"); + }); + it("Has no link to create occupancies on Occupancy Search", () => { + cy.visit("/lotOccupancies"); + cy.get("a[href*='/new']").should("not.exist"); + }); + it("Has no link to create work orders on Work Order Search", () => { + cy.visit("/workOrders"); + cy.get("a[href*='/new']").should("not.exist"); + }); + it("Redirects to Dashboard when attempting to create a work order", () => { + cy.visit("/workOrders/new"); + cy.wait(200); + cy.location("pathname").should("equal", "/dashboard"); + }); + it("Redirects to Dashboard when attempting to alter fees", () => { + cy.visit("/admin/fees"); + cy.wait(200); + cy.location("pathname").should("not.contain", "/admin"); + }); +}); diff --git a/cypress/e2e/03-readOnly/readOnlyUser.cy.ts b/cypress/e2e/03-readOnly/readOnlyUser.cy.ts new file mode 100644 index 00000000..5ed11797 --- /dev/null +++ b/cypress/e2e/03-readOnly/readOnlyUser.cy.ts @@ -0,0 +1,64 @@ +import { testView } from "../../../test/_globals.js"; + +import { logout, login } from "../../support/index.js"; + +describe("Read Only User", () => { + before(logout); + + after(logout); + + it("Logs In Successfully", () => { + login(testView); + }); + + describe("Dashboard", () => { + before(() => { + cy.visit("/dashboard"); + }); + + it("Has no detectable accessibility issues", () => { + cy.injectAxe(); + cy.checkA11y(); + }); + + it("Has no links to new areas", () => { + cy.get("a[href*='/new']").should("not.exist"); + }); + + it("Has no links to admin areas", () => { + cy.get("a[href*='/admin']").should("not.exist"); + }); + }); + + it("Has no link to create maps on Map Search", () => { + cy.visit("/maps"); + cy.get("a[href*='/new']").should("not.exist"); + }); + + it("Has no link to create lots on Lot Search", () => { + cy.visit("/lots"); + cy.get("a[href*='/new']").should("not.exist"); + }); + + it("Has no link to create occupancies on Occupancy Search", () => { + cy.visit("/lotOccupancies"); + cy.get("a[href*='/new']").should("not.exist"); + }); + + it("Has no link to create work orders on Work Order Search", () => { + cy.visit("/workOrders"); + cy.get("a[href*='/new']").should("not.exist"); + }); + + it("Redirects to Dashboard when attempting to create a work order", () => { + cy.visit("/workOrders/new"); + cy.wait(200); + cy.location("pathname").should("equal", "/dashboard"); + }); + + it("Redirects to Dashboard when attempting to alter fees", () => { + cy.visit("/admin/fees"); + cy.wait(200); + cy.location("pathname").should("not.contain", "/admin"); + }); +}); diff --git a/views/admin-cleanup.ejs b/views/admin-cleanup.ejs index e26495e5..a49dc65b 100644 --- a/views/admin-cleanup.ejs +++ b/views/admin-cleanup.ejs @@ -45,7 +45,7 @@

-