diff --git a/apps/website/e2e/models-catalogue-corrections.spec.ts b/apps/website/e2e/models-catalogue-corrections.spec.ts index bedc5e64cb9..946fd63b80b 100644 --- a/apps/website/e2e/models-catalogue-corrections.spec.ts +++ b/apps/website/e2e/models-catalogue-corrections.spec.ts @@ -69,6 +69,9 @@ test('GPT Image generation pages remain discoverable while disabled edit pages a .getByTestId('workshop-models-grid') .getByTestId('workshop-model-card') await expect(cards).toHaveCount(5) + const card = cards.first() + await expect(card).toHaveAccessibleName(/GPT Image/) + await expect(card.getByRole('img', { name: /GPT Image/ })).toHaveCount(0) await page.getByRole('link', { name: /GPT Image 1\.5/ }).click() await expect(page).toHaveURL( /\/models\/openai--gpt-image-1\.5--edit-images\/$/ diff --git a/apps/website/e2e/models-performance.spec.ts b/apps/website/e2e/models-performance.spec.ts index 5c7f1681f71..f2fe8bf0b47 100644 --- a/apps/website/e2e/models-performance.spec.ts +++ b/apps/website/e2e/models-performance.spec.ts @@ -53,7 +53,7 @@ test('catalogue browsing stays within its JavaScript budget', async ({ // a chunk the homepage also loads would pass the delta and still be paid // for by every visitor to /models/. const totalBytes = scripts.reduce((total, [, bytes]) => total + bytes, 0) - expect(totalBytes).toBeLessThan(1_815_000) + expect(totalBytes).toBeLessThan(1_820_000) }) test('video cards load on screen and stop playing when scrolled away', async ({ diff --git a/apps/website/e2e/workshop-apps.spec.ts b/apps/website/e2e/workshop-apps.spec.ts index 3e7b73b2279..5a061fbcdd9 100644 --- a/apps/website/e2e/workshop-apps.spec.ts +++ b/apps/website/e2e/workshop-apps.spec.ts @@ -36,7 +36,7 @@ test('opens Cinematic Studio on the apps flag alone', async ({ ) }) -test('keeps Cinematic Studio closed when only the workflows flag is on', async ({ +test('opens Cinematic Studio on the workflows flag alone', async ({ page, context }) => { @@ -52,13 +52,17 @@ test('lists both apps in the catalogue Apps tab, on /models/apps/ pages', async }) => { await mockFlags(context, { apps: true, workflows: false }) await page.goto('/models/?type=apps') - const cards = page.getByTestId('apps-list').getByTestId('workshop-model-card') + const shelf = page.getByTestId('app-shelf') + const cards = shelf.getByRole('link') await expect(cards).toHaveCount(2) await expect(cards.nth(0)).toHaveAttribute( 'href', '/models/apps/cinematic-studio/' ) await expect(cards.nth(1)).toHaveAttribute('href', '/models/apps/reshoot/') + await expect( + page.getByRole('button', { name: /Browse all apps/ }) + ).toHaveCount(0) }) test('sends the old studio address to the app page it named', async ({ diff --git a/apps/website/e2e/workshop-workflow-runs.spec.ts b/apps/website/e2e/workshop-workflow-runs.spec.ts index 7b5f13ad915..0715c4d2991 100644 --- a/apps/website/e2e/workshop-workflow-runs.spec.ts +++ b/apps/website/e2e/workshop-workflow-runs.spec.ts @@ -22,6 +22,7 @@ const image = readFileSync('e2e/assets/placeholder-1x1.webp') async function setup(context: BrowserContext) { let enabled = true let generation = 0 + let reachable = true await context.route('https://apis.google.com/js/api.js*', (route) => route.abort('blockedbyclient') ) @@ -93,6 +94,7 @@ async function setup(context: BrowserContext) { const request = route.request() const url = new URL(request.url()) const method = request.method() + if (!reachable) return route.abort('failed') commands.push({ method, path: url.pathname, @@ -115,6 +117,9 @@ async function setup(context: BrowserContext) { disable() { enabled = false }, + drop() { + reachable = false + }, cancel() { current = { ...current, status: 'cancelled', update_time: Date.now() } } @@ -143,7 +148,7 @@ async function signInAndRun( page.getByRole('button', { name: 'Replace photo.webp' }) ).toBeVisible() await page.getByTestId('workflow-run').click() - await expect(page.getByTestId('workflow-run')).toHaveText('Queued') + await expect(page.getByTestId('workflow-run')).toHaveText('Waiting its turn') } test('Cloud upload, refresh, partial delivery and downloads retain one run @mobile', async ({ @@ -165,25 +170,28 @@ test('Cloud upload, refresh, partial delivery and downloads retain one run @mobi }) await page.reload() - await expect(page.getByTestId('workflow-run')).toHaveText('Queued') + await expect(page.getByTestId('workflow-run')).toHaveText('Waiting its turn') expect(cloud.uploads).toHaveLength(1) expect(submissions()).toHaveLength(1) await page.getByRole('tab', { name: 'API', exact: true }).click() + // The address a run is posted to, before the snippet that posts to it. + await expect(page.getByTestId('workflow-api-endpoint')).toContainText( + '/api/prompt' + ) + await expect( + page.getByRole('link', { name: 'API documentation' }) + ).toBeVisible() const snippet = await page.getByTestId('workflow-api-snippet').textContent() expect(snippet).toContain('/api/prompt') expect(snippet).toContain('X-API-Key:') await page.setViewportSize({ width: 320, height: 851 }) - await page.getByRole('tab', { name: 'Workflow', exact: true }).click() + await page.getByRole('tab', { name: 'Details', exact: true }).click() await expect( - page.getByRole('img', { name: 'Workflow', exact: true }) + page.getByRole('img', { name: /nodes of this workflow/i }) ).toBeVisible() const panelRight = await page - .getByRole('tabpanel', { name: 'Workflow', exact: true }) - .evaluate( - (panel) => - panel.getBoundingClientRect().right - - parseFloat(getComputedStyle(panel).paddingRight) - ) + .getByRole('tabpanel', { name: 'Details', exact: true }) + .evaluate((panel) => panel.getBoundingClientRect().right) const downloadRight = await page .getByRole('link', { name: 'Download workflow JSON' }) .evaluate((link) => link.getBoundingClientRect().right) @@ -303,13 +311,10 @@ test('workflow cancellation survives disabled admission and hides on sign-out', await page.clock.fastForward(2100) await expect(page.getByTestId('playground-output')).toHaveAttribute( 'data-state', - 'idle' + 'cancelled' ) await expect( - page.getByText( - 'Cancellation requested. Check Cloud for the final job status.', - { exact: true } - ) + page.getByText('This run was cancelled before it finished.').first() ).toBeVisible() await expect(page.getByTestId('workflow-run')).toBeDisabled() await page.locator('[data-testid="header-account"]:visible').click() @@ -321,3 +326,31 @@ test('workflow cancellation survives disabled admission and hides on sign-out', ) ).toHaveLength(1) }) + +test('a run the page stops hearing about holds the panel still', async ({ + page, + context, + modelsAccount +}) => { + const cloud = await setup(context) + await signInAndRun(page, modelsAccount) + const panel = page.getByTestId('playground-output') + const run = page.getByTestId('workflow-run') + await expect(panel).toHaveAttribute('data-state', 'running') + await expect(panel.getByTestId('run-spinner')).toBeVisible() + await expect(panel.getByTestId('run-elapsed')).toBeVisible() + await expect(run.getByTestId('run-button-spinner')).toBeVisible() + + cloud.drop() + await page.clock.fastForward(2100) + + await expect(panel.getByRole('status')).toHaveText('Connection interrupted') + await expect(panel).toHaveAttribute('data-state', 'running') + await expect(panel.getByTestId('run-spinner')).toHaveCount(0) + await expect(panel.getByTestId('run-elapsed')).toHaveCount(0) + await expect(run).toHaveText('Connection interrupted') + await expect(run.getByTestId('run-button-spinner')).toHaveCount(0) + await expect( + page.getByRole('button', { name: 'Reconnect to this run' }) + ).toBeVisible() +}) diff --git a/apps/website/e2e/workshop-workflows.spec.ts b/apps/website/e2e/workshop-workflows.spec.ts index e98f560b14c..dcea8aca41e 100644 --- a/apps/website/e2e/workshop-workflows.spec.ts +++ b/apps/website/e2e/workshop-workflows.spec.ts @@ -66,7 +66,7 @@ test('workflow launch groups lead to the existing shared form', async ({ 'href', '/models/workflows/change-material/' ) - await page.getByTestId('browse-all').click() + await page.getByTestId('browse-all-end').click() await expect(page.getByRole('heading', { level: 1 })).toHaveText( 'All workflows 30' ) @@ -88,6 +88,10 @@ test('workflow launch groups lead to the existing shared form', async ({ await expect( page.getByRole('heading', { name: 'Change a material', exact: true }) ).toBeVisible() + // The eyebrow names the shelf this workflow sits on, and leads back to it. + const shelf = page.getByTestId('workflow-use-case') + await expect(shelf).toHaveText('Edit images') + await expect(shelf).toHaveAttribute('href', '/models?useCase=edit-images') await expect( page.getByRole('group', { name: 'Your original image' }) ).toBeVisible() @@ -104,13 +108,13 @@ test('workflow launch groups lead to the existing shared form', async ({ .click() await page.getByTestId('example-replace-keep').click() await expect(prompt).toHaveValue('Use the material from the second image.') + await page.getByRole('tab', { name: 'Details', exact: true }).click() await expect( page.getByRole('link', { name: 'Try in Cloud' }) ).toHaveAttribute( 'href', 'https://testcloud.comfy.org/?template=image_qwen_image_edit_2511' ) - await page.getByRole('tab', { name: 'Workflow', exact: true }).click() const graphFiles = [ { link: page.getByRole('link', { name: 'Open full-size workflow preview' }), diff --git a/apps/website/e2e/workshop.spec.ts b/apps/website/e2e/workshop.spec.ts index 57168f7c272..16d01a859a5 100644 --- a/apps/website/e2e/workshop.spec.ts +++ b/apps/website/e2e/workshop.spec.ts @@ -243,9 +243,35 @@ test.describe('Models catalog', () => { await expect(page.getByTestId('workshop-hero')).toBeVisible() }) + // A row loads eight whatever its total says, so a row holding fewer than + // eight cards is showing its whole shelf and has nothing left to open. + test('a shelf showing everything stops promising more', async ({ page }) => { + await page.goto('/models/') + const sections = page.getByTestId('workshop-sections') + await expect(sections).toBeVisible() + await expect( + sections.getByTestId('workshop-model-card').first() + ).toBeVisible() + const shelves = sections + .locator('[data-testid^="section-"]') + .filter({ has: page.getByTestId('workshop-model-card') }) + const count = await shelves.count() + expect(count).toBeGreaterThan(1) + + let complete = 0 + for (let index = 0; index < count; index++) { + const shelf = shelves.nth(index) + if ((await shelf.getByTestId('workshop-model-card').count()) >= 8) + continue + complete++ + await expect(shelf.locator('[data-testid$="-see-all"]')).toHaveCount(0) + } + expect(complete).toBeGreaterThan(0) + }) + test('the rows listing opens the whole catalogue', async ({ page }) => { await page.goto('/models/') - await page.getByTestId('browse-all').click() + await page.getByTestId('browse-all-end').click() await expect(page.getByTestId('workshop-sections')).toHaveCount(0) const heading = page.getByRole('heading', { level: 1 }) diff --git a/apps/website/src/components/common/VideoPlayer.test.ts b/apps/website/src/components/common/VideoPlayer.test.ts index 020c599c024..68fa13ae893 100644 --- a/apps/website/src/components/common/VideoPlayer.test.ts +++ b/apps/website/src/components/common/VideoPlayer.test.ts @@ -1,5 +1,6 @@ import { render, screen } from '@testing-library/vue' -import { describe, expect, it, vi } from 'vitest' +import { describe, expect, it, onTestFinished, vi } from 'vitest' +import { nextTick } from 'vue' import VideoPlayer from './VideoPlayer.vue' @@ -96,6 +97,47 @@ describe('VideoPlayer', () => { } ) + // A pointer that hovers keeps the bar up for as long as it rests on the + // player. A finger cannot: the window after playback starts is the whole of + // the bar's visit, and 800ms was long enough to see the controls and too + // short to hit one. + it.for([ + { hover: true, after: 1000, reachable: false }, + { hover: false, after: 1000, reachable: true }, + { hover: false, after: 5000, reachable: false } + ])( + 'leaves the bar reachable $reachable $after ms into playback (hover: $hover)', + async ({ hover, after, reachable }) => { + vi.stubGlobal('matchMedia', (query: string) => ({ + matches: query === '(hover: hover)' ? hover : false, + media: query, + addEventListener: () => {}, + removeEventListener: () => {} + })) + vi.useFakeTimers() + onTestFinished(() => { + vi.useRealTimers() + }) + vi.spyOn(HTMLMediaElement.prototype, 'paused', 'get').mockReturnValue( + false + ) + render(VideoPlayer, { + props: { src: 'https://example.com/clip.mp4', controlsOnHover: true } + }) + + // Playback starting is what summons the bar, and the only thing that does + // on a device with no pointer to rest here. + await vi.waitFor(() => + expect(screen.getByRole('button', { name: 'Pause' })).toBeTruthy() + ) + vi.advanceTimersByTime(after) + await nextTick() + + const bar = screen.getByTestId('player-control-bar') + expect(bar.className.includes('pointer-events-none')).toBe(!reachable) + } + ) + it('shows play and mute for a paused, unmuted video', async () => { render(VideoPlayer, { props: { src: 'https://example.com/clip.mp4', muteOnly: true } diff --git a/apps/website/src/components/common/VideoPlayer.vue b/apps/website/src/components/common/VideoPlayer.vue index a23a91873fd..4071dc76a6a 100644 --- a/apps/website/src/components/common/VideoPlayer.vue +++ b/apps/website/src/components/common/VideoPlayer.vue @@ -7,6 +7,7 @@ import { useFocusWithin, useFullscreen, useMediaControls, + useMediaQuery, useMouseInElement, whenever } from '@vueuse/core' @@ -119,7 +120,12 @@ watch( // Controls fade const hovering = useElementHover(playerEl) const { focused } = useFocusWithin(playerEl) -const recentActivity = refAutoReset(false, 800) +// A pointer that hovers keeps the bar up for as long as it rests here, so the +// window after it moves can be short. A finger cannot hover: the tap that +// summoned the bar is the whole of its visit, and 800ms was long enough to see +// the controls and too short to hit one. +const canHover = useMediaQuery('(hover: hover)') +const recentActivity = refAutoReset(false, () => (canHover.value ? 800 : 4000)) const controlsVisible = computed( () => @@ -379,6 +385,7 @@ function toggleFullscreen() {
+import { ref } from 'vue' + +import type { DiscoveryProvider } from '../../data/modelDiscovery' +import StaticFrame from '../workshop/StaticFrame.vue' + +const { provider } = defineProps<{ provider: DiscoveryProvider }>() + +// The preview is fetched the first time this card is pointed at or focused, so +// a looping row of them costs nothing until someone shows interest in one. +const revealed = ref(false) + + + diff --git a/apps/website/src/components/home/DiscoveryWorkflowCard.vue b/apps/website/src/components/home/DiscoveryWorkflowCard.vue new file mode 100644 index 00000000000..5a8e1133eac --- /dev/null +++ b/apps/website/src/components/home/DiscoveryWorkflowCard.vue @@ -0,0 +1,26 @@ + + + diff --git a/apps/website/src/components/home/ModelDiscoverySection.test.ts b/apps/website/src/components/home/ModelDiscoverySection.test.ts index a885a3bdc55..ef28868c8af 100644 --- a/apps/website/src/components/home/ModelDiscoverySection.test.ts +++ b/apps/website/src/components/home/ModelDiscoverySection.test.ts @@ -5,10 +5,14 @@ import { readonly, ref, nextTick } from 'vue' import type { Ref } from 'vue' import { discoveryProviders } from '../../data/modelDiscovery' -import type { DiscoveryProvider } from '../../data/modelDiscovery' +import type { + DiscoveryProvider, + DiscoveryWorkflow +} from '../../data/modelDiscovery' import { useWorkshopEnabled, - useWorkshopEnabledSettled + useWorkshopEnabledSettled, + useWorkshopWorkflowsEnabled } from '../../scripts/posthog' import ModelDiscoverySection from './ModelDiscoverySection.vue' @@ -16,12 +20,17 @@ vi.mock(import('../../scripts/posthog')) let enabled: Ref let settled: Ref +let workflowsEnabled: Ref beforeEach(() => { enabled = ref(true) vi.mocked(useWorkshopEnabled).mockReturnValue(readonly(enabled)) settled = ref(true) vi.mocked(useWorkshopEnabledSettled).mockReturnValue(readonly(settled)) + workflowsEnabled = ref(true) + vi.mocked(useWorkshopWorkflowsEnabled).mockReturnValue( + readonly(workflowsEnabled) + ) }) const providers: readonly DiscoveryProvider[] = [ @@ -33,6 +42,14 @@ const providers: readonly DiscoveryProvider[] = [ } ] +const workflows: readonly DiscoveryWorkflow[] = [ + { + name: 'Turn a sketch into a render', + href: '/models/workflows/sketch/', + thumbnailUrl: '/fixture-workflow.png' + } +] + describe('ModelDiscoverySection', async () => { it('keeps discovery unavailable until enabled and hides it on revocation', async () => { enabled.value = false @@ -107,6 +124,88 @@ describe('ModelDiscoverySection', async () => { expect(screen.getAllByTestId('static-frame').length).toBeGreaterThan(0) }) + // The tab is a promise that the other half exists. Where the catalogue does + // not offer it, neither does the home page. + it.for([ + { when: 'the flag is off', flag: false, rows: workflows }, + { when: 'there are no workflows', flag: true, rows: [] } + ])('offers no second tab when $when', async ({ flag, rows }) => { + workflowsEnabled.value = flag + render(ModelDiscoverySection, { + props: { providers, workflows: rows } + }) + await nextTick() + + expect(screen.queryByTestId('catalogue-tabs')).toBeNull() + expect(screen.getByRole('link', { name: 'Browse all models' })).toBeTruthy() + }) + + it('swaps the row and the way out when the workflows tab is pressed', async () => { + const user = userEvent.setup() + render(ModelDiscoverySection, { props: { providers, workflows } }) + await nextTick() + + expect( + screen.getByRole('link', { name: /Fixture Studio & Co/ }) + ).toBeTruthy() + + await user.click(screen.getByTestId('catalogue-tab-workflows')) + expect( + screen.queryByRole('link', { name: /Fixture Studio & Co/ }) + ).toBeNull() + expect( + screen.getByRole('link', { name: /Turn a sketch into a render/ }) + ).toHaveAttribute('href', '/models/workflows/sketch/') + expect( + screen.getByRole('link', { name: 'Browse all workflows' }) + ).toHaveAttribute('href', '/models?type=workflows') + }) + + // Both rows cross the screen at one pace, so switching tabs does not speed + // the marquee up or slow it down under the reader. + it('paces both rows by the card, not by the row', async () => { + const user = userEvent.setup() + const pace = () => + screen + .getAllByTestId('discovery-marquee') + .map((copy) => copy.style.animationDuration) + + render(ModelDiscoverySection, { + props: { + providers: [providers[0], { ...providers[0], name: 'Second Studio' }], + workflows: [ + workflows[0], + { ...workflows[0], name: 'Second flow' }, + { ...workflows[0], name: 'Third flow' } + ] + } + }) + await nextTick() + expect(pace()).toEqual(['6s', '6s']) + + await user.click(screen.getByTestId('catalogue-tab-workflows')) + expect(pace()).toEqual(['9s', '9s']) + }) + + it('starts the arriving row at its beginning, not mid-stride', async () => { + const user = userEvent.setup() + render(ModelDiscoverySection, { props: { providers, workflows } }) + await nextTick() + + const [copy] = screen.getAllByTestId('discovery-marquee') + const animation = copy.animate([{ transform: 'none' }], { + duration: 6000, + iterations: Infinity + }) + animation.pause() + animation.currentTime = 2000 + expect(animation.currentTime).toBe(2000) + + await user.click(screen.getByTestId('catalogue-tab-workflows')) + + expect(animation.currentTime).toBe(0) + }) + it('localizes copy while keeping the English-only Workshop route', async () => { render(ModelDiscoverySection, { props: { locale: 'zh-CN', providers } diff --git a/apps/website/src/components/home/ModelDiscoverySection.vue b/apps/website/src/components/home/ModelDiscoverySection.vue index 84d17fb537d..8dbe0319794 100644 --- a/apps/website/src/components/home/ModelDiscoverySection.vue +++ b/apps/website/src/components/home/ModelDiscoverySection.vue @@ -1,27 +1,80 @@ + + diff --git a/apps/website/src/components/workshop/CatalogueTabs.vue b/apps/website/src/components/workshop/CatalogueTabs.vue index 21ae4ea39d9..1bcf39b1cf4 100644 --- a/apps/website/src/components/workshop/CatalogueTabs.vue +++ b/apps/website/src/components/workshop/CatalogueTabs.vue @@ -9,13 +9,14 @@ import { t } from '../../i18n/translations' export type CatalogueTab = 'models' | 'workflows' | 'apps' const { - tabs = ['models', 'workflows', 'apps'], locale = 'en', - focusActive = false + focusActive = false, + tabs = ['models', 'workflows', 'apps'] } = defineProps<{ - tabs?: readonly CatalogueTab[] locale?: Locale focusActive?: boolean + /** The home page teaches the same control with the halves it can open. */ + tabs?: readonly CatalogueTab[] }>() const emit = defineEmits<{ focused: [] }>() const active = defineModel({ required: true }) @@ -33,6 +34,9 @@ onMounted(() => { const marker = computed( () => `translateX(${tabs.indexOf(active.value) * 100}%)` ) +const columns = computed(() => + tabs.length === 2 ? 'grid-cols-2' : 'grid-cols-3' +)