openpencil/tests/e2e/app/recent-files.spec.ts
Danila Poyarkov e69ba75c12
refactor(ui): compose shared editor controls (#670)
* refactor(ui): extract shared action and navigation primitives

* refactor(ui): compose settings and libraries with shared tabs

* feat(ui): preserve native activation and toolbar keyboard navigation

* refactor(home): share document entries and accessible input controls

* fix(layers): share virtualized row geometry and selection styling

* refactor(layout): compose spacing and readable dimension controls

* refactor(properties): compose advanced strokes and inline effects

* refactor(ui): reuse actions in page and property controls

* refactor(settings): adopt shared actions without changing workflows

* refactor(ui): share collaboration and provider actions

* refactor(ui): finish shell and paint action composition

* test(ui): restore extracted control and settings coverage

* test(ui): complete workflow extraction coverage

* fix(ui): address review and trim redundant snapshots

* fix(layout): preserve single-step Undo for guides and wrap
2026-09-10 12:09:06 +03:00

48 lines
2 KiB
TypeScript

import { expect, test } from '#tests/e2e/fixtures'
test('keeps the New tab layout usable on mobile', async ({ page }) => {
await page.setViewportSize({ width: 390, height: 844 })
await page.goto('/?recent-files')
const search = page.getByLabel('Search files…')
await expect(search).toBeVisible()
await expect(search).not.toBeFocused()
await expect(search).toHaveAttribute('placeholder', 'Search files…')
await expect(page.getByTestId('home-open-file')).toBeVisible()
await expect(page.getByTestId('home-new-document')).toBeVisible()
await expect(page.getByTestId('recent-files-home')).toHaveJSProperty(
'scrollWidth',
await page.getByTestId('recent-files-home').evaluate((element) => element.clientWidth)
)
})
test('opens to the recent-files home and starts a new document', async ({ page }) => {
await page.goto('/?recent-files')
await expect(page.getByTestId('recent-files-home')).toBeVisible()
await expect(page.getByText('No recent files yet')).toBeVisible()
await expect(page.getByTestId('tabbar-tab')).toHaveCount(1)
await page.getByTestId('home-new-document').click()
await expect(page.getByTestId('recent-files-home')).toBeHidden()
const tab = page.getByTestId('tabbar-tab')
await expect(tab).toHaveCount(1)
await expect(tab).toContainText('Untitled')
await expect(page.getByTestId('tabbar-close')).toHaveCount(1)
await page.getByTestId('tabbar-new').click()
await expect(page.getByTestId('recent-files-home')).toBeVisible()
await expect(page.getByTestId('tabbar-tab')).toHaveCount(2)
await expect(page.getByTestId('tabbar-tab').last()).toContainText('New tab')
await expect(page.getByLabel('Search files…')).toBeFocused()
await expect(page.getByTestId('tabbar-close')).toHaveCount(2)
await page.getByTestId('tabbar-tab').first().click()
await page.getByTestId('tabbar-tab').first().hover()
await page.locator('[data-slot="tab-item"]').first().getByTestId('tabbar-close').click()
await expect(page.getByTestId('recent-files-home')).toBeVisible()
})