Cypress test with new mock auth

This commit is contained in:
Kalle
2022-05-24 19:42:26 +03:00
parent 6433383fc7
commit 92db2f8976
4 changed files with 19 additions and 8 deletions

View File

@@ -1,4 +1,4 @@
.plus__suggested-info-text {
font-size: var(--fonts-lg);
color: var(--text-lighter);
font-size: var(--fonts-lg);
}

View File

@@ -0,0 +1,13 @@
export {};
describe("Plus suggestions page", () => {
beforeEach(() => {
cy.seed();
});
it("views suggestions status as non plus member", function () {
cy.auth(150);
cy.visit("/plus");
cy.contains("You are suggested");
});
});

View File

@@ -44,6 +44,6 @@ describe("User page", () => {
cy.getCy("profile-page-link").click();
cy.contains("Sendou");
cy.contains("Finland").should("not.exist");
cy.contains(bio);
cy.contains(bio).should("not.exist");
});
});

View File

@@ -6,7 +6,7 @@ declare global {
interface Chainable {
getCy(id: string): Chainable<JQuery<HTMLElement>>;
seed(): void;
auth(): void;
auth(userId?: number): void;
}
}
}
@@ -15,13 +15,11 @@ Cypress.Commands.add("getCy", (id) => {
return cy.get(`[data-cy=${id}]`);
});
// TODO: make this a request instead... probably faster?
Cypress.Commands.add("seed", () => {
cy.exec("npm run seed");
});
const SENDOU_COOKIE =
"eyJvYXV0aDI6c3RhdGUiOiJhMDE0MjI5Mi03YjRiLTRkYTYtYWQxZC1jMTI5ZWExZGVhNjUiLCJ1c2VyIjp7ImlkIjoxLCJkaXNjb3JkSWQiOiI3OTIzNzQwMzYyMDk0NTkyMCIsImRpc2NvcmRBdmF0YXIiOiJmY2ZkNjVhM2JlYTU5ODkwNWFiYjljYTI1Mjk2ODE2YiJ9LCJzdHJhdGVneSI6ImRpc2NvcmQifQ%3D%3D.yf5YER%2B15VPqVk6Kys2jnpPAQqbq2Yv%2FF50lmGAIilc";
Cypress.Commands.add("auth", () => {
cy.setCookie("_session", SENDOU_COOKIE);
Cypress.Commands.add("auth", (id = 1) => {
cy.request("POST", `/auth/impersonate?id=${id}`);
});