An open source design system that's fully customizable and agent ready
TypeScript
ci: match audit titles without case; scope the parity specs to Rich Text source (#8416)
Cindy Zhangb7ea471a8fc7
diff --git a/.github/scripts/a11y-pr-contracts.mjs b/.github/scripts/a11y-pr-contracts.mjsindex e167518035..c177222229 100644--- a/.github/scripts/a11y-pr-contracts.mjs+++ b/.github/scripts/a11y-pr-contracts.mjs@@ -135,14 +135,21 @@ function componentMatches(token, components) {}/**- * Audited component names from a "[Component Audit] <Name>: ..." title.+ * Audited component names from a "[Component Audit] <Name>: ..." title. Like+ * GitHub's `startsWith`, the match ignores case; names compare with+ * `sameComponent`.* @param {string} title*/export function auditedComponents(title) {- const match = /^\[Component Audit\] ([A-Z]\w*):/.exec(title ?? '');+ const match = /^\[component audit\] (\w+):/i.exec(title ?? '');return match ? [match[1]] : [];}+/** Component names compared without case, as an audit title is. */+export function sameComponent(a, b) {+ return a.toLowerCase() === b.toLowerCase();+}+/** `DropdownMenuItem` -> `dropdown-menu-item`. */export function kebab(name) {return name.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();@@ -191,10 +198,14 @@ export function auditPlan(name, config) {*/export function planFor(name, specs, config) {if (!name) return null;- const configured =- Object.hasOwn(config, name) ||- specs.some(({routing}) => routing.audits.includes(name));- return configured ? auditPlan(name, config) : null;+ const canonical =+ Object.keys(config).find(+ key => key !== '$comment' && sameComponent(key, name),+ ) ??+ specs+ .flatMap(({routing}) => routing.audits)+ .find(audit => sameComponent(audit, name));+ return canonical ? auditPlan(canonical, config) : null;}/** The `accessibility-audit.js` arguments for an audit plan. */@@ -239,7 +250,9 @@ export function selectSpecs({if (routing.mode === 'always') return 'always';if (!isPullRequest || routing.mode === 'release-only') return null;if (routing.mode === 'audit') {- const name = routing.audits.find(n => audited.includes(n));+ const name = routing.audits.find(n =>+ audited.some(a => sameComponent(a, n)),+ );return name ? `component audit ${name}` : null;}if (changedPaths == null) return 'scope unknown';diff --git a/.github/scripts/a11y-pr-contracts.test.mjs b/.github/scripts/a11y-pr-contracts.test.mjsindex 913db4e148..68fea8c57b 100644--- a/.github/scripts/a11y-pr-contracts.test.mjs+++ b/.github/scripts/a11y-pr-contracts.test.mjs@@ -226,6 +226,10 @@ describe('selectSpecs', () => {expect(pr([audit], {title: 'fix: [Component Audit] ChatMessageList:'}),).toEqual([]);+ // GitHub's startsWith, which the per-audit steps used, ignores case.+ expect(+ pr([audit], {title: '[component audit] chatmessagelist: fix'}),+ ).toEqual([audit.file]);});it('never runs a release-only spec on a pull request', () => {@@ -339,6 +343,11 @@ describe('component audit axe pass', () => {// A name with no audit spec and no entry may have no owned Storybook// route; axe would refuse it and fail the job.expect(planFor('DialogHeader', named, config)).toBeNull();+ // A title in another case resolves to the configured name.+ expect(planFor('dateinput', [], config)?.readySelector).toBe(+ '[role="dialog"]',+ );+ expect(planFor('drawer', named, {})?.components).toEqual(['Drawer']);expect(planFor(undefined, named, config)).toBeNull();});diff --git a/packages/richtext/src/__tests__/MarkdownParitySandbox.a11y.chromium.spec.ts b/packages/richtext/src/__tests__/MarkdownParitySandbox.a11y.chromium.spec.tsindex 6ab7b00e13..f1bcb4664d 100644--- a/packages/richtext/src/__tests__/MarkdownParitySandbox.a11y.chromium.spec.ts+++ b/packages/richtext/src/__tests__/MarkdownParitySandbox.a11y.chromium.spec.ts@@ -1,5 +1,5 @@// Copyright (c) Meta Platforms, Inc. and affiliates.-// @pr-a11y scope core/Markdown richtext/* ^(apps/storybook/stories/RichTextEditor\.(markdownParity|stories)|packages/richtext/src/__tests__/(MarkdownParitySandbox|RichTextView|RichTextEditorToolbar)) ^packages/richtext/+// @pr-a11y scope core/Markdown richtext/* ^(apps/storybook/stories/RichTextEditor\.(markdownParity|stories)|packages/richtext/src/__tests__/(MarkdownParitySandbox|RichTextView|RichTextEditorToolbar)) ^packages/richtext/src//*** @file MarkdownParitySandbox.a11y.chromium.spec.tsdiff --git a/packages/richtext/src/__tests__/RichTextEditorToolbar.a11y.chromium.spec.ts b/packages/richtext/src/__tests__/RichTextEditorToolbar.a11y.chromium.spec.tsindex 56728a517e..66d78371f8 100644--- a/packages/richtext/src/__tests__/RichTextEditorToolbar.a11y.chromium.spec.ts+++ b/packages/richtext/src/__tests__/RichTextEditorToolbar.a11y.chromium.spec.ts@@ -1,5 +1,5 @@// Copyright (c) Meta Platforms, Inc. and affiliates.-// @pr-a11y scope core/Markdown richtext/* ^(apps/storybook/stories/RichTextEditor\.(markdownParity|stories)|packages/richtext/src/__tests__/(MarkdownParitySandbox|RichTextView|RichTextEditorToolbar)) ^packages/richtext/+// @pr-a11y scope core/Markdown richtext/* ^(apps/storybook/stories/RichTextEditor\.(markdownParity|stories)|packages/richtext/src/__tests__/(MarkdownParitySandbox|RichTextView|RichTextEditorToolbar)) ^packages/richtext/src//*** @file RichTextEditorToolbar.a11y.chromium.spec.tsdiff --git a/packages/richtext/src/__tests__/RichTextView.a11y.chromium.spec.ts b/packages/richtext/src/__tests__/RichTextView.a11y.chromium.spec.tsindex 11edd4634d..b6c0eaf286 100644--- a/packages/richtext/src/__tests__/RichTextView.a11y.chromium.spec.ts+++ b/packages/richtext/src/__tests__/RichTextView.a11y.chromium.spec.ts@@ -1,5 +1,5 @@// Copyright (c) Meta Platforms, Inc. and affiliates.-// @pr-a11y scope core/Markdown richtext/* ^(apps/storybook/stories/RichTextEditor\.(markdownParity|stories)|packages/richtext/src/__tests__/(MarkdownParitySandbox|RichTextView|RichTextEditorToolbar)) ^packages/richtext/+// @pr-a11y scope core/Markdown richtext/* ^(apps/storybook/stories/RichTextEditor\.(markdownParity|stories)|packages/richtext/src/__tests__/(MarkdownParitySandbox|RichTextView|RichTextEditorToolbar)) ^packages/richtext/src//*** @file RichTextView.a11y.chromium.spec.ts