test: pin the Coach layout clock to midday and read copied text without a tag-stripping replace

The panel groups conversations by the browser's local day, so the e2e
fixture's "an hour ago" landed in yesterday when CI ran just after
midnight. The turn-steps test reads its markup by splitting rather than
with a replace CodeQL reads as an incomplete sanitiser.
This commit is contained in:
Marc-André Bombeck committed 2026-10-06 00:30:13 +02:00
1 parent 68720418e3
commit ef9dc1ddc6
2 files changed
+10 -6

No files matched your search

+5 -1
View File
@@ -41,7 +41,10 @@ import { aiBlockAvailable, serveAiBlock } from "./setup/ai-capabilities";
* Screenshots are attached to the report (no pixel baselines).
*/
const NOW = Date.now();
// A fixed midday, pinned in the browser too (see beforeEach): the panel groups
// conversations by the browser's local day, so a run just after midnight in
// the runner's or the profile's zone would move "an hour ago" into yesterday.
const NOW = Date.parse("2026-06-04T12:00:00Z");
const HOUR = 60 * 60 * 1000;
interface Conversation {
@@ -406,6 +409,7 @@ test.describe("Coach page frame", () => {
testInfo.project.name !== "chromium-desktop",
"each case sets its own viewport; the desktop project runs them all",
);
await page.clock.setFixedTime(new Date(NOW));
await serveAiBlock(page, aiBlockAvailable());
await page.emulateMedia({ reducedMotion: "reduce" });
});
@@ -363,12 +363,12 @@ describe("a step row copied out of the list", () => {
"de",
);
// What a selection copies: every text node except the unselectable ones.
// Reads this test's own static markup; not a sanitiser for input.
const copied = html
.replace(
/<span[^>]*class="[^"]*\bselect-none\b[^"]*"[^>]*>[^<]*<\/span>/g,
"",
)
.replace(/<[^>]+>/g, "")
.split(/<span[^>]*class="[^"]*\bselect-none\b[^"]*"[^>]*>[^<]*<\/span>/)
.join("")
.split(/<[^>]*>/)
.join("")
.replace(/\s+/g, " ")
.trim();
expect(copied).toBe("Gewicht · letzte 90 Tage");