From 9888467a9fb515ce8ef91e0a8398bde9c64ce256 Mon Sep 17 00:00:00 2001 From: Joseph Andersen <12385932+jpandersen87@users.noreply.github.com> Date: Wed, 30 Oct 2024 13:32:04 -0500 Subject: [PATCH] Un-skip E2E test: idletimeout.spec.ts if needed Fixes #16060 --- .../e2e/spec/all/idletimeout.spec.ts | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/frontend-react/e2e/spec/all/idletimeout.spec.ts b/frontend-react/e2e/spec/all/idletimeout.spec.ts index cc42f98b4d9..07815045c7d 100644 --- a/frontend-react/e2e/spec/all/idletimeout.spec.ts +++ b/frontend-react/e2e/spec/all/idletimeout.spec.ts @@ -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; @@ -37,6 +36,7 @@ const test = baseTest.extend({ frontendWarningsLogPath, isFrontendWarningsLog, }); + await page.page.clock.install(); await page.goto(); await use(page); }, @@ -44,20 +44,20 @@ const test = baseTest.extend({ 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(); });