diff --git a/apps/website/src/components/workshop/FeaturedBanner.test.ts b/apps/website/src/components/workshop/FeaturedBanner.test.ts
index a568edf3721..f7fa3541577 100644
--- a/apps/website/src/components/workshop/FeaturedBanner.test.ts
+++ b/apps/website/src/components/workshop/FeaturedBanner.test.ts
@@ -5,7 +5,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'
import type { WorkshopModel } from '../../config/models-catalogue'
import FeaturedBanner from './FeaturedBanner.vue'
-import { modelSlides, studioSlide } from '../../lib/workshop/featured-slides'
+import { modelSlides } from '../../lib/workshop/featured-slides'
import {
setAllIntersecting,
stubIntersectionObserver
@@ -72,24 +72,6 @@ describe('FeaturedBanner', () => {
)
})
- it('leads with Cinematic Studio when the catalogue promotes it', () => {
- render(FeaturedBanner, {
- props: {
- slides: [studioSlide('en'), ...modelSlides([base, kling], 'en')]
- }
- })
-
- expect(screen.getByRole('heading', { level: 2 }).textContent).toBe(
- 'Cinematic Studio'
- )
- expect(screen.getByRole('link', { name: 'Open studio' })).toHaveAttribute(
- 'href',
- '/models/apps/cinematic-studio'
- )
- expect(screen.queryByTestId('featured-docs-link')).toBeNull()
- expect(screen.getByRole('button', { name: 'Flux' })).toBeTruthy()
- })
-
it('localizes the task without leaving its English suffix in the model name', () => {
render(FeaturedBanner, {
props: {
@@ -288,28 +270,23 @@ describe('FeaturedBanner', () => {
expect(screen.getByRole('heading', { level: 2 }).textContent).toBe('Kling')
})
- // The compact banner gives up height where outcome rows follow it. What it
- // must not give up is anything the reader came for.
- it.for([false, true])(
- 'carries the same slide whether or not it is compact (%s)',
- (compact) => {
- render(FeaturedBanner, {
- props: { slides: modelSlides([base, kling], 'en'), compact }
- })
- expect(screen.getByRole('heading', { level: 2 }).textContent).toBe('Flux')
- expect(screen.getByText('Text to Image')).toBeTruthy()
- expect(
- screen.getByText(
- 'Photorealistic images with professional text rendering.'
- )
- ).toBeTruthy()
- expect(
- screen.getByTestId('featured-slide-link').getAttribute('href')
- ).toBe('/models/flux/')
- expect(screen.getByRole('link', { name: /Try/i })).toHaveAttribute(
- 'href',
- '/models/flux/'
+ it('carries everything the reader came for', () => {
+ render(FeaturedBanner, {
+ props: { slides: modelSlides([base, kling], 'en') }
+ })
+ expect(screen.getByRole('heading', { level: 2 }).textContent).toBe('Flux')
+ expect(screen.getByText('Text to Image')).toBeTruthy()
+ expect(
+ screen.getByText(
+ 'Photorealistic images with professional text rendering.'
)
- }
- )
+ ).toBeTruthy()
+ expect(screen.getByTestId('featured-slide-link').getAttribute('href')).toBe(
+ '/models/flux/'
+ )
+ expect(screen.getByRole('link', { name: /Try/i })).toHaveAttribute(
+ 'href',
+ '/models/flux/'
+ )
+ })
})
diff --git a/apps/website/src/components/workshop/FeaturedBanner.vue b/apps/website/src/components/workshop/FeaturedBanner.vue
index 945c3ead87a..82c10c6c9f0 100644
--- a/apps/website/src/components/workshop/FeaturedBanner.vue
+++ b/apps/website/src/components/workshop/FeaturedBanner.vue
@@ -12,10 +12,10 @@ import { prefersReducedMotion } from '../../composables/useReducedMotion'
import { usePreviewVideo } from '../../composables/usePreviewVideo'
import type { Locale } from '../../i18n/translations'
import { t } from '../../i18n/translations'
-import { cn } from '@comfyorg/tailwind-utils'
import Badge from '../ui/badge/Badge.vue'
import Button from '@/components/ui/button/Button.vue'
+import FeaturedBannerPagination from './FeaturedBannerPagination.vue'
/**
* One thing worth opening, whatever kind of thing the catalogue holds. The
@@ -41,15 +41,11 @@ const AUTOPLAY_MS = 7000
const {
slides,
locale = 'en',
- autoplay = true,
- compact = false
+ autoplay = true
} = defineProps<{
slides: readonly FeaturedSlide[]
locale?: Locale
autoplay?: boolean
- /** Where outcome rows follow immediately, the banner gives up height so the
- * first of them is on screen with it. */
- compact?: boolean
}>()
const activeIndex = ref(0)
@@ -126,14 +122,7 @@ const fill = computed(() =>
data-testid="section-featured"
>
/>
-
-
-
+ :slides
+ :active-index="activeIndex"
+ :fill
+ @go="goTo"
+ />
diff --git a/apps/website/src/components/workshop/FeaturedBannerPagination.vue b/apps/website/src/components/workshop/FeaturedBannerPagination.vue
new file mode 100644
index 00000000000..248a9566209
--- /dev/null
+++ b/apps/website/src/components/workshop/FeaturedBannerPagination.vue
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
diff --git a/apps/website/src/components/workshop/FileSourceInput.test.ts b/apps/website/src/components/workshop/FileSourceInput.test.ts
index f281a1c5495..b527b8d1945 100644
--- a/apps/website/src/components/workshop/FileSourceInput.test.ts
+++ b/apps/website/src/components/workshop/FileSourceInput.test.ts
@@ -310,3 +310,44 @@ describe('file source selection', () => {
expect(screen.queryByRole('img')).toBeNull()
})
})
+
+describe('undoing a removal', () => {
+ const sample: FileValue = {
+ name: 'courtyard.png',
+ size: 2048,
+ type: 'image/png',
+ sourceUrl: 'https://example.test/courtyard.png'
+ }
+
+ it('offers the removed picture back instead of sending the reader to the example', async () => {
+ const values = mountInput(false, { ...field, multiple: false }, sample)
+ const visitor = userEvent.setup()
+
+ await visitor.click(screen.getByRole('button', { name: /Remove/ }))
+ expect(values.value).toBeUndefined()
+
+ const undo = screen.getByTestId('removed-file-undo')
+ expect(undo).toHaveTextContent('courtyard.png removed')
+ await visitor.click(
+ within(undo).getByRole('button', { name: 'Put it back' })
+ )
+
+ expect(values.value).toEqual(sample)
+ expect(screen.queryByTestId('removed-file-undo')).toBeNull()
+ })
+
+ it('drops the offer once the reader has chosen a file themselves', async () => {
+ mountInput(false, { ...field, multiple: false }, sample)
+ const visitor = userEvent.setup()
+
+ await visitor.click(screen.getByRole('button', { name: /Remove/ }))
+ expect(screen.getByTestId('removed-file-undo')).toBeTruthy()
+
+ await visitor.upload(
+ screen.getByLabelText('Images', { selector: 'input' }),
+ new File([new Uint8Array(8)], 'mine.png', { type: 'image/png' })
+ )
+
+ expect(screen.queryByTestId('removed-file-undo')).toBeNull()
+ })
+})
diff --git a/apps/website/src/components/workshop/FileSourceInput.vue b/apps/website/src/components/workshop/FileSourceInput.vue
index 48f1021fe59..5ec82c681f4 100644
--- a/apps/website/src/components/workshop/FileSourceInput.vue
+++ b/apps/website/src/components/workshop/FileSourceInput.vue
@@ -52,6 +52,9 @@ const uploadLimit = computed(() =>
formatWorkshopUploadLimit(field.maxBytes, locale)
)
const rejection = ref()
+// Removing the only picture the example brought left the field empty with no
+// way back but the example card further down, which rewrites the whole form.
+const removed = ref<{ at: number; file: FileValue }>()
const replacement = ref()
const input = useTemplateRef('input')
const zone = useTemplateRef('zone')
@@ -149,6 +152,7 @@ function choose(files: File[], index?: number) {
? 'workshop.form.tooLarge'
: undefined
if (rejection.value) return
+ removed.value = undefined
value.value = field.multiple ? next : next[0]
}
@@ -169,6 +173,7 @@ function remove(index: number) {
const remaining = selectedFiles.value.filter(
(_, position) => position !== index
)
+ removed.value = { at: index, file: selectedFiles.value[index] }
value.value = remaining.length
? field.multiple
? remaining
@@ -176,6 +181,14 @@ function remove(index: number) {
: undefined
rejection.value = undefined
}
+
+function putBack() {
+ const undo = removed.value
+ if (!undo) return
+ const restored = selectedFiles.value.toSpliced(undo.at, 0, undo.file)
+ value.value = field.multiple ? restored : restored[0]
+ removed.value = undefined
+}
@@ -190,6 +203,21 @@ function remove(index: number) {
)
"
>
+
+ {{ t('workshop.field.removedFile', locale, { name: removed.file.name }) }}
+
+
{
)
expect(screen.getByTestId('example-replace-dialog').textContent).toContain(
- '要替换你的输入吗?'
+ '要载入这个示例吗?'
)
expect(screen.getByTestId('example-replace-confirm').textContent).toContain(
- '使用该示例'
+ '载入示例'
)
})
diff --git a/apps/website/src/components/workshop/ModelDetail.vue b/apps/website/src/components/workshop/ModelDetail.vue
index 7514cf8fb65..ba602b2e27b 100644
--- a/apps/website/src/components/workshop/ModelDetail.vue
+++ b/apps/website/src/components/workshop/ModelDetail.vue
@@ -1060,7 +1060,6 @@ function useInCode() {
:earlier
:attachments
:now
- :model-name="model.name"
:modality="model.modality"
:locale
:member-workspace="
diff --git a/apps/website/src/components/workshop/ModelsCatalogue.test.ts b/apps/website/src/components/workshop/ModelsCatalogue.test.ts
index fd790c8d2bf..f0481f825f0 100644
--- a/apps/website/src/components/workshop/ModelsCatalogue.test.ts
+++ b/apps/website/src/components/workshop/ModelsCatalogue.test.ts
@@ -162,8 +162,6 @@ describe('ModelsCatalogue', () => {
).toBeNull()
})
- // The line under the title belongs to the half that is open, so the eyebrow
- // is what has to hold still: it names the whole catalogue, not the tab.
it('names the Hub in the eyebrow on every tab', async () => {
const user = userEvent.setup()
render(ModelsCatalogue, { props: { models: launchModels } })
diff --git a/apps/website/src/components/workshop/ModelsPage.test.ts b/apps/website/src/components/workshop/ModelsPage.test.ts
index e144cf5750a..c962a12f408 100644
--- a/apps/website/src/components/workshop/ModelsPage.test.ts
+++ b/apps/website/src/components/workshop/ModelsPage.test.ts
@@ -66,7 +66,7 @@ describe('Models page entry', () => {
expect(
screen.getByRole('group', { name: 'Your original image' })
).toBeVisible()
- expect(screen.getByText('An example from this template.')).toBeVisible()
+ expect(screen.getByTestId('output-example')).toBeVisible()
workflowsEnabled.value = false
await nextTick()
expect(screen.getByRole('heading', { name: 'Public Models' })).toBeVisible()
diff --git a/apps/website/src/components/workshop/PlaygroundField.test.ts b/apps/website/src/components/workshop/PlaygroundField.test.ts
index ff54d43b320..c60eb58b9a6 100644
--- a/apps/website/src/components/workshop/PlaygroundField.test.ts
+++ b/apps/website/src/components/workshop/PlaygroundField.test.ts
@@ -1,7 +1,7 @@
import userEvent from '@testing-library/user-event'
import { fireEvent, render, screen, within } from '@testing-library/vue'
import { describe, expect, it, vi } from 'vitest'
-import { defineComponent, h, ref } from 'vue'
+import { defineComponent, h, nextTick, ref } from 'vue'
import type {
FieldErrors,
@@ -89,6 +89,29 @@ describe('PlaygroundField', () => {
expect(screen.queryByText(`Default: ${field.defaultValue}`)).toBeNull()
})
+ it('grows the prompt box to the prompt an example drops into it', async () => {
+ const field: FieldSchema = {
+ kind: 'text',
+ name: 'prompt',
+ label: 'Prompt',
+ required: true,
+ multiline: true
+ }
+ const values = mountField(field, { prompt: 'A forest.' })
+ const box = screen.getByTestId('field-prompt')
+ const lineHeight = 24
+ Object.defineProperty(box, 'scrollHeight', {
+ get: () => box.value.split('\n').length * lineHeight
+ })
+
+ values.value = {
+ prompt: 'A forest.\nThen a clearing.\nThen the sea.\nThen dusk.'
+ }
+ await nextTick()
+
+ expect(box.style.height).toBe(`${4 * lineHeight}px`)
+ })
+
it('preserves a provider rejection when the input passes its form constraint', () => {
mountField(
{
diff --git a/apps/website/src/components/workshop/PlaygroundField.vue b/apps/website/src/components/workshop/PlaygroundField.vue
index 14b3ed23be8..57b45f5d375 100644
--- a/apps/website/src/components/workshop/PlaygroundField.vue
+++ b/apps/website/src/components/workshop/PlaygroundField.vue
@@ -1,6 +1,7 @@
+
+
+
+
+ {{ title }}
+
+
+ {{ subtitle }}
+
+
+
diff --git a/apps/website/src/components/workshop/VideoSourcePreview.vue b/apps/website/src/components/workshop/VideoSourcePreview.vue
index 393ed586760..ce093869d41 100644
--- a/apps/website/src/components/workshop/VideoSourcePreview.vue
+++ b/apps/website/src/components/workshop/VideoSourcePreview.vue
@@ -1,5 +1,4 @@
+
+
+
+
diff --git a/apps/website/src/components/workshop/WorkflowGraph.vue b/apps/website/src/components/workshop/WorkflowGraph.vue
index 586f5b64e11..a535a5fb4ff 100644
--- a/apps/website/src/components/workshop/WorkflowGraph.vue
+++ b/apps/website/src/components/workshop/WorkflowGraph.vue
@@ -1,16 +1,20 @@
@@ -174,42 +192,26 @@ const control =
v-else
class="flex size-full items-center justify-center text-sm text-content-muted"
>
- {{
- failed
- ? t('workshop.workflow.graphFailed')
- : t('workshop.workflow.graphLoading')
- }}
+ {{ statusText }}
-
- {{ t('workshop.workflow.graphHint') }}
-
+
+ {{ t('workshop.workflow.fullPreview') }}
+
-
-
-
- {{ Math.round(scale * 100) }}%
-
-
-
-
+ :scale
+ @zoom="zoomBy"
+ @reset="reset"
+ />
diff --git a/apps/website/src/components/workshop/WorkflowGraphControls.vue b/apps/website/src/components/workshop/WorkflowGraphControls.vue
new file mode 100644
index 00000000000..204adb9a9e5
--- /dev/null
+++ b/apps/website/src/components/workshop/WorkflowGraphControls.vue
@@ -0,0 +1,41 @@
+
+
+
+
+ {{ t('workshop.workflow.graphHint') }}
+
+
+
+
+
+ {{ Math.round(scale * 100) }}%
+
+
+
+
+
diff --git a/apps/website/src/components/workshop/WorkflowGraphNode.vue b/apps/website/src/components/workshop/WorkflowGraphNode.vue
index bff793c1f13..614791e1dc5 100644
--- a/apps/website/src/components/workshop/WorkflowGraphNode.vue
+++ b/apps/website/src/components/workshop/WorkflowGraphNode.vue
@@ -120,7 +120,7 @@ const header = (n: GraphNode) =>
:y="node.y + node.picture.y"
:width="node.width - WIDGET_INSET * 2"
:height="node.picture.height"
- preserveAspectRatio="xMidYMid slice"
+ preserveAspectRatio="xMidYMid meet"
:clip-path="`url(#sample-${node.id})`"
/>
diff --git a/apps/website/src/components/workshop/WorkflowPage.test.ts b/apps/website/src/components/workshop/WorkflowPage.test.ts
index e7522eee22b..bddd5f65e90 100644
--- a/apps/website/src/components/workshop/WorkflowPage.test.ts
+++ b/apps/website/src/components/workshop/WorkflowPage.test.ts
@@ -39,12 +39,12 @@ describe('WorkflowPage header', () => {
expect(screen.queryByTestId('workflow-use-case')).toBeNull()
})
- it('credits the template and leaves the models to the Details tab', () => {
+ it('leaves the credit and the models to the Details tab', () => {
mount()
const hero = screen.getByTestId('workflow-hero')
expect(hero).toHaveTextContent(model.name)
- expect(hero).toHaveTextContent(`Template by ${template.author}`)
+ expect(hero).not.toHaveTextContent(`Template by ${template.author}`)
for (const name of template.models) expect(hero).not.toHaveTextContent(name)
})
})
diff --git a/apps/website/src/components/workshop/WorkflowPage.vue b/apps/website/src/components/workshop/WorkflowPage.vue
index 35269623574..657b3a56913 100644
--- a/apps/website/src/components/workshop/WorkflowPage.vue
+++ b/apps/website/src/components/workshop/WorkflowPage.vue
@@ -74,17 +74,6 @@ const cloudHref = template
>
{{ model.summary }}
-
- {{
- t('workshop.workflow.templateBy', 'en', {
- author: template.author
- })
- }}
-
- {{ t('workshop.workflow.explore') }}
+ {{ t('workshop.examples.start') }}
-
+ @open="selectExample(index)"
+ />
{
role="tabpanel"
aria-labelledby="workflow-tab-workflow"
>
-
-
- {{ t('workshop.workflow.inside') }}
-
-
- {{ t('workshop.workflow.previewHint') }}
-
-
+
diff --git a/apps/website/src/components/workshop/WorkflowResults.test.ts b/apps/website/src/components/workshop/WorkflowResults.test.ts
index 1359c1d1436..1190aafd6d4 100644
--- a/apps/website/src/components/workshop/WorkflowResults.test.ts
+++ b/apps/website/src/components/workshop/WorkflowResults.test.ts
@@ -262,7 +262,7 @@ describe('a refused request', () => {
expect(
screen.getAllByText('Not enough credits. Add credits to continue.').length
).toBeGreaterThan(0)
- expect(screen.queryByText('An example from this template.')).toBeNull()
+ expect(screen.queryByTestId('output-example')).toBeNull()
})
// The panel already knows how to send a reader to buy credits; it was never
@@ -285,7 +285,7 @@ describe('a refused request', () => {
it('shows nothing rather than the example for a refusal it cannot word', () => {
mountRefused('access_denied')
- expect(screen.queryByText('An example from this template.')).toBeNull()
+ expect(screen.queryByTestId('output-example')).toBeNull()
expect(screen.getByText('Your output will appear here.')).toBeTruthy()
})
})
diff --git a/apps/website/src/components/workshop/WorkflowResults.vue b/apps/website/src/components/workshop/WorkflowResults.vue
index 1996d3ea09a..de7cf460a9c 100644
--- a/apps/website/src/components/workshop/WorkflowResults.vue
+++ b/apps/website/src/components/workshop/WorkflowResults.vue
@@ -209,7 +209,6 @@ function captureDownload(kind: RunOutput['kind']) {
:state="outputState"
:attachments="outputs.slice(1)"
:now="now.getTime()"
- :model-name="model.name"
:modality="model.modality"
:retry-disabled="!canStart"
:cancelled-message="t('workshop.workflow.cancelled')"
@@ -221,7 +220,6 @@ function captureDownload(kind: RunOutput['kind']) {
@playback-started="delivery.beginPlayback"
@download="captureDownload"
>
-
{{ t('workshop.workflow.exampleHint') }}
taskLabelFor(model, locale))
+const cardName = computed(() => nameWithoutTask(model.name, taskLabel.value))
const thumbnailLabel = computed(() =>
model.thumbnail ? model.thumbnailLabel : undefined
)
@@ -97,7 +98,7 @@ const pillClass =
:title="model.name"
data-testid="model-card-name"
>
- {{ model.name }}
+ {{ cardName }}
diff --git a/apps/website/src/components/workshop/WorkshopModelsGrid.test.ts b/apps/website/src/components/workshop/WorkshopModelsGrid.test.ts
index ee02be61de3..67f60201897 100644
--- a/apps/website/src/components/workshop/WorkshopModelsGrid.test.ts
+++ b/apps/website/src/components/workshop/WorkshopModelsGrid.test.ts
@@ -1,16 +1,13 @@
import userEvent from '@testing-library/user-event'
import { render, screen, waitFor, within } from '@testing-library/vue'
-import { afterEach, describe, expect, it, vi } from 'vitest'
+import { afterEach, describe, expect, it, onTestFinished, vi } from 'vitest'
-import { computed, nextTick } from 'vue'
+import { nextTick } from 'vue'
import type { WorkshopModel } from '../../config/models-catalogue'
import { lastShelf } from '../../lib/workshop/shelf-memory'
-import { useWorkshopAppsEnabled } from '../../scripts/posthog'
import WorkshopModelsGrid from './WorkshopModelsGrid.vue'
-vi.mock(import('../../scripts/posthog'))
-
const models: WorkshopModel[] = [
{
slug: 'kling-ai',
@@ -146,7 +143,7 @@ describe('WorkshopModelsGrid', () => {
expect(cardNames()).toHaveLength(3)
})
- it('clears filter chips without leaving Browse all models', async () => {
+ it('clears the filters without leaving Browse all models', async () => {
const user = userEvent.setup()
render(WorkshopModelsGrid, { props: { models } })
@@ -156,7 +153,7 @@ describe('WorkshopModelsGrid', () => {
await user.click(
within(dialog).getByRole('button', { name: 'Edit images 1' })
)
- await user.click(screen.getByTestId('workshop-filter-chips-clear'))
+ await user.click(within(dialog).getByTestId('workshop-filter-clear'))
expect(screen.getByRole('heading', { level: 1 })).toHaveTextContent(
'All models 3'
@@ -165,21 +162,28 @@ describe('WorkshopModelsGrid', () => {
expect(cardNames()).toHaveLength(3)
})
- it('names the section it was browsing, and leaves it from that name', async () => {
+ // A shelf and the filter are the same choice: opening "Edit images" has to
+ // leave the menu saying so, or the reader sees a narrowed grid with nothing
+ // anywhere to say what narrowed it.
+ it('opens a shelf as the filter it is', async () => {
const user = userEvent.setup()
render(WorkshopModelsGrid, { props: { models } })
await user.click(screen.getByRole('button', { name: 'Edit images' }))
- expect(screen.getByTestId('workshop-filter-chips')).toHaveTextContent(
+ expect(screen.getByRole('heading', { level: 1 })).toHaveTextContent(
'Edit images'
)
+ expect(screen.getByTestId('workshop-filter-count')).toHaveTextContent('1')
- await user.click(screen.getByRole('button', { name: 'Remove Edit images' }))
- expect(screen.queryByTestId('workshop-filter-chips')).toBeNull()
- expect(cardNames()).toHaveLength(3)
+ await user.click(screen.getByRole('button', { name: 'Use cases' }))
+ const dialog = await screen.findByRole('dialog', { name: 'Use cases' })
+ expect(
+ within(dialog).getByRole('button', { name: 'Edit images 1' })
+ ).toHaveAttribute('aria-pressed', 'true')
+ expect(within(dialog).getByText('1 selected')).toBeTruthy()
})
- it('names the use case it was narrowed by, and lets go of it from that name', async () => {
+ it('counts what the menu narrowed by, and lets go of it from the menu', async () => {
const user = userEvent.setup()
render(WorkshopModelsGrid, { props: { models } })
@@ -188,18 +192,18 @@ describe('WorkshopModelsGrid', () => {
await user.click(
within(dialog).getByRole('button', { name: 'Edit images 1' })
)
- expect(screen.getByTestId('workshop-filter-chips')).toHaveTextContent(
- 'Edit images'
- )
+ expect(screen.getByTestId('workshop-filter-count')).toHaveTextContent('1')
- await user.click(screen.getByRole('button', { name: 'Remove Edit images' }))
- expect(screen.queryByTestId('workshop-filter-chips')).toBeNull()
+ await user.click(
+ within(dialog).getByRole('button', { name: 'Edit images 1' })
+ )
+ expect(screen.queryByTestId('workshop-filter-count')).toBeNull()
expect(cardNames()).toHaveLength(3)
})
- // A cross that cleared everything would pass a test that only ever set one
- // filter, so this one sets two and keeps the other.
- it('takes off the chip that was pressed and leaves the rest alone', async () => {
+ // Letting go of one choice must not take the others with it, which a test
+ // that only ever sets one would never catch.
+ it('lets go of one use case and leaves the rest alone', async () => {
const user = userEvent.setup()
render(WorkshopModelsGrid, { props: { models } })
@@ -211,23 +215,16 @@ describe('WorkshopModelsGrid', () => {
await user.click(
within(dialog).getByRole('button', { name: 'Generate videos 1' })
)
+ expect(screen.getByTestId('workshop-filter-count')).toHaveTextContent('2')
- await user.click(screen.getByRole('button', { name: 'Remove Edit images' }))
- expect(screen.getByTestId('workshop-filter-chips')).toHaveTextContent(
- 'Generate videos'
+ await user.click(
+ within(dialog).getByRole('button', { name: 'Edit images 1' })
)
+ expect(screen.getByTestId('workshop-filter-count')).toHaveTextContent('1')
expect(cardNames()).toEqual([expect.stringContaining('Kling AI')])
- // The pressed cross went with its chip; focus stays in the row.
- expect(
- screen.getByRole('button', { name: 'Remove Generate videos' })
- ).toHaveFocus()
-
- await user.click(screen.getByTestId('workshop-filter-chips-clear'))
- expect(screen.queryByTestId('workshop-filter-chips')).toBeNull()
- expect(screen.getByRole('button', { name: 'Use cases' })).toHaveFocus()
})
- it('replaces a browsed section with a use-case filter', async () => {
+ it('adds a menu choice to the shelf already open', async () => {
const user = userEvent.setup()
render(WorkshopModelsGrid, { props: { models } })
@@ -238,9 +235,54 @@ describe('WorkshopModelsGrid', () => {
within(dialog).getByRole('button', { name: 'Generate videos 1' })
)
+ expect(screen.getByTestId('workshop-filter-count')).toHaveTextContent('2')
+ expect(cardNames()).toHaveLength(2)
+ expect(cardNames()).toEqual(
+ expect.arrayContaining([expect.stringContaining('Kling AI')])
+ )
+ })
+
+ // Coming back from a model, a browser can restore this page from its cache
+ // with the shelf still open, so the reader lands on a narrowed catalogue the
+ // address does not name. Reported by Eric: back should reach all models.
+ it('starts from the address again when the browser restores the page', async () => {
+ const user = userEvent.setup()
+ render(WorkshopModelsGrid, { props: { models } })
+
+ await user.click(screen.getByRole('button', { name: 'Edit images' }))
+ expect(screen.getByTestId('workshop-filter-count')).toHaveTextContent('1')
+
+ // A different shelf in the address, so a handler that only emptied the
+ // selection would fail here rather than pass by coincidence.
+ history.replaceState(null, '', '/models/?useCase=generate-videos')
+ onTestFinished(() => history.replaceState(null, '', '/'))
+ const restored = new Event('pageshow')
+ Object.defineProperty(restored, 'persisted', { value: true })
+ window.dispatchEvent(restored)
+
+ await waitFor(() =>
+ expect(screen.getByRole('heading', { level: 1 })).toHaveTextContent(
+ 'Generate videos'
+ )
+ )
+ expect(screen.getByTestId('workshop-filter-count')).toHaveTextContent('1')
expect(cardNames()).toEqual([expect.stringContaining('Kling AI')])
})
+ // A first load is a pageshow too, and it must not throw away a shelf the
+ // visitor opened before the page had finished settling.
+ it('keeps the open shelf when the page was not restored', async () => {
+ const user = userEvent.setup()
+ render(WorkshopModelsGrid, { props: { models } })
+
+ await user.click(screen.getByRole('button', { name: 'Edit images' }))
+ window.dispatchEvent(new Event('pageshow'))
+
+ await waitFor(() =>
+ expect(screen.getByTestId('workshop-filter-count')).toHaveTextContent('1')
+ )
+ })
+
it('narrows the use-case menu with its search box', async () => {
const user = userEvent.setup()
render(WorkshopModelsGrid, { props: { models } })
@@ -273,48 +315,41 @@ describe('WorkshopModelsGrid', () => {
expect(cardNames()[0]).toContain('Flux')
})
- it.for([
- { studio: true, lead: ['Cinematic Studio'] },
- { studio: false, lead: [] }
- ])(
- 'keeps Flux 3 out of the featured models (studio flag $studio)',
- ({ studio, lead }) => {
- vi.mocked(useWorkshopAppsEnabled).mockReturnValue(computed(() => studio))
- const featured = [
- {
- slug: 'byteplus--seedance-2-fast-text-to-video--generate-videos',
- name: 'Seedance 2 Fast',
- rank: 32
- },
- {
- slug: 'bfl--flux-3-text-to-video--generate-videos',
- name: 'FLUX.3 Video',
- rank: 63
- },
- {
- slug: 'byteplus--seedream-5-pro--generate-images',
- name: 'Seedream 5 Pro',
- rank: 0
- }
- ].map(({ slug, name, rank }) => ({
- ...models[0],
- slug,
- name,
- href: `/models/${slug}/`,
- recommendedRank: rank,
- thumbnailUrl: `https://example.com/${rank}.webp`
- }))
-
- render(WorkshopModelsGrid, { props: { models: featured } })
-
- const pagination = screen.getByTestId('featured-pagination')
- expect(
- within(pagination)
- .getAllByRole('button')
- .map((button) => button.getAttribute('aria-label'))
- ).toEqual([...lead, 'Seedream 5 Pro', 'Seedance 2 Fast'])
- }
- )
+ it('keeps Flux 3 out of the featured models', () => {
+ const featured = [
+ {
+ slug: 'byteplus--seedance-2-fast-text-to-video--generate-videos',
+ name: 'Seedance 2 Fast',
+ rank: 32
+ },
+ {
+ slug: 'bfl--flux-3-text-to-video--generate-videos',
+ name: 'FLUX.3 Video',
+ rank: 63
+ },
+ {
+ slug: 'byteplus--seedream-5-pro--generate-images',
+ name: 'Seedream 5 Pro',
+ rank: 0
+ }
+ ].map(({ slug, name, rank }) => ({
+ ...models[0],
+ slug,
+ name,
+ href: `/models/${slug}/`,
+ recommendedRank: rank,
+ thumbnailUrl: `https://example.com/${rank}.webp`
+ }))
+
+ render(WorkshopModelsGrid, { props: { models: featured } })
+
+ const pagination = screen.getByTestId('featured-pagination')
+ expect(
+ within(pagination)
+ .getAllByRole('button')
+ .map((button) => button.getAttribute('aria-label'))
+ ).toEqual(['Seedream 5 Pro', 'Seedance 2 Fast'])
+ })
it('does not manufacture a return shelf before a model is opened', () => {
sessionStorage.setItem('comfy-models-shelf', 'generate-videos')
diff --git a/apps/website/src/components/workshop/WorkshopModelsGrid.vue b/apps/website/src/components/workshop/WorkshopModelsGrid.vue
index 1a3f62035c8..71aeda773d3 100644
--- a/apps/website/src/components/workshop/WorkshopModelsGrid.vue
+++ b/apps/website/src/components/workshop/WorkshopModelsGrid.vue
@@ -1,7 +1,14 @@