Files
LocalAI/core/http/react-ui/e2e/studio-addons.spec.js
T
mudler-agentandEttore Di Giacinto 0a44303c21 fix(addons): one page title, one primary action and clearer empty states (#12850)
A visual pass over the add-on pages found the same few problems on
several of them. Fix them with one rule per problem instead of page by
page.

Titles: every add-on page takes the host page-title size. Talk and Tables
no longer shrink it, Studio draws one "Studio" title above its tabs (the
card of a generator is a section), and Voice keeps one title on all its
tabs. The Text to speech tab gets a styled form. The "not available"
page shows the add-on name, not the lowercase id, and sits at the same
inset as an add-on page.

One primary action: the empty state of a list carries the add button, so
the header button waits until there is something in the list (Voice
library, enrolling a speaker or a person, Add rows). The Add-ons page
shows one way into Browse. A table with no columns says so once.

Tables: Share is hidden when there are no named accounts. The active
table tab is highlighted and an empty tab list leaves no gap before
"New table".

Studio: the tab strip stays on one row at 1280 wide, /studio/3d opens
the 3D tab, and an input chip has a divider between its label and its
placeholder.

Fine-tune and Quantize: the Experimental badge sits beside the lede, not
inside the h1; an open step shows its number instead of an empty circle;
the sticky action bar keeps a gap above it.

The footer shows nothing for the empty version of a source build, and
the Voice Text to speech tab says where to get a model when none is
installed.

Assisted-by: Claude:claude-sonnet-5-5 [Claude Code]

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Co-authored-by: Ettore Di Giacinto <mudler@localai.io>
2026-10-23 12:35:44 +02:00

131 lines
6.8 KiB
JavaScript

import { test, expect } from './coverage-fixtures.js'
import { installStudioAddons } from './studio-addon.js'
import { mockStudio } from './studio-fixtures.js'
import { fakeRealtime } from './chat-fixtures.js'
// Studio and Talk are packaged add-ons. These specs run the real built bundles
// inside the add-on shell: the pages draw, the old addresses open them, the
// links they hold reach the core pages, and nothing is left when they are not
// installed.
function watchErrors(page) {
const errors = []
page.on('pageerror', e => errors.push(String(e)))
page.on('console', m => { if (m.type() === 'error') errors.push(m.text()) })
return errors
}
test.describe('Studio add-on', () => {
for (const tab of ['', '/images', '/video', '/threed', '/tts', '/sound', '/transform', '/diarization']) {
test(`the ${tab ? tab.slice(1) : 'overview'} tab draws inside the add-on shell with no script error`, async ({ page }) => {
const errors = watchErrors(page)
await mockStudio(page)
await page.goto(`/app/addons/studio/studio${tab}`)
await expect(page.locator('[data-testid="addon-surface"][data-addon="studio"] .studio-tabs')).toBeVisible({ timeout: 15_000 })
if (tab) await expect(page.locator(`.studio-tab-active[data-tab="${tab.slice(1)}"]`)).toBeVisible()
else await expect(page.getByTestId('studio-overview')).toBeVisible()
expect(errors).toEqual([])
})
}
test('the page draws its own title once, and the page keeps its own words from the media locale', async ({ page }) => {
await mockStudio(page)
await page.goto('/app/addons/studio/studio')
await expect(page.getByTestId('studio-overview')).toBeVisible({ timeout: 15_000 })
await expect(page.locator('h1')).toHaveCount(1)
await expect(page.locator('h1.page-title', { hasText: /^Studio$/ })).toHaveCount(1)
await expect(page.getByText('What do you want to make?')).toBeVisible()
// No raw key is drawn where words belong.
await expect(page.locator('.studio-front').getByText(/studio\.[a-z]+\.[A-Za-z.]+/)).toHaveCount(0)
})
test('/studio/3d opens the 3D tab, and a generator tab has the one page title', async ({ page }) => {
await mockStudio(page)
await page.goto('/app/addons/studio/studio/3d')
await expect(page.locator('.studio-tab-active[data-tab="threed"]')).toBeVisible({ timeout: 15_000 })
await expect(page.locator('h1')).toHaveCount(1)
await expect(page.locator('h1.page-title')).toHaveText('Studio')
// The card of the generator is a section under that title.
await expect(page.getByTestId('ws-compose').getByRole('heading', { level: 2 })).toBeVisible()
})
test('the tab strip stays on one row at 1280 wide', async ({ page }) => {
await page.setViewportSize({ width: 1280, height: 800 })
await mockStudio(page)
await page.goto('/app/addons/studio/studio/tts')
await expect(page.locator('.studio-tab-active[data-tab="tts"]')).toBeVisible({ timeout: 15_000 })
const tops = await page.locator('.studio-tab').evaluateAll(tabs => [...new Set(tabs.map(el => Math.round(el.getBoundingClientRect().top)))])
expect(tops).toHaveLength(1)
})
test('a model id with a slash and a colon travels as ?model= and reaches the page', async ({ page }) => {
await mockStudio(page)
await page.goto('/app/studio/images/sd-1.5-lcm?size=768x768')
await expect(page).toHaveURL(/\/app\/addons\/studio\/studio\/images\?size=768x768&model=sd-1\.5-lcm$/)
await expect(page.locator('.studio-tab-active[data-tab="images"]')).toBeVisible({ timeout: 15_000 })
})
test('the old Studio addresses say so plainly when the add-on is not installed', async ({ page }) => {
for (const address of ['/app/studio', '/app/studio/tts', '/app/image', '/app/talk']) {
await page.goto(address)
await expect(page.getByTestId('addon-unavailable')).toBeVisible({ timeout: 15_000 })
await expect(page).toHaveURL(/\/app\/addons\/(studio|talk)\//)
}
await expect(page.locator('.studio-tabs')).toHaveCount(0)
})
test('the Studio style sheet reaches the page and nothing outside it', async ({ page }) => {
await mockStudio(page)
await page.goto('/app/addons/studio/studio/images')
await expect(page.locator('.studio-tab-active')).toBeVisible({ timeout: 15_000 })
const css = await page.evaluate(() => [...document.querySelectorAll('style[data-addon-style="studio"]')].map(el => el.textContent).join('\n'))
expect(css).toContain('[data-addon="studio"]')
expect(css).not.toMatch(/(^|\})\s*\.studio-tab\s*\{/)
// The sidebar is untouched by the sheet.
const sidebarFont = await page.locator('.sidebar-nav .nav-item').first().evaluate(el => getComputedStyle(el).fontFamily)
expect(sidebarFont.length).toBeGreaterThan(0)
})
})
test.describe('Talk add-on', () => {
test('the page draws inside the add-on shell, titled once, with no script error', async ({ page }) => {
const errors = watchErrors(page)
await fakeRealtime(page)
await page.goto('/app/addons/talk/talk')
await expect(page.getByTestId('talk-start')).toBeEnabled({ timeout: 15_000 })
await expect(page.locator('h1')).toHaveCount(1)
await expect(page.locator('h1')).toHaveText('Talk')
expect(errors).toEqual([])
})
test('a button of the page opens a core page, and the way back to Talk travels with the editor link', async ({ page }) => {
await fakeRealtime(page, { pipelines: false })
await page.goto('/app/addons/talk/talk')
const card = page.getByTestId('talk-no-pipeline')
await expect(card).toBeVisible({ timeout: 15_000 })
await card.getByRole('button', { name: 'Create a pipeline model' }).click()
await expect(page).toHaveURL(/\/app\/model-editor\?template=pipeline/)
expect(await page.evaluate(() => window.history.state?.usr)).toEqual({ from: '/app/addons/talk/talk', fromLabel: 'Talk' })
await page.goBack()
await expect(page.getByTestId('talk-no-pipeline')).toBeVisible()
await page.getByTestId('talk-no-pipeline').getByRole('button', { name: /gallery/i }).click()
await expect(page).toHaveURL(/\/app\/models/)
})
})
test.describe('Without the add-ons', () => {
test('the Add-ons drawer does not list Studio or Talk, and the sidebar has no Create group', async ({ page }) => {
await page.goto('/app/addons')
await expect(page.getByTestId('addon-tile').filter({ hasText: /Studio|Talk/ })).toHaveCount(0)
await expect(page.locator('.sidebar-nav a[href="/app/studio"], .sidebar-nav a[href="/app/talk"]')).toHaveCount(0)
await expect(page.locator('.sidebar-section-title', { hasText: 'Create' })).toHaveCount(0)
})
test('installing them lists both in the drawer', async ({ page }) => {
await installStudioAddons(page)
await page.goto('/app/addons')
await expect(page.getByTestId('addon-tile').filter({ hasText: 'Studio' })).toBeVisible({ timeout: 15_000 })
await expect(page.getByTestId('addon-tile').filter({ hasText: 'Talk' })).toBeVisible()
})
})