sendou.ink/cypress/support/index.ts
Ryan Laughlin 15ff99bc9e
Start to fix tests + add more factories (#334)
* Stop using npm run migrate:reset in tests

* Begin moving other existing fixtures to factories

* Update cypress/support/index.ts

Co-authored-by: Kalle <38327916+Sendouc@users.noreply.github.com>

* Clean up usage of _.sample

* Rename files

* Remove incomplete building of associations

* Add missing references to calendarEvent

* Remove inaccurate seeds

* Add explicit lodash devDependency

Co-authored-by: Kalle <38327916+Sendouc@users.noreply.github.com>
2021-04-01 23:32:19 +03:00

19 lines
594 B
TypeScript

Cypress.Commands.add("dataCy", (value: string) => {
return cy.get(`[data-cy=${value}]`);
});
Cypress.Commands.add("login", (user: "sendou" | "nzap") => {
return cy.fixture(`user.${user}`).then((u) => {
const d = new Date();
u.iat = Math.floor(d.setHours(-168) / 1000);
u.exp = Math.floor(d.setHours(336) / 1000);
cy.setCookie("mockUser", JSON.stringify(u));
cy.intercept("/api/auth/session", u);
});
});
beforeEach(() => {
// TODO: use database transactions, instead of dropping and recreating the database with each individual test
cy.exec("npm run seed");
});