Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MDCT-2555] Stabilize carts e2e smoke test #139420

Merged
merged 6 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions tests/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ before(() => {

const emailForCognito = "//input[@name='email']";
const passwordForCognito = "//input[@name='password']";
const uncertifyButton = "[data-testid='uncertifyButton']";
const logoutButton = "[data-testid='header-menu-option-log-out']";
const headerDropdownMenu = "[data-testid='headerDropDownMenu']";

const stateUser = {
email: Cypress.env("STATE_USER_EMAIL"),
Expand All @@ -27,6 +30,7 @@ const reviewer = {
};

Cypress.Commands.add("authenticate", (userType, userCredentials) => {
cy.reload();
let credentials = {};
if (userType && userCredentials) {
console.warn(
Expand Down Expand Up @@ -56,6 +60,40 @@ Cypress.Commands.add("authenticate", (userType, userCredentials) => {
cy.get('[data-cy="login-with-cognito-button"]').click();
});

Cypress.Commands.add("logout", () => {
cy.wait(3000);
cy.get(headerDropdownMenu).click();
cy.get(logoutButton).click();
cy.wait(3000); // let logout settle
});

Cypress.Commands.add("ensureAvailableReport", () => {
// login as admin
cy.visit("/");
cy.authenticate("adminUser");

/*
* check if there is a certified program, if so, uncertify
* so state user will always have an editable program
*/
// Scope to test user's state
cy.get(".dropdown-heading").first().click();
cy.contains("Alabama").click();
cy.get("body").click(0, 0);
cy.get(".filter-button").contains("Filter").click();
cy.wait(3000);

cy.get("body").then(($body) => {
if ($body.find(uncertifyButton).length > 0) {
cy.get(uncertifyButton).first().click();
cy.get("button").contains("Yes, Uncertify").click();
}
return;
});

cy.logout();
});

// Define at the top of the spec file or just import it
function terminalLog(violations) {
cy.task(
Expand Down
55 changes: 15 additions & 40 deletions tests/cypress/tests/integration/submitAndUncertify.spec.js
Original file line number Diff line number Diff line change
@@ -1,68 +1,43 @@
// element selectors
const logoutButton = "[data-testid='header-menu-option-log-out']";
const headerDropdownMenu = "[data-testid='headerDropDownMenu']";
const actionButton = "[data-testid='report-action-button']";
const certifySubmitButton = "[data-testid='certifySubmit']";
const uncertifyButton = "[data-testid='uncertifyButton']";

describe("CARTS Submit and Uncertify Integration Tests", () => {
before(() => {
cy.visit("/");

// login as admin
cy.authenticate("adminUser");
/*
* check if there is a certified program, if so, uncertify
* so state user will always have an editable program
*/
cy.wait(15000);

cy.get("body").then(($body) => {
if ($body.text().includes("Uncertify")) {
cy.wait(3000);
cy.get(uncertifyButton).first().click();
cy.get("button").contains("Yes, Uncertify").click();
}
return;
});

cy.wait(3000);
cy.get(headerDropdownMenu).click();
cy.get(logoutButton).click();
});

it("Should submit form as a State User and uncertify as a Reviewer", () => {
cy.ensureAvailableReport(); // Needs to happen each iteration of the test

// log in as State User
cy.authenticate("stateUser");

// certify and submit report
cy.get(actionButton, { timeout: 30000 }).contains("Edit").click();
cy.wait(3000);
cy.contains("Certify and Submit").click();
cy.wait(3000);

cy.get(certifySubmitButton).click();
cy.get("button").contains("Confirm Certify and Submit").click();
cy.get("button").contains("Return Home").click();

// log out
cy.get(headerDropdownMenu).click();
cy.get(logoutButton).click();
cy.logout();

// log in as CMS Admin (user who can uncertify)
cy.authenticate("adminUser");

// uncertify report
// uncertify report - Scope to test user's state
cy.get(".dropdown-heading").first().click();
cy.contains("Alabama").click();
cy.get("body").click(0, 0);
cy.get(".filter-button").contains("Filter").click();
cy.wait(3000);

cy.get(uncertifyButton).first().contains("Uncertify").click();
cy.get("button").contains("Yes, Uncertify").click();

cy.wait(3000);

// log back out
cy.get(headerDropdownMenu).click();
cy.get(logoutButton).click();
cy.logout();

// log back in as State User
// log back in as State User - the report should be "In Progress" again
cy.authenticate("stateUser");

// the report should be "In Progress" again
cy.get(actionButton).contains("Edit").should("be.visible");
});
});
Loading