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

Convert Auth0 tests to use experimentalSessionAndOrigin #1270

Merged
merged 6 commits into from
Nov 28, 2022
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Rename cy.loginByAuth0Api to cy.loginToAuth0
debrisapron committed Nov 22, 2022
commit f5bbe23467913cfa0533417fbd31616945fe8b3f
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -175,7 +175,7 @@ Support for 3rd party authentication is available in the application to demonstr

### Auth0

The [Auth0](https://auth0.com/) tests have been rewritten to take advantage of our new (currently experimental) [`cy.session`](https://docs.cypress.io/api/commands/session) and [`cy.origin`](https://docs.cypress.io/api/commands/origin) commands.
The [Auth0](https://auth0.com/) tests have been rewritten to take advantage of our (currently experimental) [`cy.session`](https://docs.cypress.io/api/commands/session) and [`cy.origin`](https://docs.cypress.io/api/commands/origin) commands.

Prerequisites include an Auth0 account and a Tenant configured for use with a SPA. Environment variables from Auth0 are to be placed in the [.env](./.env). For more details see [Auth0 Application Setup](http://on.cypress.io/auth0#Auth0-Application-Setup) and [Setting Auth0 app credentials in Cypress](http://on.cypress.io/auth0#Setting-Auth0-app-credentials-in-Cypress).

4 changes: 2 additions & 2 deletions cypress/global.d.ts
Original file line number Diff line number Diff line change
@@ -126,9 +126,9 @@ declare namespace Cypress {
logoutByXstate(): Chainable<string>;

/**
* Logs in via Auth0 API
* Logs in via Auth0 login page
*/
loginByAuth0Api(username: string, password: string): Chainable<any>;
loginToAuth0(username: string, password: string): Chainable<any>;

/**
* Switch current user by logging out current user and logging as user with specified username
2 changes: 1 addition & 1 deletion cypress/support/auth-provider-commands/auth0.ts
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@

// Note: this function leaves you on a blank page, so you must call cy.visit()
// afterwards, before continuing with your test.
Cypress.Commands.add("loginByAuth0Api", (username: string, password: string) => {
Cypress.Commands.add("loginToAuth0", (username: string, password: string) => {
const log = Cypress.log({
displayName: "AUTH0 LOGIN",
message: [`🔐 Authenticating | ${username}`],
5 changes: 1 addition & 4 deletions cypress/tests/ui-auth-providers/auth0.spec.ts
Original file line number Diff line number Diff line change
@@ -4,10 +4,7 @@ if (Cypress.env("auth0_username")) {
describe("Auth0", function () {
beforeEach(function () {
cy.task("db:seed");

cy.intercept("POST", "/graphql").as("createBankAccount");

cy.loginByAuth0Api(Cypress.env("auth0_username"), Cypress.env("auth0_password"));
cy.loginToAuth0(Cypress.env("auth0_username"), Cypress.env("auth0_password"));
cy.visit("/");
});