From d6ee5fc5ec2320d2135b1b94ca20bbef01bc2f59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Salavisa?= Date: Fri, 14 Aug 2026 17:03:32 +0100 Subject: [PATCH] test(e2e): use a secure random source for secret name tokens (#2665) Co-authored-by: Kandev Agent Co-authored-by: Claude Opus 5 (1M context) --- .../web/e2e/tests/settings/mobile-secrets-copy-move.spec.ts | 4 +++- apps/web/e2e/tests/settings/secrets-copy-move.spec.ts | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/web/e2e/tests/settings/mobile-secrets-copy-move.spec.ts b/apps/web/e2e/tests/settings/mobile-secrets-copy-move.spec.ts index a1b592c295..ab5c516db4 100644 --- a/apps/web/e2e/tests/settings/mobile-secrets-copy-move.spec.ts +++ b/apps/web/e2e/tests/settings/mobile-secrets-copy-move.spec.ts @@ -1,3 +1,5 @@ +import { randomUUID } from "node:crypto"; + import { test, expect } from "../../fixtures/test-base"; import { assertNoDescendantOverflowsRight, @@ -8,7 +10,7 @@ const WORKSPACE_VALUE = "e2e-mobile-copy-move-value"; const GLOBAL_VALUE = "e2e-mobile-copy-move-global"; /** Unique per run so retries never collide with leftovers from a failed attempt. */ -const runToken = () => `${Date.now()}${Math.random().toString(36).slice(2, 6)}`; +const runToken = () => `${Date.now()}${randomUUID().slice(0, 8)}`; test.describe("mobile-secrets-copy-move", () => { test("moves a workspace secret to General and copies one back at phone width", async ({ diff --git a/apps/web/e2e/tests/settings/secrets-copy-move.spec.ts b/apps/web/e2e/tests/settings/secrets-copy-move.spec.ts index cd83af9993..a05dce6a93 100644 --- a/apps/web/e2e/tests/settings/secrets-copy-move.spec.ts +++ b/apps/web/e2e/tests/settings/secrets-copy-move.spec.ts @@ -1,9 +1,11 @@ +import { randomUUID } from "node:crypto"; + import { test, expect } from "../../fixtures/test-base"; const GLOBAL_VALUE = "e2e-copy-move-global-value"; /** Unique per run so retries never collide with leftovers from a failed attempt. */ -const runToken = () => `${Date.now()}${Math.random().toString(36).slice(2, 6)}`; +const runToken = () => `${Date.now()}${randomUUID().slice(0, 8)}`; const WORKSPACE_VALUE = "e2e-copy-move-workspace-value"; /** Creates a secret from the settings page via the Add secret dialog. */ @@ -167,7 +169,7 @@ test.describe("secrets-copy-move", () => { test("restores focus to the trigger after closing the dialog", async ({ testPage }) => { // Unique per run: retries must not collide with a secret a previous // attempt left behind (the fixture reset does not remove secrets). - const sourceName = `E2E Copy Move Focus ${Date.now()} ${Math.random().toString(36).slice(2, 6)}`; + const sourceName = `E2E Copy Move Focus ${runToken()}`; await createSecretFromSettings(testPage, "/settings/general/secrets", sourceName, GLOBAL_VALUE); await testPage.getByRole("button", { name: `Copy or move ${sourceName}` }).click();