diff --git a/apps/website/src/components/workshop/WorkshopModelsGrid.test.ts b/apps/website/src/components/workshop/WorkshopModelsGrid.test.ts
index d3553daacc4..ccf795adb14 100644
--- a/apps/website/src/components/workshop/WorkshopModelsGrid.test.ts
+++ b/apps/website/src/components/workshop/WorkshopModelsGrid.test.ts
@@ -130,8 +130,8 @@ describe('WorkshopModelsGrid', () => {
const user = userEvent.setup()
render(WorkshopModelsGrid, { props: { models } })
- await user.click(screen.getByRole('button', { name: 'Filter' }))
- const dialog = await screen.findByRole('dialog', { name: 'Filter' })
+ await user.click(screen.getByRole('button', { name: 'Use cases' }))
+ const dialog = await screen.findByRole('dialog', { name: 'Use cases' })
await user.click(
within(dialog).getByRole('button', { name: 'Edit images 1' })
)
@@ -148,8 +148,8 @@ describe('WorkshopModelsGrid', () => {
render(WorkshopModelsGrid, { props: { models } })
await user.click(screen.getByRole('button', { name: 'Edit images' }))
- await user.click(screen.getByRole('button', { name: 'Filter' }))
- const dialog = await screen.findByRole('dialog', { name: 'Filter' })
+ await user.click(screen.getByRole('button', { name: 'Use cases' }))
+ const dialog = await screen.findByRole('dialog', { name: 'Use cases' })
await user.click(
within(dialog).getByRole('button', { name: 'Generate videos 1' })
)
@@ -161,8 +161,8 @@ describe('WorkshopModelsGrid', () => {
const user = userEvent.setup()
render(WorkshopModelsGrid, { props: { models } })
- await user.click(screen.getByRole('button', { name: 'Filter' }))
- const dialog = await screen.findByRole('dialog', { name: 'Filter' })
+ await user.click(screen.getByRole('button', { name: 'Use cases' }))
+ const dialog = await screen.findByRole('dialog', { name: 'Use cases' })
await user.type(
within(dialog).getByRole('searchbox', { name: 'Search…' }),
'video'
diff --git a/apps/website/src/lib/workshop/filter-label.test.ts b/apps/website/src/lib/workshop/filter-label.test.ts
new file mode 100644
index 00000000000..5e62d95ce84
--- /dev/null
+++ b/apps/website/src/lib/workshop/filter-label.test.ts
@@ -0,0 +1,22 @@
+import { describe, expect, it } from 'vitest'
+
+import { filterLabel } from './filter-label'
+
+describe('filterLabel', () => {
+ it.for([
+ ['the group itself when it is the only one', ['Use cases'], 'Use cases'],
+ [
+ 'the generic name once a second group exists',
+ ['Use cases', 'Output'],
+ 'Filter'
+ ],
+ ['the generic name when there is nothing to filter by', [], 'Filter']
+ ] as const)('names it after %s', ([, labels, expected]) => {
+ expect(
+ filterLabel(
+ labels.map((label) => ({ label })),
+ 'Filter'
+ )
+ ).toBe(expected)
+ })
+})
diff --git a/apps/website/src/lib/workshop/filter-label.ts b/apps/website/src/lib/workshop/filter-label.ts
new file mode 100644
index 00000000000..8cedb4e61eb
--- /dev/null
+++ b/apps/website/src/lib/workshop/filter-label.ts
@@ -0,0 +1,13 @@
+/**
+ * What to call a filter control.
+ *
+ * A sheet with one group hides that group's name, so the control is the only
+ * place a reader can learn what the filter narrows. With more than one there is
+ * no single answer, and the generic name is the honest one.
+ */
+export function filterLabel(
+ groups: readonly { readonly label: string }[],
+ generic: string
+): string {
+ return groups.length === 1 ? groups[0].label : generic
+}