Skip to content
40 changes: 40 additions & 0 deletions apps/website/e2e/workshop-api-actions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,43 @@ test('the workflow API tab opens with the key action and what it needs beside th
expect(action.y).toBeLessThanOrEqual(code.y)
expect(action.x).toBeGreaterThanOrEqual(code.x + code.width)
})

test('@mobile the workflow example output is as tall as its 16:9 media', async ({
page,
context
}) => {
await allowWorkflows(context)
await page.goto(WORKFLOW_PATH)

const output = page.getByTestId('playground-output')
await expect(output).toHaveAttribute('data-state', 'example')
const media = await frame(output.getByTestId('output-media'))
expect(media.height).toBeCloseTo((media.width * 9) / 16, 0)
})

test('@mobile opens a source picture full screen with its close button clear of it', async ({
page,
context
}) => {
await allowWorkflows(context)
await page.goto(WORKFLOW_PATH)
await page
.locator('input[type=file]')
.first()
.setInputFiles('public/images/cinematic-studio/diner.jpg')
await page
.getByRole('button', { name: /^Expand / })
.first()
.click()

const dialog = page.getByTestId('image-source-dialog')
const viewportWidth = page.viewportSize()?.width ?? 0
await expect
.poll(async () => (await frame(dialog)).width)
.toBeGreaterThan(viewportWidth - 2)
const [close, picture] = await Promise.all([
frame(dialog.getByRole('button', { name: 'Close' })),
frame(dialog.getByRole('img'))
])
expect(close.y + close.height).toBeLessThanOrEqual(picture.y)
})
45 changes: 45 additions & 0 deletions apps/website/e2e/workshop-apps.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,48 @@ test('sends the old studio address to the app page it named', async ({
await page.goto('/cinematic-studio/?app=reshoot&ux=d&model=flux')
await expect(page).toHaveURL(/\/models\/apps\/reshoot\/\?ux=d&model=flux$/)
})

test('@mobile keeps the Re-shoot aim badges to one line on a phone', async ({
page,
context
}) => {
await mockFlags(context, { apps: true, workflows: false })
await page.goto('/models/apps/reshoot/')
await page.getByText('Sci-fi pilot').first().click()

const viewport = page.getByTestId('reshoot-viewport').first()
await expect(
viewport.getByText('Drag to orbit', { exact: true })
).toBeVisible()
await expect(viewport.getByText(/Scroll to move closer/)).toBeHidden()

for (const badge of [
viewport.getByTestId('reshoot-drag-hint'),
viewport.getByTestId('reshoot-angle-readout')
]) {
const box = await badge.boundingBox()
expect(box?.height).toBeLessThan(40)
}
})

test('@mobile pins the Re-shoot preview while the camera controls scroll under it', async ({
page,
context
}) => {
await mockFlags(context, { apps: true, workflows: false })
await page.goto('/models/apps/reshoot/')
await page.getByText('Sci-fi pilot').first().click()

const frame = page.getByTestId('reshoot-frame')
const distance = page.getByRole('slider', { name: /Distance/ })
await page.getByTestId('reshoot-action').scrollIntoViewIfNeeded()
const pinned = await frame.boundingBox()
expect(pinned?.y).toBeGreaterThanOrEqual(0)
expect(pinned?.y).toBeLessThan(120)

const before = Number(await distance.inputValue())
await page.getByRole('button', { name: 'Move the camera closer' }).tap()
await expect
.poll(async () => Number(await distance.inputValue()))
.toBeLessThan(before)
})
Comment thread
mariana953 marked this conversation as resolved.
Resolved
37 changes: 37 additions & 0 deletions apps/website/e2e/workshop-workflows.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -513,3 +513,40 @@ test('keeps the workflow form inside a phone screen @mobile', async ({
const box = await footer.boundingBox()
expect((box?.x ?? 0) + (box?.width ?? 0)).toBeLessThanOrEqual(viewportWidth)
})

test('@mobile keeps the catalogue tabs in place when a tab changes the hero subtitle', async ({
page,
context
}) => {
await mockWorkflowVisibility(context, true)
await page.goto('/models/')
const models = page.getByTestId('catalogue-tab-models')
const workflows = page.getByTestId('catalogue-tab-workflows')
await expect(workflows).toBeVisible()
const before = await workflows.boundingBox()

await workflows.click()
await expect(workflows).toHaveAttribute('aria-pressed', 'true')
expect((await workflows.boundingBox())?.y).toBeCloseTo(before?.y ?? 0, 0)

await models.click()
await expect(models).toHaveAttribute('aria-pressed', 'true')
expect((await models.boundingBox())?.y).toBeCloseTo(before?.y ?? 0, 0)
})

test('@mobile stretches the catalogue tabs across the toolbar on a phone', async ({
page,
context
}) => {
await mockWorkflowVisibility(context, true)
await page.goto('/models/')
const toolbar = page.getByTestId('workshop-toolbar')
const tabs = toolbar.getByTestId('catalogue-tabs')
await expect(tabs).toBeVisible()

const [bar, group] = await Promise.all([
toolbar.boundingBox(),
tabs.boundingBox()
])
expect(Math.abs((bar?.width ?? 0) - (group?.width ?? 0))).toBeLessThan(12)
})
2 changes: 1 addition & 1 deletion apps/website/src/components/workshop/CatalogueTabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const columns = computed(() =>
<div
:class="
cn(
'relative grid w-fit shrink-0 rounded-2xl bg-transparency-white-t8 p-1',
'relative grid w-fit shrink-0 rounded-2xl bg-transparency-white-t8 p-1 max-sm:w-full',
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
columns
)
"
Expand Down
16 changes: 16 additions & 0 deletions apps/website/src/components/workshop/ImageSourcePreview.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,22 @@ describe('image source previews', () => {
)
})

it('closes when the reader taps the space around the picture', async () => {
const user = userEvent.setup()
render(ImageSourcePreview, {
props: { name: 'Source image', src: 'https://example.com/image.png' }
})
await user.click(
screen.getByRole('button', { name: 'Expand Source image' })
)

await user.click(await screen.findByTestId('image-source-dialog'))

await waitFor(() =>
expect(screen.queryByTestId('image-source-dialog')).toBeNull()
)
})

it('does not emit a server-owned Blob URL into the page HTML', async () => {
const create = vi.spyOn(URL, 'createObjectURL')
const html = await renderToString(
Expand Down
11 changes: 5 additions & 6 deletions apps/website/src/components/workshop/ImageSourcePreview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import type { SourcePreviewProps } from '../../composables/useSourceUrl'
import { useSourceUrl } from '../../composables/useSourceUrl'
import { t } from '../../i18n/translations'
import Dialog from '../ui/dialog/Dialog.vue'
import DialogContent from '../ui/dialog/DialogContent.vue'
import DialogTitle from '../ui/dialog/DialogTitle.vue'
import DialogTrigger from '../ui/dialog/DialogTrigger.vue'
import SourceLightbox from './SourceLightbox.vue'

const { file, src, name, locale = 'en' } = defineProps<SourcePreviewProps>()

Expand Down Expand Up @@ -44,21 +44,20 @@ const expandLabel = computed(
</button>
</DialogTrigger>

<DialogContent
<SourceLightbox
:close-label="t('workshop.output.collapse', locale)"
:aria-describedby="undefined"
class="sm:max-w-5xl"
data-testid="image-source-dialog"
@dismiss="expanded = false"
>
<DialogTitle class="sr-only">{{ name }}</DialogTitle>
<img
:key="source"
:src="source"
:alt="name"
referrerpolicy="no-referrer"
class="max-h-dvh w-full rounded-2xl bg-black object-contain"
class="max-h-full max-w-full rounded-2xl bg-black object-contain"
/>
</DialogContent>
</SourceLightbox>
</Dialog>
<span
v-else-if="source"
Expand Down
1 change: 1 addition & 0 deletions apps/website/src/components/workshop/ModelsCatalogue.vue
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ watch(
:eyebrow="t('workshop.catalogue.eyebrow', locale)"
:heading="t('workshop.hero.heading', locale)"
:subtitle="t(heroSubtitle[activeTab], locale)"
:subtitle-space="availableTabs.map((tab) => t(heroSubtitle[tab], locale))"
/>
<WorkshopModelsGrid
v-if="activeTab === 'models'"
Expand Down
15 changes: 15 additions & 0 deletions apps/website/src/components/workshop/PlaygroundOutput.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,21 @@ const succeeded = (out: RunOutput, nsfw = false): RunState => ({
})

describe('PlaygroundOutput', () => {
it('reserves a minimum height only until there is media to size the panel', async () => {
const { rerender } = render(PlaygroundOutput, {
props: {
modelName: 'Workflow',
now: 3000,
state: { status: 'running', startedAt: 1000, label: 'Queued' }
}
})
const panel = screen.getByTestId('playground-output')
expect(panel).toHaveClass('min-h-96')

await rerender({ state: succeeded(output('latest')) })
expect(panel).not.toHaveClass('min-h-96')
})

it('uses a signed download without buffering media and refreshes an expired link', async () => {
const user = userEvent.setup()
const media = {
Expand Down
8 changes: 7 additions & 1 deletion apps/website/src/components/workshop/PlaygroundOutput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,12 @@

<template>
<section
class="flex min-h-96 flex-col overflow-hidden rounded-2xl border border-transparency-white-t8 bg-transparency-white-t4"
:class="
cn(

Check failure on line 294 in apps/website/src/components/workshop/PlaygroundOutput.vue

View workflow job for this annotation

GitHub Actions / fallow

High complexity (critical)

Function '<template>' exceeds both complexity thresholds: • Severity: critical • Cyclomatic: 69 (threshold: 20) • Cognitive: 115 (threshold: 15) • Lines: 728 Consider splitting this function into smaller, focused functions.
'flex flex-col overflow-hidden rounded-2xl border border-transparency-white-t8 bg-transparency-white-t4',
!shown && 'min-h-96'
Comment thread
mariana953 marked this conversation as resolved.
Resolved
)
"
data-testid="playground-output"
:data-state="state.status"
>
Expand Down Expand Up @@ -451,6 +456,7 @@
<template v-else-if="shown">
<div
class="relative aspect-video max-h-[70dvh] w-full flex-1 overflow-hidden bg-black/20"
data-testid="output-media"
>
<div
:key="currentUrl"
Expand Down
17 changes: 17 additions & 0 deletions apps/website/src/components/workshop/SourceLightbox.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<script setup lang="ts">
import DialogContent from '../ui/dialog/DialogContent.vue'

const { closeLabel } = defineProps<{ closeLabel: string }>()
const emit = defineEmits<{ dismiss: [] }>()
</script>

<template>
<DialogContent
:close-label="closeLabel"
:aria-describedby="undefined"
class="inset-0 top-0 left-0 flex h-dvh max-h-dvh w-full translate-0 items-center justify-center rounded-none border-0 bg-primary-comfy-ink/90 p-6 backdrop-blur-sm sm:max-w-none sm:p-6 lg:p-12"
@click.self="emit('dismiss')"
>
<slot />
</DialogContent>
</template>
11 changes: 5 additions & 6 deletions apps/website/src/components/workshop/VideoSourcePreview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import type { SourcePreviewProps } from '../../composables/useSourceUrl'
import { useSourceUrl } from '../../composables/useSourceUrl'
import { t } from '../../i18n/translations'
import Dialog from '../ui/dialog/Dialog.vue'
import DialogContent from '../ui/dialog/DialogContent.vue'
import DialogTitle from '../ui/dialog/DialogTitle.vue'
import DialogTrigger from '../ui/dialog/DialogTrigger.vue'
import SourceLightbox from './SourceLightbox.vue'

const { file, src, name, locale = 'en' } = defineProps<SourcePreviewProps>()

Expand Down Expand Up @@ -49,11 +49,10 @@ const expanded = ref(false)
</button>
</DialogTrigger>

<DialogContent
<SourceLightbox
:close-label="t('workshop.output.collapse', locale)"
:aria-describedby="undefined"
class="sm:max-w-5xl"
data-testid="video-source-dialog"
@dismiss="expanded = false"
>
<DialogTitle class="sr-only">{{ name }}</DialogTitle>
<video
Expand All @@ -63,8 +62,8 @@ const expanded = ref(false)
controls
playsinline
preload="metadata"
class="max-h-dvh w-full rounded-2xl bg-black object-contain"
class="max-h-full max-w-full rounded-2xl bg-black object-contain"
/>
</DialogContent>
</SourceLightbox>
</Dialog>
</template>
18 changes: 18 additions & 0 deletions apps/website/src/components/workshop/WorkshopHero.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,24 @@ describe('WorkshopHero', () => {
expect(screen.queryByText('Browse')).toBeNull()
})

it('reserves room for every subtitle it may switch to, hidden from readers', () => {
render(WorkshopHero, {
props: {
heading: 'What will you make next?',
subtitle: 'Short',
subtitleSpace: ['Short', 'A much longer subtitle for another tab']
}
})

const space = screen.getAllByTestId('hero-subtitle-space')
expect(space.map((line) => line.textContent)).toEqual([
'Short',
'A much longer subtitle for another tab'
])
for (const line of space)
expect(line).toHaveAttribute('aria-hidden', 'true')
})

// The live catalogue puts its tabs where the eyebrow goes, so a section that
// fills the slot replaces the line rather than sitting under it.
it('gives the eyebrow line up to whatever fills its slot', () => {
Expand Down
22 changes: 19 additions & 3 deletions apps/website/src/components/workshop/WorkshopHero.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@ import SplitReveal from './SplitReveal.vue'

// The copy arrives resolved, so the hero belongs to whichever catalogue renders
// it rather than to one section's translation table.
const { eyebrow, heading, subtitle } = defineProps<{
const {
eyebrow,
heading,
subtitle,
subtitleSpace = []
} = defineProps<{
eyebrow?: string
heading: string
subtitle?: string
subtitleSpace?: readonly string[]
}>()

const slots = useSlots()
Expand Down Expand Up @@ -42,8 +48,18 @@ const slots = useSlots()
<div
class="mt-4 flex flex-wrap items-center justify-between gap-x-6 gap-y-4 sm:short:mt-3"
>
<p v-if="subtitle" class="text-lg text-primary-comfy-canvas/70">
<SplitReveal :text="subtitle" :delay="260" :stagger="50" />
<p v-if="subtitle" class="grid text-lg text-primary-comfy-canvas/70">
<span
v-for="text in subtitleSpace"
:key="text"
class="invisible col-start-1 row-start-1"
aria-hidden="true"
data-testid="hero-subtitle-space"
>{{ text }}</span
>
<span class="col-start-1 row-start-1">
<SplitReveal :text="subtitle" :delay="260" :stagger="50" />
</span>
</p>
<slot name="aside" />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ const { locale = 'en' } = defineProps<{ locale?: Locale }>()
<p class="text-lg text-primary-warm-gray">
{{ rc('reshoot.pick.lead', locale) }}
</p>
<p class="text-xs text-primary-warm-gray/80">
{{ rc('reshoot.credit', locale) }} ·
{{ rc('reshoot.demoNote', locale) }}
<p class="flex flex-col gap-1 text-xs text-primary-warm-gray/80">
<span>{{ rc('reshoot.credit', locale) }}</span>
<span>{{ rc('reshoot.demoNote', locale) }}</span>
</p>
</header>
</template>
Loading
Loading