Skip to content

Commit

Permalink
test year end
Browse files Browse the repository at this point in the history
  • Loading branch information
dangowans committed Jun 17, 2022
1 parent 4327ea4 commit bfa0d9f
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 3 deletions.
1 change: 1 addition & 0 deletions cypress/e2e/01-admin/yearEnd.cy.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
46 changes: 46 additions & 0 deletions cypress/e2e/01-admin/yearEnd.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { testAdmin } from "../../../test/_globals.js";
import { logout, login, ajaxDelayMillis } from "../../support/index.js";
describe("Admin - Year-End Process", function () {
before(function () {
logout();
login(testAdmin);
});
after(logout);
beforeEach("Loads page", function () {
cy.visit("/admin/yearEnd");
cy.location("pathname").should("equal", "/admin/yearEnd");
});
it("Has no detectable accessibility issues", function () {
cy.injectAxe();
cy.checkA11y();
});
it("Refreshes the database", function () {
if (new Date().getMonth() !== 1 - 1) {
cy.get("button[data-cy='proceed']").click();
}
cy.get("a[data-cy='backup']").click();
cy.get(".modal")
.should("be.visible")
.should("contain.text", "Backup");
cy.get(".modal button[data-cy='ok']")
.click();
cy.wait(ajaxDelayMillis);
cy.get(".modal")
.should("contain.text", "Backed Up")
.should("contain.text", "Success");
cy.get(".modal button[data-cy='ok']")
.click();
cy.get("a[data-cy='refresh']").click();
cy.get(".modal")
.should("be.visible")
.should("contain.text", "Refresh");
cy.get(".modal button[data-cy='ok']")
.click();
cy.wait(ajaxDelayMillis);
cy.get(".modal")
.should("contain.text", "Refresh")
.should("contain.text", "Success");
cy.get(".modal button[data-cy='ok']")
.click();
});
});
75 changes: 75 additions & 0 deletions cypress/e2e/01-admin/yearEnd.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/* 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 - Year-End Process", () => {

before(() => {
logout();
login(testAdmin)
});

after(logout);

beforeEach("Loads page", () => {
cy.visit("/admin/yearEnd");
cy.location("pathname").should("equal", "/admin/yearEnd");
});

it("Has no detectable accessibility issues", () => {
cy.injectAxe();
cy.checkA11y();
});

it("Refreshes the database", () => {

// Proceed in not January

if (new Date().getMonth() !== 1 - 1) {
cy.get("button[data-cy='proceed']").click();
}

// Backup

cy.get("a[data-cy='backup']").click();

cy.get(".modal")
.should("be.visible")
.should("contain.text", "Backup");

cy.get(".modal button[data-cy='ok']")
.click();

cy.wait(ajaxDelayMillis);

cy.get(".modal")
.should("contain.text", "Backed Up")
.should("contain.text", "Success");

cy.get(".modal button[data-cy='ok']")
.click();

// Refresh

cy.get("a[data-cy='refresh']").click();

cy.get(".modal")
.should("be.visible")
.should("contain.text", "Refresh");

cy.get(".modal button[data-cy='ok']")
.click();

cy.wait(ajaxDelayMillis);

cy.get(".modal")
.should("contain.text", "Refresh")
.should("contain.text", "Success");

cy.get(".modal button[data-cy='ok']")
.click();
});
});
6 changes: 3 additions & 3 deletions views/admin-yearEnd.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
Are you sure you want to proceed?
</p>
<p class="has-text-right">
<button class="button is-warning" id="yearEnd--showProcess" type="button">
<button class="button is-warning" id="yearEnd--showProcess" data-cy="proceed" type="button">
Proceed to Year-End Process
</button>
</p>
Expand Down Expand Up @@ -92,7 +92,7 @@
</div>
<div class="media-content">
<h3 class="title is-4 is-marginless">
<a href="#" id="yearEnd--backupDatabase">Backup Database</a>
<a href="#" id="yearEnd--backupDatabase" data-cy="backup">Backup Database</a>
</h3>
<p>Take a snapshot of the database as it is right now, and archive it on the server.</p>
</div>
Expand Down Expand Up @@ -142,7 +142,7 @@
</div>
<div class="media-content">
<h3 class="title is-4 is-marginless">
<a class="has-text-danger" href="#" id="yearEnd--refreshDatabase">Refresh Database</a>
<a class="has-text-danger" href="#" id="yearEnd--refreshDatabase" data-cy="refresh">Refresh Database</a>
</h3>
<p>
This process cannot be undone without restoring from backups.
Expand Down

0 comments on commit bfa0d9f

Please sign in to comment.