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

Cypress Version Upgrade pt. II #139419

Closed
wants to merge 3 commits into from
Closed
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
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Run Cypress Tests
uses: cypress-io/github-action@v3.0.3
uses: cypress-io/github-action@v4.1.0
with:
working-directory: tests/cypress
spec: tests/integration/*.spec.js
Expand Down Expand Up @@ -143,7 +143,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Check Project A11y
uses: cypress-io/github-action@v3.0.3
uses: cypress-io/github-action@v4.1.0
with:
working-directory: tests/cypress
spec: tests/a11y/*.spec.js
Expand Down
23 changes: 23 additions & 0 deletions tests/cypress/cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const { defineConfig } = require("cypress");

module.exports = defineConfig({
experimentalStudio: true,
redirectionLimit: 20,
retries: 2,
watchForFileChanges: true,
fixturesFolder: "fixtures",
screenshotsFolder: "screenshots",
videosFolder: "videos",
downloadsFolder: "downloads",
defaultCommandTimeout: 20000,
types: ["cypress", "cypress-axe"],
e2e: {
setupNodeEvents(on, config) {
return require("./plugins/index.js")(on, config);
},
baseUrl: "http://localhost:3000/",
specPattern: ["tests/**/*.feature", "tests/**/*.spec.js"],
excludeSpecPattern: "filterReports.spec.js",
supportFile: "support/index.js",
},
});
18 changes: 0 additions & 18 deletions tests/cypress/cypress.json

This file was deleted.

2 changes: 1 addition & 1 deletion tests/cypress/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@cypress-audit/pa11y": "^1.2.0",
"axe-core": "^4.4.1",
"concurrently": "^6.2.1",
"cypress": "^9.4.1",
"cypress": "12.17.2",
"cypress-axe": "^0.14.0",
"cypress-cucumber-preprocessor": "^4.2.0",
"cypress-file-upload": "^5.0.8",
Expand Down
7 changes: 2 additions & 5 deletions tests/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ before(() => {
cy.visit("/", { timeout: 60000 * 5 });
});

const emailForCognito = "//input[@name='email']";
const passwordForCognito = "//input[@name='password']";

const stateUser = {
email: Cypress.env("STATE_USER_EMAIL"),
password: Cypress.env("STATE_USER_PASSWORD"),
Expand Down Expand Up @@ -51,8 +48,8 @@ Cypress.Commands.add("authenticate", (userType, userCredentials) => {
} else {
throw new Error("Must specify either userType or userCredentials.");
}
cy.xpath(emailForCognito).type(credentials.email);
cy.xpath(passwordForCognito).type(credentials.password);
cy.get('input[name="email"]').type(credentials.email);
cy.get('input[name="password"]').type(credentials.password);
cy.get('[data-cy="login-with-cognito-button"]').click();
});

Expand Down
33 changes: 6 additions & 27 deletions tests/cypress/support/index.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,11 @@
/*
* ***********************************************************
* This example support/index.js is processed and
* loaded automatically before your test files.
*
* This is a great place to put global configuration and
* behavior that modifies Cypress.
*
* You can change the location of this file or turn off
* automatically serving support files with the
* 'supportFile' configuration option.
*
* You can read more here:
* https://on.cypress.io/configuration
* ***********************************************************
*/
{
require("cypress-xpath");
}
// Import commands.js using ES2015 syntax:
import "./commands";

/*
* Alternatively you can use CommonJS syntax:
* require('./commands')
*/

/*
* This is a Cypress plugin that allows you to run axe (https://dequeuniversity.com/rules/axe/about) on
* your tests.
*/
import "cypress-axe";

// eslint-disable-next-line no-unused-vars
Cypress.on("uncaught:exception", (err, runnable) => {
// returning false here prevents Cypress from failing the test
return false;
});
21 changes: 10 additions & 11 deletions tests/cypress/support/pages/Homepage.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
const appLogo = "//a[contains(text(), 'CARTS')]";
const appLogo = "a[contains(text(), 'CARTS')]";
const headerAppLogo = "a[contains(text(), 'CARTS')]";
const headerLoginButton = "a#loginButton";
const footerAddress = '(//div[@class="footer-wrapper"]/div)[2]';
const footerEmail = ".footer-email";
const footerHhsLogo = "img[alt='Department of Health and Human Services logo']";
const footerMdctLogo = "//img[@alt='Mdct logo']";
const footerMedicaidLogo = "//img[@alt='Medicaid.gov logo']";
const footerMdctLogo = "img[@alt='Mdct logo']";
const footerMedicaidLogo = "img[@alt='Medicaid.gov logo']";
const medicaidLogo = "img[alt='Medicaid.gov logo']";
const footerSentence = '(//div[@class="footer-fed-gov-text"])[1]';
const footerSentence = '(div[@class="footer-fed-gov-text"])[1]';

export class Homepage {
launch() {
cy.visit("/");
}

verifyLogos() {
cy.xpath(appLogo).should("be.visible");
cy.xpath(footerMdctLogo).should("be.visible");
cy.xpath(footerMedicaidLogo).should("be.visible");
cy.get(appLogo).should("be.visible");
cy.get(footerMdctLogo).should("be.visible");
cy.get(footerMedicaidLogo).should("be.visible");
}

validateCoreSetReportingIcon() {
//cy.wait(3000);
cy.get(headerAppLogo).should("be.visible");
}

validatePageBanner() {
cy.xpath(headerAppLogo).should("be.visible");
cy.get(headerAppLogo).should("be.visible");
}

validateLoginButton() {
Expand All @@ -38,7 +37,7 @@ export class Homepage {
}

validateSupportSenence() {
cy.xpath(footerSentence).should("be.visible");
cy.get(footerSentence).should("be.visible");
}

validateMedicaidLogo() {
Expand All @@ -54,7 +53,7 @@ export class Homepage {
}

validateAddress() {
cy.xpath(footerAddress).contains(
cy.get(footerAddress).contains(
"7500 Security Boulevard Baltimore, MD 21244"
);
}
Expand Down
22 changes: 11 additions & 11 deletions tests/cypress/support/pages/LoginPage.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
const cognitoUserEmail = "//input[@name='email']";
const cognitoUserPassword = "//input[@name='password']";
const cognitoLoginButton = "//button[@data-cy='login-with-cognito-button']";
const cognitoUserEmail = "input[@name='email']";
const cognitoUserPassword = "input[@name='password']";
const cognitoLoginButton = "button[@data-cy='login-with-cognito-button']";

export class LoginPage {
enterEmailwithCognitoLogin() {
cy.xpath(cognitoUserEmail).type("[email protected]");
cy.get(cognitoUserEmail).type("[email protected]");
}

enterPasswordwithCognitoLogin() {
cy.xpath(cognitoUserPassword).type("p@55W0rd!");
cy.get(cognitoUserPassword).type("p@55W0rd!");
}

stateCognitoLogin() {
cy.xpath(cognitoUserEmail).type("[email protected]");
cy.xpath(cognitoUserPassword).type("p@55W0rd!");
cy.xpath(cognitoLoginButton).click();
cy.get(cognitoUserEmail).type("[email protected]");
cy.get(cognitoUserPassword).type("p@55W0rd!");
cy.get(cognitoLoginButton).click();
}

approverCognitoLogin() {
cy.xpath(cognitoUserEmail).type("[email protected]");
cy.xpath(cognitoUserPassword).type("p@55W0rd!");
cy.xpath(cognitoLoginButton).click();
cy.get(cognitoUserEmail).type("[email protected]");
cy.get(cognitoUserPassword).type("p@55W0rd!");
cy.get(cognitoLoginButton).click();
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/cypress/tests/integration/filterReports.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe("Check Report Filtering as CMS Reviewer and Help Desk User", () => {
before(() => {
beforeEach(() => {
cy.visit("/");
cy.authenticate("adminUser");
});
Expand Down
2 changes: 1 addition & 1 deletion tests/cypress/tests/integration/login.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const logoutButton = "[data-testid='header-menu-option-log-out']";
const headerDropdownMenu = "[data-testid='headerDropDownMenu']";

describe("CARTS Login Integration Tests", () => {
before(() => {
beforeEach(() => {
cy.visit("/");
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const certifySubmitButton = "[data-testid='certifySubmit']";
const uncertifyButton = "[data-testid='uncertifyButton']";

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

// login as admin
Expand Down
Loading
Loading