Skip to content

Commit

Permalink
Merge branch 'main' into cmdct-3587
Browse files Browse the repository at this point in the history
  • Loading branch information
gmrabian committed May 14, 2024
2 parents 30540aa + 8036127 commit c9558d6
Show file tree
Hide file tree
Showing 40 changed files with 1,409 additions and 5,411 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,10 @@ jobs:
with:
working-directory: tests/cypress
spec: |
tests/e2e/*.spec.js
tests/e2e/**/*.feature
e2e/*.cy.js
e2e/admin/*.cy.js
e2e/mcpar/*.cy.js
e2e/mlr/*.cy.js
browser: chrome
config: baseUrl=${{ needs.deploy.outputs.application_endpoint }}
wait-on: ${{ needs.deploy.outputs.application_endpoint }}
Expand Down Expand Up @@ -256,7 +258,7 @@ jobs:
uses: cypress-io/github-action@v6
with:
working-directory: tests/cypress
spec: tests/accessibility/*.feature
spec: e2e/accessibility/*.cy.js
browser: chrome
config: baseUrl=${{ needs.deploy.outputs.application_endpoint }}
wait-on: ${{ needs.deploy.outputs.application_endpoint }}
Expand Down
2 changes: 1 addition & 1 deletion services/ui-src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@emotion/react": "^11",
"@emotion/styled": "^11",
"@hookform/resolvers": "^2.8.4",
"aws-amplify": "^4.3.4",
"aws-amplify": "^5.3.4",
"bootstrap": "^5.1.3",
"date-fns": "^2.26.0",
"date-fns-tz": "^1.2.2",
Expand Down
1,797 changes: 844 additions & 953 deletions services/ui-src/yarn.lock

Large diffs are not rendered by default.

17 changes: 2 additions & 15 deletions tests/cypress/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,11 @@
`cypress.config.js` may use any of [these](https://docs.cypress.io/guides/references/configuration#Global) config options.

## Writing tests

There are two primary syntaxes for writing tests for Cypress.

- JavaScript
- uses extension `*.spec.js` located in `tests` directory
- Gherkin (Cucumber)
- uses extension `*.feature` located in `tests` directory
- requires suitable JavaScript step definitions be created
- General use steps go in `support/step_definitions` directory
- Feature specific steps go in same directory as your feature, with filename of `<feature>.stepdef.js`
- eg `tests\e2e\admin\admin.feature` and `tests\e2e\admin\admin.stepdef.js`
- VS Code plugins available, [Cucumber (Gherkin) Full Support](https://marketplace.visualstudio.com/items?itemName=alexkrechik.cucumberautocomplete) recommended
- uses extension `*.cy.js` located in `e2e` directory

Relevant Documentation
- [Cypress Documentation](https://docs.cypress.io/guides/core-concepts/writing-and-organizing-tests#What-you-ll-learn)
- [Cucumber Preprocessor Documentation](https://github.com/badeball/cypress-cucumber-preprocessor/blob/master/docs/readme.md)
- [Gherkin Documentation](https://cucumber.io/docs/gherkin/reference/)
- [Step Definitions Documentation](https://cucumber.io/docs/cucumber/step-definitions/?lang=javascript)
- [Cypress Documentation](https://docs.cypress.io/)

## Running tests

Expand Down
10 changes: 2 additions & 8 deletions tests/cypress/cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
const { defineConfig } = require("cypress");
const preprocessor = require("@badeball/cypress-cucumber-preprocessor");
const browserify = require("@badeball/cypress-cucumber-preprocessor/browserify");
const { pa11y, prepareAudit } = require("@cypress-audit/pa11y");

module.exports = defineConfig({
experimentalStudio: true,
redirectionLimit: 20,
retries: 1,
retries: 2,
watchForFileChanges: true,
fixturesFolder: "fixtures",
screenshotsFolder: "screenshots",
Expand All @@ -20,13 +18,9 @@ module.exports = defineConfig({
e2e: {
baseUrl: "http://127.0.0.1:3000/",
testIsolation: false,
specPattern: ["tests/**/*.spec.js", "tests/**/*.feature"],
specPattern: ["e2e/**/*.cy.js"],
supportFile: "support/index.js",
// eslint-disable-next-line @typescript-eslint/no-unused-vars
async setupNodeEvents(on, config) {
await preprocessor.addCucumberPreprocessorPlugin(on, config);
on("file:preprocessor", browserify.default(config));

on("task", {
log(message) {
// eslint-disable-next-line no-console
Expand Down
7 changes: 7 additions & 0 deletions tests/cypress/e2e/accessibility/admin.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
describe("Admin Page - Accessibility Test", () => {
it("is accessible on all device types for admin user", () => {
cy.authenticate("adminUser");
cy.visit("/admin");
cy.testPageAccessibility();
});
});
10 changes: 10 additions & 0 deletions tests/cypress/e2e/accessibility/help.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
describe("Help Page - Accessibility Test", () => {
it("is accessible on all device types for state user", () => {
cy.authenticate("stateUser");

cy.visit("/help");
cy.location("pathname").should("match", /help/);

cy.testPageAccessibility();
});
});
18 changes: 18 additions & 0 deletions tests/cypress/e2e/accessibility/home.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
describe("Home Page - Accessibility Test", () => {
it("Is accessible when not logged in", () => {
cy.visit("/");
cy.testPageAccessibility();
});

it("is accessible on all device types for admin user", () => {
cy.authenticate("adminUser");

cy.testPageAccessibility();
});

it("is accessible on all device types for state user", () => {
cy.authenticate("stateUser");

cy.testPageAccessibility();
});
});
19 changes: 19 additions & 0 deletions tests/cypress/e2e/accessibility/profile.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
describe("Profile Page - Accessibility Test", () => {
it("is accessible on all device types for admin user", () => {
cy.authenticate("adminUser");

cy.visit("/profile");
cy.location("pathname").should("match", /profile/);

cy.testPageAccessibility();
});

it("is accessible on all device types for state user", () => {
cy.authenticate("stateUser");

cy.visit("/profile");
cy.location("pathname").should("match", /profile/);

cy.testPageAccessibility();
});
});
64 changes: 64 additions & 0 deletions tests/cypress/e2e/admin/admin.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { fillFormField } from "../../support";

const bannerInputArray = [
{ name: "bannerTitle", type: "text", value: "test-title" },
{ name: "bannerDescription", type: "text", value: "test-description" },
{ name: "bannerStartDate", type: "text", value: "07/14/2022" },
{ name: "bannerEndDate", type: "text", value: "07/14/2026" },
];

describe("Admin Page E2E Testing", () => {
it("Create a Banner and then delete it", () => {
cy.authenticate("adminUser");

// go to banner editor
const menuButton = '[aria-label="my account"';
const menuOptionManageAccount =
'[data-testid="header-menu-option-manage-account"]';
const adminButton = 'button:contains("Banner Editor")';
cy.get(menuButton).click();
cy.get(menuOptionManageAccount).click();
cy.get(adminButton).click();

// fill out banner form
fillFormField(bannerInputArray);
const submitButton = "[type='submit']";
cy.get(submitButton).click();

// check active banner
cy.contains("Status: Active", { matchCase: true }).should("be.visible");
cy.get('[role="alert"]').contains("test-title");
cy.get('[role="alert"]').contains("test-description");
cy.contains(`Start Date: 07/14/2022`, { matchCase: true }).should(
"be.visible"
);
cy.contains(`End Date: 07/14/2026`, { matchCase: true }).should(
"be.visible"
);

checkForErrors();

// delete banner
const deleteButton = "Delete Current Banner";
cy.contains(deleteButton).click();

// verify banner is gone
const noCurrentBannerMessage = "There is no current banner";
cy.contains(noCurrentBannerMessage).should("be.visible");

checkForErrors();
});
});

function checkForErrors() {
const bannerFetchErrorMessage =
"Banner could not be fetched. Please contact support.";
const bannerWriteErrorMessage =
"Current banner could not be replaced. Please contact support.";
const bannerDeleteErrorMessage =
"Current banner could not be deleted. Please contact support.";

cy.contains(bannerWriteErrorMessage).should("not.exist");
cy.contains(bannerFetchErrorMessage).should("not.exist");
cy.contains(bannerDeleteErrorMessage).should("not.exist");
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ beforeEach(() => {
cy.authenticate("stateUser");
});

afterEach(() => {
cy.navigateToHomePage();
});

describe("Footer integration tests", () => {
it("Footer help link navigates to /help", () => {
cy.contains(helpLinkText).click();
Expand Down
43 changes: 43 additions & 0 deletions tests/cypress/e2e/header.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// element selectors
const accessibilityStatementLinkText = "Accessibility Statement";

beforeEach(() => {
cy.authenticate("stateUser");
});

describe("Footer integration tests", () => {
it("Footer help link navigates to /help", () => {
cy.get("[aria-label='Get Help']").click();
cy.url().should("include", "/help");

cy.get("[alt='MCR logo']").click();
cy.url().should("include", "/");

cy.get("[aria-label='my account']").click();
cy.url().should("include", "/");
cy.get("[data-testid='header-menu-options-list']").should("be.visible");
cy.get("[data-testid='header-menu-option-manage-account']").should(
"be.visible"
);
cy.get("[data-testid='header-menu-option-log-out']").should("be.visible");

cy.get("[data-testid='header-menu-option-manage-account']").click();
cy.url().should("include", "/profile");

cy.get("[aria-label='my account']").click();
cy.get("[data-testid='header-menu-option-log-out']").click();
cy.wait(3000);
cy.visit("/");
cy.get("[data-testid='cognito-login-button']").should("be.visible");
});

it("Footer accessibility statement link navigates to the right external URL", () => {
cy.get(
'a[href="https://www.cms.gov/About-CMS/Agency-Information/Aboutwebsite/CMSNondiscriminationNotice"]'
).contains(accessibilityStatementLinkText);

cy.contains(accessibilityStatementLinkText).then((link) => {
cy.request(link.prop("href")).its("status").should("eq", 200);
});
});
});
File renamed without changes.
105 changes: 105 additions & 0 deletions tests/cypress/e2e/mcpar/dashboard.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import { fillFormField, verifyElementsArePrefilled } from "../../support";

const currentDate = new Date().toISOString();

const newReportInputArray = [
{
name: "programName",
type: "text",
value: `automated test - ${currentDate}`,
},
{ name: "reportingPeriodStartDate", type: "text", value: "07/14/2023" },
{ name: "reportingPeriodEndDate", type: "text", value: "07/14/2026" },
{ name: "combinedData", type: "singleCheckbox", value: "true" },
{ name: "programIsPCCM", type: "radio", value: "No" },
];

describe("MCPAR Dashboard Page - Program Creation/Editing/Archiving", () => {
it("State users can create and edit reports", () => {
cy.authenticate("stateUser");

// go to mcpar dashboard; two clicks to get through instruction page
cy.get('button:contains("Enter MCPAR online")').click();
cy.get('button:contains("Enter MCPAR online")').click();

// create a new mcpar report
cy.get('button:contains("Add / copy a MCPAR")').click();

fillFormField(newReportInputArray);
cy.get("button[type=submit]").contains("Save").click();

cy.wait(2000);

cy.contains(`automated test - ${currentDate}`, {
matchCase: true,
}).should("be.visible");

// edit the report
cy.get('[alt="Edit Report"]').last().click();

cy.contains(`automated test - ${currentDate}`, {
matchCase: true,
}).should("be.visible");
verifyElementsArePrefilled(newReportInputArray);

// edit report name
cy.get(`[name='programName']`)
.clear()
.type(`Edited Program - ${currentDate}`);
cy.get("button[type=submit]").contains("Save").click();

cy.contains(`Edited Program - ${currentDate}`, {
matchCase: true,
}).should("be.visible");
});
});

const adminSelectorArray = [
{ name: "state", type: "dropdown", value: "District of Columbia" },
{
name: "report",
type: "radio",
value: "Managed Care Program Annual Report (MCPAR)",
},
];

describe("Admin Archiving", () => {
it("Admin users can archive/unarchive reports", () => {
cy.authenticate("adminUser");

fillFormField(adminSelectorArray);
cy.contains("Go to Report Dashboard").click();

// cannot create reports
cy.contains("Add / copy a MCPAR").should("not.exist");

cy.contains(`Edited Program - ${currentDate}`, {
matchCase: true,
}).should("be.visible");

cy.get('button:contains("Archive")').last().click();
cy.contains("Unarchive").should("be.visible");

cy.contains("Unarchive").last().click();
cy.contains("Archive").should("be.visible");

cy.contains("Archive").last().click();
cy.contains("Unarchive").should("be.visible");
});
});

describe("State users can't see archived programs", () => {
it("State users can't see archived programs", () => {
cy.authenticate("stateUser");

// go to mcpar dashboard; two clicks to get through instruction page
cy.get('button:contains("Enter MCPAR online")').click();
cy.get('button:contains("Enter MCPAR online")').click();

cy.contains(`Edited Program - ${currentDate}`, {
matchCase: true,
}).should("not.exist");

cy.contains("button", { "Edit Report": String }).should("not.exist");
});
});
Loading

0 comments on commit c9558d6

Please sign in to comment.