Skip to content

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

TypeScript

test(TextInput): read each state's result once in the whole-suite contract check (#7440)

Cindy Zhangcb6bcc4702d4
diff --git a/packages/core/src/TextInput/__tests__/TextInput.a11y.chromium.spec.ts b/packages/core/src/TextInput/__tests__/TextInput.a11y.chromium.spec.ts
index a30dc04e74..269f84126e 100644
--- a/packages/core/src/TextInput/__tests__/TextInput.a11y.chromium.spec.ts
+++ b/packages/core/src/TextInput/__tests__/TextInput.a11y.chromium.spec.ts
@@ -176,26 +176,18 @@ test('every state declaration matches the browser accessibility node', async ({
expect(wrong).toEqual([]);
});
-test('every expectation is exercised and every known failure matches once', async ({
- page,
-}) => {
- test.setTimeout(8 * 60 * 1000);
- const cdp = await page.context().newCDPSession(page);
- const results: BindingResult[] = [];
- for (const state of TEXT_INPUT_BINDING_STATES) {
- results.push(await runState(page, cdp, state));
- }
- expect(neverExercised(results)).toEqual([]);
- expect(unmatchedKnownFailures(TEXT_INPUT_KNOWN_FAILURES, results)).toEqual(
- [],
- );
-});
+// Each state's result, recorded by its own test below so the whole-suite check
+// at the end reads it instead of measuring every state a second time. A state
+// whose test did not run in this worker (a filtered run, or a worker restarted
+// after a failure) is measured by the whole-suite check itself.
+const recorded = new Map<string, BindingResult>();
for (const state of TEXT_INPUT_BINDING_STATES) {
test(`${state.binding} [${state.id}] — ${state.summary}`, async ({page}) => {
test.setTimeout(3 * 60 * 1000);
const cdp = await page.context().newCDPSession(page);
const result = await runState(page, cdp, state);
+ recorded.set(state.id, result);
const report = summarize(TEXT_INPUT_PATTERN, [result]);
// eslint-disable-next-line no-console -- the report is this run's artifact
console.log(formatReport(report));
@@ -204,3 +196,18 @@ for (const state of TEXT_INPUT_BINDING_STATES) {
expect(report.counts.unexpectedPass).toBe(0);
});
}
+
+test('every expectation is exercised and every known failure matches once', async ({
+ page,
+}) => {
+ test.setTimeout(8 * 60 * 1000);
+ const cdp = await page.context().newCDPSession(page);
+ const results: BindingResult[] = [];
+ for (const state of TEXT_INPUT_BINDING_STATES) {
+ results.push(recorded.get(state.id) ?? (await runState(page, cdp, state)));
+ }
+ expect(neverExercised(results)).toEqual([]);
+ expect(unmatchedKnownFailures(TEXT_INPUT_KNOWN_FAILURES, results)).toEqual(
+ [],
+ );
+});