Skip to content

Commit

Permalink
Un-skip E2E test: idletimeout.spec.ts if needed
Browse files Browse the repository at this point in the history
Fixes #16060
  • Loading branch information
jpandersen87 committed Oct 30, 2024
1 parent 787b61a commit 9888467
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions frontend-react/e2e/spec/all/idletimeout.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import process from "node:process";
import { OrganizationPage } from "../../pages/authenticated/admin/organization";
import { test as baseTest } from "../../test";

const timeout = parseInt(process.env.VITE_IDLE_TIMEOUT ?? "20000");
// Add/Sub 500 ms to account for variance
const timeoutLow = timeout - 500;
const timeoutHigh = timeout + 500;
const timeout = parseInt(process.env.VITE_IDLE_TIMEOUT ?? "900000");
const timeoutLow = timeout - 1000;
const timeoutHigh = timeout + 1000;

export interface OrganizationPageFixtures {
organizationPage: OrganizationPage;
Expand Down Expand Up @@ -37,27 +36,28 @@ const test = baseTest.extend<OrganizationPageFixtures>({
frontendWarningsLogPath,
isFrontendWarningsLog,
});
await page.page.clock.install();
await page.goto();
await use(page);
},
});

test.use({ storageState: "e2e/.auth/admin.json" });

test.skip("Does not trigger early", async ({ organizationPage }) => {
test("Does not trigger early", async ({ organizationPage }) => {
await expect(organizationPage.page.getByRole("banner").first()).toBeVisible();
await organizationPage.page.keyboard.down("Tab");

const start = new Date();
await organizationPage.page.clock.fastForward(timeoutLow);

await organizationPage.page.waitForRequest(/\/oauth2\/default\/v1\/revoke/, {
timeout: timeoutHigh,
});
await expect(organizationPage.page.getByRole("banner").first()).toBeVisible();
});

const end = new Date();
test("Triggers on time", async ({ organizationPage }) => {
await expect(organizationPage.page.getByRole("banner").first()).toBeVisible();
await organizationPage.page.keyboard.down("Tab");

const idleTime = Math.abs(end.valueOf() - start.valueOf());
await organizationPage.page.clock.fastForward(timeoutHigh);

expect(idleTime).not.toBeLessThan(timeoutLow);
expect(idleTime).not.toBeGreaterThan(timeoutHigh);
await expect(organizationPage.page.getByRole("link", { name: "Login" })).toBeVisible();
});

0 comments on commit 9888467

Please sign in to comment.