Skip to content

Commit

Permalink
test(e2e): add seed command
Browse files Browse the repository at this point in the history
  • Loading branch information
douglasduteil committed Oct 30, 2024
1 parent 49d362e commit a2d4a22
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/end-to-end.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@ jobs:
node-version-file: package.json
- run: npm ci --include=dev
- run: npm run migrate up
- run: npm run fixtures:load-ci -- cypress/e2e/${{ matrix.e2e_test }}/fixtures.sql
- run: npm run update-organization-info -- 500
- name: Cypress run
uses: cypress-io/[email protected]
with:
Expand Down
10 changes: 10 additions & 0 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import { generateToken } from "@sunknudsen/totp";
import { checkA11y } from "./a11y/checkA11y";
import { seed } from "./commands/seed";

//

Expand All @@ -18,6 +19,7 @@ declare global {
mfaLogin(email: string): Chainable<void>;
setCustomParams(customParams: any): Chainable<void>;
setRequestedAcrs(requestedAcrs?: string[]): Chainable<void>;
seed: typeof seed;
}
}
}
Expand Down Expand Up @@ -97,3 +99,11 @@ Cypress.Commands.add("setRequestedAcrs", (requestedAcrs) => {

cy.setCustomParams(customParams);
});

Cypress.Commands.add("seed", seed);

//

before(() => {
cy.seed();
});
35 changes: 35 additions & 0 deletions cypress/support/commands/seed.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//

import { dirname } from "path";

//

export function seed() {
{
const command = "npm run delete-database";
cy.task("log", `$ ${command}`);
cy.exec(command, { env: { ENABLE_DATABASE_DELETION: "True" } }).then(
(result) => cy.task("log", result.stdout),
);
}
{
const command = "npm run migrate up";
cy.task("log", `$ ${command}`);
cy.exec(command).then((result) => cy.task("log", result.stdout));
}
{
const scope = dirname(Cypress.spec.relative);
const command = `npm run fixtures:load-ci -- ${scope}/fixtures.sql`;
cy.task("log", `$ ${command}`);
cy.exec(command).then((result) => cy.task("log", result.stdout));
}
{
const command = "npm run update-organization-info -- 2000";
cy.task("log", `$ ${command}`);
cy.exec(command, { timeout: 10_000 }).then((result) =>
cy.task("log", result.stdout),
);
}

return cy.wrap(undefined);
}

0 comments on commit a2d4a22

Please sign in to comment.