Skip to content

Commit

Permalink
Fix failing cypress check:
Browse files Browse the repository at this point in the history
* Firebase auth isn't (and can't conveniently be) sandboxed during tests
* Update e2e test data 'saul' to also include 'password'
* Use the aformentioned password in all tests signing saul in/up so as to not clash
  • Loading branch information
ikusteu committed Jul 8, 2023
1 parent 07b5def commit 03daf8f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
3 changes: 2 additions & 1 deletion packages/e2e/__testData__/customers.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"covidCertificateSuspended": true,
"categories": ["competitive"],
"secretKey": "123445",
"subscriptionNumber": ""
"subscriptionNumber": "",
"password": "sauls_pass_123"
},

"walt": {
Expand Down
4 changes: 2 additions & 2 deletions packages/e2e/integration/athlete_self_register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import i18n, {
Alerts,
ValidationMessage,
} from "@eisbuk/translations";
import { CustomerFull, OrganizationData } from "@eisbuk/shared";
import { OrganizationData } from "@eisbuk/shared";

import { PrivateRoutes } from "../temp";

Expand All @@ -21,7 +21,7 @@ import {
import { organization as organizationData } from "../__testData__/organization.json";

// extract saul from test data .json
const saul = testCustomers.customers.saul as Required<CustomerFull>;
const saul = testCustomers.customers.saul;

/** A convenience method, to avoid having to write '' each time */
const t = (input: string, params?: Record<string, any>): string =>
Expand Down
4 changes: 2 additions & 2 deletions packages/e2e/integration/auth_redirect_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ describe("auth-related redirects", () => {

describe("authenticated non-admin", () => {
it("redirects to customer area page from any of the private routes", () => {
const { email, name, surname } = customers.saul;
const { email, name, surname, password } = customers.saul;

// Sign up (or sign in on each subsequent test) as saul.
// Saul is already registered in the app (in customers collection).
cy.signUp(email, "123456");
cy.signUp(email, password);

// Check for /athletes page
cy.visit(PrivateRoutes.Athletes);
Expand Down
8 changes: 4 additions & 4 deletions packages/e2e/integration/login_flow_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import i18n, {
ValidationMessage,
CustomerLabel,
} from "@eisbuk/translations";
import { Customer, CustomerFull } from "@eisbuk/shared";
import { Customer } from "@eisbuk/shared";

import { PrivateRoutes, defaultUser } from "../temp";

import { customers } from "../__testData__/customers.json";

// extract saul from test data .json
const saul = customers.saul as Required<CustomerFull>;
const saul = customers.saul;

/** A convenience method, to avoid having to write '' each time */
const t = (input: string, params?: Record<string, any>): string =>
Expand Down Expand Up @@ -412,8 +412,8 @@ describe("login", () => {

describe("Login redirect", () => {
it("Redirects to customer bookings page on customer (non-admin) login", () => {
const password = "password";
cy.addAuthUser({ email: saul.email, password });
const { email, password } = saul;
cy.addAuthUser({ email, password });
// log in saul, who is not an admin, but exists in customers collection
cy.clickButton(t(AuthTitle.SignInWithEmail));
cy.getAttrWith("type", "email").type(saul.email);
Expand Down

0 comments on commit 03daf8f

Please sign in to comment.