Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

Wait for warning cards to reflow before measuring (#7341)

Nick Gomez5c3dbcc1d89b
diff --git a/packages/app/tests/a11y/acp-agent-notice.e2e.ts b/packages/app/tests/a11y/acp-agent-notice.e2e.ts
index 6c79f67e8..e7c7ec33f 100644
--- a/packages/app/tests/a11y/acp-agent-notice.e2e.ts
+++ b/packages/app/tests/a11y/acp-agent-notice.e2e.ts
@@ -200,6 +200,7 @@ function readTypography(card: Locator) {
};
};
return {
+ width: el.getBoundingClientRect().width,
devicePixelRatio: window.devicePixelRatio,
label: measure(el.querySelector('p')),
body: measure(el.lastElementChild as HTMLElement | null),
@@ -239,9 +240,11 @@ test.describe('narrow window', () => {
await expect(card).toBeVisible({ timeout: 15_000 });
await page.setViewportSize({ width: 320, height: 640 });
- await page.waitForFunction(() => document.documentElement.clientWidth === 320, null, {
- timeout: 10_000,
- });
+ await expect(async () => {
+ const { width } = await readCardMetrics(card);
+ expect(width).toBeGreaterThan(0);
+ expect(width).toBeLessThanOrEqual(320);
+ }).toPass({ timeout: 10_000 });
const metrics = await readCardMetrics(card);
expect(metrics.width).toBeGreaterThan(0);
@@ -285,11 +288,14 @@ test.describe('400% browser zoom', () => {
const unzoomed = await readCardMetrics(card);
await page.setViewportSize({ width: 320, height: 256 });
- await page.waitForFunction(() => document.documentElement.clientWidth === 320, null, {
- timeout: 10_000,
- });
+ await expect(async () => {
+ const { width } = await readCardMetrics(card);
+ expect(width).toBeGreaterThan(0);
+ expect(width).toBeLessThanOrEqual(320);
+ }).toPass({ timeout: 10_000 });
const zoomed = await readTypography(card);
+ expect(zoomed.width).toBeLessThanOrEqual(320);
expect(zoomed.devicePixelRatio).toBe(4);
expect(zoomed.label.fontSize).toBeGreaterThanOrEqual(unzoomed.fontSize);