Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

test(ProgressBar, CircularProgress): motion traces read screencast frames in the order they were presented (#9378)

Christopher Chedeau7d493c12ef9c
diff --git a/packages/core/src/ProgressBar/__tests__/ProgressBarMotion.a11y.chromium.spec.ts b/packages/core/src/ProgressBar/__tests__/ProgressBarMotion.a11y.chromium.spec.ts
index 6ecf063833..13e6867812 100644
--- a/packages/core/src/ProgressBar/__tests__/ProgressBarMotion.a11y.chromium.spec.ts
+++ b/packages/core/src/ProgressBar/__tests__/ProgressBarMotion.a11y.chromium.spec.ts
@@ -22,6 +22,7 @@ import {
serveStorybook,
type StaticServer,
} from '@astryxdesign/a11y-spec/storybook';
+import {inPresentationOrder} from '@astryxdesign/interaction-harness';
let storybook: StaticServer;
test.beforeAll(async () => {
@@ -124,7 +125,10 @@ interface Frame {
readonly data: string;
}
-/** Compositor frames, captured off the main thread. */
+/**
+ * Compositor frames, captured off the main thread, in the order the page
+ * presented them.
+ */
async function startScreencast(page: Page) {
const cdp = await page.context().newCDPSession(page);
const frames: Frame[] = [];
@@ -157,7 +161,13 @@ async function startScreencast(page: Page) {
await cdp.detach();
// A lost acknowledgement stalls the screencast and thins the frames.
expect(ackFailures).toEqual([]);
- return frames;
+ // Chromium encodes each frame off its main thread and can send a slow
+ // one after the next: on a loaded runner, the frame that applied a new
+ // value arrived after the first frame that moved. Frames go by the
+ // swap timestamp each one carries; a frame that shows the fill behind
+ // an earlier one still has its own later timestamp, so it stays in
+ // place and fails the trace.
+ return inPresentationOrder(frames);
},
};
}
diff --git a/packages/lab/package.json b/packages/lab/package.json
index 12d1515f23..5069976a2e 100644
--- a/packages/lab/package.json
+++ b/packages/lab/package.json
@@ -75,6 +75,7 @@
"devDependencies": {
"@astryxdesign/a11y-spec": "workspace:*",
"@astryxdesign/cli": "workspace:*",
+ "@astryxdesign/interaction-harness": "workspace:*",
"@babel/cli": "catalog:",
"@babel/core": "catalog:",
"@babel/preset-react": "catalog:",
diff --git a/packages/lab/src/CircularProgress/__tests__/CircularProgressMotion.a11y.chromium.spec.ts b/packages/lab/src/CircularProgress/__tests__/CircularProgressMotion.a11y.chromium.spec.ts
index 10cd04c372..e9778b98fd 100644
--- a/packages/lab/src/CircularProgress/__tests__/CircularProgressMotion.a11y.chromium.spec.ts
+++ b/packages/lab/src/CircularProgress/__tests__/CircularProgressMotion.a11y.chromium.spec.ts
@@ -24,6 +24,7 @@ import {
serveStorybook,
type StaticServer,
} from '@astryxdesign/a11y-spec/storybook';
+import {inPresentationOrder} from '@astryxdesign/interaction-harness';
let storybook: StaticServer;
test.beforeAll(async () => {
@@ -303,6 +304,11 @@ test('a value change keeps moving while a script holds the main thread', async (
await cdp.detach();
// A lost acknowledgement stalls the screencast and thins the frames.
expect(ackFailures).toEqual([]);
+ // Chromium encodes each frame off its main thread and can send a slow one
+ // after the next: frames go by the swap timestamp each one carries. A frame
+ // that shows the arc behind an earlier one still has its own later
+ // timestamp, so it stays in place.
+ const presented = inPresentationOrder(raw);
// Crop each frame to the ring, then read how far the arc reaches.
const scratch = await page.context().newPage();
let crops: string[];
@@ -344,13 +350,13 @@ test('a value change keeps moving while a script holds the main thread', async (
}
return out;
},
- {items: raw.map(f => f.data), ring: box},
+ {items: presented.map(f => f.data), ring: box},
);
} finally {
await scratch.close();
}
const rows = await inkByDegree(page, crops, palette);
- const frames = rows.map((row, i) => ({t: raw[i].t, ...span(row)}));
+ const frames = rows.map((row, i) => ({t: presented[i].t, ...span(row)}));
const inside = frames.filter(
f => f.t >= busy.from + 20 && f.t <= busy.to - 20,
);
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 276e75556f..42294168aa 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -949,6 +949,9 @@ importers:
'@astryxdesign/cli':
specifier: workspace:*
version: link:../cli
+ '@astryxdesign/interaction-harness':
+ specifier: workspace:*
+ version: link:../../internal/interaction-harness
'@babel/cli':
specifier: 'catalog:'
version: 7.29.7(@babel/[email protected])