Skip to content

Commit 369e797

Browse files
benvinegarclaude
andcommitted
test(e2e): disambiguate html vs markdown iframes in theme.spec
#66's theme.spec was authored when markdown rendered in-document; this branch moves markdown into its own sandboxed `srcdoc` iframe, so `.card iframe` now matches two elements (Playwright strict-mode violation) and `.mdpart` no longer exists. Target the html part via `iframe[src]` and read the shiki token through the markdown frame (iframe.mdframe). Behavior covered is unchanged: all three theming layers still move together. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 327dbb7 commit 369e797

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

e2e/theme.spec.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { expect, publishParts, test } from "./fixtures.ts";
22

33
// A surface with the two parts whose theming runs through different layers: an
4-
// html part (re-themed by reloading its sandboxed iframe at /s/:id) and a
5-
// markdown part (re-highlighted in-document by shiki). Together with the chrome
4+
// html part (re-themed by reloading its sandboxed iframe at /s/:id, which has a
5+
// `src`) and a markdown part (rendered in its own sandboxed `srcdoc` iframe,
6+
// re-highlighted by shiki when its doc rebuilds). Together with the chrome
67
// palette that covers the layers CLAUDE.md warns must move as one.
78
const PARTS = [
89
{ kind: "html", html: "<p>surface body</p>" },
@@ -19,8 +20,13 @@ test("switching the board theme re-themes chrome, html parts, and markdown toget
1920

2021
await page.goto(server.url);
2122
const card = page.locator(".card");
22-
const iframe = card.locator("iframe");
23-
const token = card.locator(".mdpart pre.shiki span[style*='color']").first();
23+
// the html part is the iframe with a `src`; the markdown part is a separate
24+
// `srcdoc` iframe (iframe.mdframe), and its shiki token lives inside it
25+
const iframe = card.locator("iframe[src]");
26+
const token = card
27+
.frameLocator("iframe.mdframe")
28+
.locator("pre.shiki span[style*='color']")
29+
.first();
2430

2531
// default theme is github; the iframe carries it in its src and the chrome
2632
// exposes the github light bg via the injected --bg var
@@ -69,7 +75,7 @@ test("the picked theme persists across a reload", async ({ page, server }) => {
6975
// of the default
7076
await page.reload();
7177
await expect(page.locator("#themeSel")).toHaveValue("gruvbox");
72-
await expect(page.locator(".card iframe")).toHaveAttribute("src", /theme=gruvbox/);
78+
await expect(page.locator(".card iframe[src]")).toHaveAttribute("src", /theme=gruvbox/);
7379
await expect
7480
.poll(() =>
7581
page.evaluate(() =>
@@ -89,14 +95,14 @@ test("a theme switch in one tab re-themes another open tab via SSE", async ({
8995
await page.goto(server.url);
9096
const other = await context.newPage();
9197
await other.goto(server.url);
92-
await expect(other.locator(".card iframe")).toHaveAttribute("src", /theme=github/);
98+
await expect(other.locator(".card iframe[src]")).toHaveAttribute("src", /theme=github/);
9399

94100
// switch in the first tab; the second re-themes off the theme-changed SSE
95101
// event without its own user action
96102
await page.locator("#themeSel").selectOption("gruvbox");
97103

98104
await expect(other.locator("#themeSel")).toHaveValue("gruvbox");
99-
await expect(other.locator(".card iframe")).toHaveAttribute("src", /theme=gruvbox/);
105+
await expect(other.locator(".card iframe[src]")).toHaveAttribute("src", /theme=gruvbox/);
100106
await expect
101107
.poll(() =>
102108
other.evaluate(() =>

0 commit comments

Comments
 (0)