diff --git a/apps/website/e2e/workshop-workflows.spec.ts b/apps/website/e2e/workshop-workflows.spec.ts index e98f560b14c..da3451e84b0 100644 --- a/apps/website/e2e/workshop-workflows.spec.ts +++ b/apps/website/e2e/workshop-workflows.spec.ts @@ -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() diff --git a/apps/website/src/components/workshop/WorkflowPage.test.ts b/apps/website/src/components/workshop/WorkflowPage.test.ts new file mode 100644 index 00000000000..8fd425853ce --- /dev/null +++ b/apps/website/src/components/workshop/WorkflowPage.test.ts @@ -0,0 +1,47 @@ +import { render, screen } from '@testing-library/vue' +import { assert, describe, expect, it } from 'vitest' + +import { workflowDetailsBySlug } from '../../config/workshop-workflow-content' +import WorkflowPage from './WorkflowPage.vue' + +const model = workflowDetailsBySlug.get('workflows/remove-background') +assert(model) + +// Who made the workflow stands over its name, and the shelf it sits on is the +// one thing up there that leads somewhere. +describe('WorkflowPage header', () => { + it('sends the shelf it names to that shelf, filtered', () => { + render(WorkflowPage, { props: { model } }) + + const shelf = screen.getByTestId('workflow-use-case') + expect(shelf.textContent.trim()).toBe('Edit images') + expect(shelf.getAttribute('href')).toBe('/models?useCase=edit-images') + }) + + it('says nothing about a shelf a workflow has none of', () => { + render(WorkflowPage, { + props: { + model: { + ...model, + useCases: [], + task: undefined, + modality: undefined + } + } + }) + + expect(screen.queryByTestId('workflow-use-case')).toBeNull() + }) + + it.for([ + { author: 'ComfyUI', authors: 1 }, + { author: undefined, authors: 0 } + ] as const)('names $authors author(s)', ({ author, authors }) => { + render(WorkflowPage, { props: { model: { ...model, author } } }) + + const named = screen.queryAllByTestId('workflow-author') + expect(named).toHaveLength(authors) + if (author) expect(named[0]).toHaveTextContent(author) + expect(screen.getByTestId('workflow-use-case')).toBeTruthy() + }) +}) diff --git a/apps/website/src/components/workshop/WorkflowPage.vue b/apps/website/src/components/workshop/WorkflowPage.vue index bbf8643afca..57487a08dfa 100644 --- a/apps/website/src/components/workshop/WorkflowPage.vue +++ b/apps/website/src/components/workshop/WorkflowPage.vue @@ -3,8 +3,11 @@ import { ChevronLeft } from '@lucide/vue' import { computed } from 'vue' import type { WorkflowWorkshopModelDetail } from '../../config/models-catalogue' +import { catalogSearch, useCaseFor } from '../../config/models-catalogue' +import { getRoutes } from '../../config/routes' import { WORKSHOP_CLOUD_BASE_URL } from '../../config/workshop-env' import { useWorkshopSession } from '../../config/workshop-session-state' +import { useCaseLabelKey } from '../../lib/workshop/use-case-label' import { t } from '../../i18n/translations' import WorkflowPlayground from './WorkflowPlayground.vue' @@ -16,6 +19,24 @@ const scope = computed(() => ? JSON.stringify([session.value.uid, session.value.workspace.id]) : 'anonymous' ) +const routes = getRoutes() + +// The one thing the eyebrow can lead somewhere: the shelf this workflow sits +// on. It was a word before, and a word is not a way back. +const shelf = computed(() => { + const useCase = useCaseFor(model) + return useCase + ? { + label: useCaseLabelKey[useCase], + href: `${routes.workshop}${catalogSearch({ useCase })}` + } + : undefined +}) +const eyebrowClass = + 'text-sm leading-none font-medium tracking-widest text-primary-comfy-yellow uppercase' +const pillClass = + 'inline-flex h-7 items-center rounded-full border border-transparency-white-t20 px-3 text-xs leading-none text-primary-comfy-canvas transition-colors hover:border-primary-comfy-yellow hover:text-primary-comfy-yellow' + const template = model.workflow.template const cloudHref = template ? `${WORKSHOP_CLOUD_BASE_URL}/?template=${encodeURIComponent(template.id)}` @@ -32,9 +53,22 @@ const cloudHref = template {{ t('workshop.catalogue.backToWorkflows') }}
-

- {{ model.categoryLabel?.en ?? model.category }} -

+
+

+ {{ model.author }} +

+ {{ t(shelf.label) }} +

@@ -46,25 +80,6 @@ const cloudHref = template > {{ model.summary }}

-
- {{ name }} - - {{ - t('workshop.workflow.templateBy').replace( - '{author}', - template.author - ) - }} - -