Skip to content

Commit

Permalink
Upgrade to Cypress 11.2
Browse files Browse the repository at this point in the history
debrisapron committed Nov 23, 2022
1 parent d5ebab4 commit a1637f6
Showing 6 changed files with 29 additions and 28 deletions.
3 changes: 0 additions & 3 deletions .env
Original file line number Diff line number Diff line change
@@ -20,13 +20,10 @@ REACT_APP_BACKEND_PORT=3001
# Auth0 Configuration to be added to .env when running "yarn dev:auth0"
#AUTH0_USERNAME="username@domain.com"
#AUTH0_PASSWORD="s3cret1234$"
#AUTH0_CLIENT_SECRET="your-auth0-client-secret"
#REACT_APP_AUTH0_DOMAIN="your-auth0-domain.auth0.com"
#REACT_APP_AUTH0_CLIENTID="1234567890"
#REACT_APP_AUTH0_AUDIENCE="https://your-auth0-domain.auth0.com/api/v2/"
#REACT_APP_AUTH0_SCOPE="openid email profile"
#AUTH0_MGMT_API_TOKEN="YOUR-MANAGEMENT-API-TOKEN"


# Okta Configuration to be added to .env when running "yarn dev:okta"
#OKTA_USERNAME="username@domain.com"
1 change: 1 addition & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -30,6 +30,7 @@ module.exports = defineConfig({
// Auth0
auth0_username: process.env.AUTH0_USERNAME,
auth0_password: process.env.AUTH0_PASSWORD,
auth0_domain: process.env.REACT_APP_AUTH0_DOMAIN,

// Okta
okta_username: process.env.OKTA_USERNAME,
39 changes: 20 additions & 19 deletions cypress/support/auth-provider-commands/auth0.ts
Original file line number Diff line number Diff line change
@@ -13,28 +13,29 @@ Cypress.Commands.add("loginToAuth0", (username: string, password: string) => {
log.snapshot("before");

const args = { username, password };
cy.session(args, () => {
// App landing page redirects to Auth0.
cy.visit("/");
cy.session(
args,
() => {
// App landing page redirects to Auth0.
cy.visit("/");

// Login on Auth0.
cy.origin("dev-ufts63sf.us.auth0.com", { args }, ({ username, password }) => {
cy.get("input#username").type(username);
cy.get("input#password").type(password);
cy.contains("button[value=default]", "Continue").click();
});
// Auth0 redirects back to RWA.
// Login on Auth0.
cy.origin(Cypress.env("auth0_domain"), { args }, ({ username, password }) => {
cy.get("input#username").type(username);
cy.get("input#password").type(password);
cy.contains("button[value=default]", "Continue").click();
});

// Wait for RWA to save auth token to localstorage before saving session.
cy.url().should((url) => {
expect(url).to.contain(Cypress.config("baseUrl")); // <-- We're on baseUrl here
expect(localStorage.getItem("authAccessToken")).to.exist;
});
}, {
validate: () => {
cy.url().should("contain", Cypress.config("baseUrl")); // <-- This fails because we're on blank now
// Ensure Auth0 has redirected us back to the RWA.
cy.url().should("equal", "http://localhost:3000/");
},
{
validate: () => {
// Validate presence of access token in localStorage.
cy.wrap(localStorage).invoke("getItem", "authAccessToken").should("exist");
},
}
});
);

log.snapshot("after");
log.end();
4 changes: 3 additions & 1 deletion cypress/tests/ui-auth-providers/auth0.spec.ts
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ if (Cypress.env("auth0_username")) {
describe("Auth0", function () {
beforeEach(function () {
cy.task("db:seed");
// cy.intercept("POST", "/graphql").as("createBankAccount");
cy.intercept("POST", "/graphql").as("createBankAccount");
cy.loginToAuth0(Cypress.env("auth0_username"), Cypress.env("auth0_password"));
cy.visit("/");
});
@@ -38,6 +38,8 @@ if (Cypress.env("auth0_username")) {
cy.location("pathname").should("eq", "/");
});

// This test should pass without needing to go through the login flow again,
// due to the session data being cached by cy.loginToAuth0.
it("shows onboarding", function () {
cy.contains("Get Started").should("be.visible");
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -92,7 +92,7 @@
"concurrently": "7.1.0",
"cors": "2.8.5",
"cross-env": "7.0.3",
"cypress": "^11.1.0",
"cypress": "^11.2.0",
"dotenv": "16.0.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-cypress": "2.12.1",
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
@@ -7456,10 +7456,10 @@ cyclist@^1.0.1:
resolved "https://registry.yarnpkg.com/cyclist/-/cyclist-1.0.1.tgz#596e9698fd0c80e12038c2b82d6eb1b35b6224d9"
integrity sha1-WW6WmP0MgOEgOMK4LW6xs1tiJNk=

cypress@^11.1.0:
version "11.1.0"
resolved "https://registry.yarnpkg.com/cypress/-/cypress-11.1.0.tgz#b8f16495a8a5d8f9a7dd3374ae7b2cef45e9c779"
integrity sha512-kzizbG9s3p3ahWqxUwG/21NqLWEGtScMevMyUPeYlcmMX9RzVxWM18MkA3B4Cb3jKx72hSyIE2mHgHymfCM1bg==
cypress@^11.2.0:
version "11.2.0"
resolved "https://registry.yarnpkg.com/cypress/-/cypress-11.2.0.tgz#63edef8c387b687066c5493f6f0ad7b9ced4b2b7"
integrity sha512-u61UGwtu7lpsNWLUma/FKNOsrjcI6wleNmda/TyKHe0dOBcVjbCPlp1N6uwFZ0doXev7f/91YDpU9bqDCFeBLA==
dependencies:
"@cypress/request" "^2.88.10"
"@cypress/xvfb" "^1.2.4"

0 comments on commit a1637f6

Please sign in to comment.