Skip to content

AI-native design editor. Open-source Figma alternative.

test(motion): cover legacy preferences and mobile Off mode

Danila Poyarkovcf86685c5185
diff --git a/tests/e2e/settings/motion.spec.ts b/tests/e2e/settings/motion.spec.ts
index efdb91808..b689a0673 100644
--- a/tests/e2e/settings/motion.spec.ts
+++ b/tests/e2e/settings/motion.spec.ts
@@ -2,6 +2,20 @@ import { expect, test } from '@playwright/test'
import { CanvasHelper } from '#tests/helpers/canvas'
+for (const appearance of [undefined, null, { animations: 'invalid' }]) {
+ test(`normalizes legacy animation preferences ${JSON.stringify(appearance)}`, async ({
+ page
+ }) => {
+ await page.emulateMedia({ reducedMotion: 'no-preference' })
+ await page.addInitScript((appearance) => {
+ localStorage.setItem('open-pencil:preferences:v1', JSON.stringify({ version: 1, appearance }))
+ }, appearance)
+ await page.goto('/?test')
+ await new CanvasHelper(page).waitForInit()
+ await expect(page.locator('html')).toHaveAttribute('data-motion', 'full')
+ })
+}
+
test('animation preference follows live system changes and persists the Off override', async ({
page
}) => {
diff --git a/tests/e2e/toolbar/mobile.spec.ts b/tests/e2e/toolbar/mobile.spec.ts
index a9015103c..8b9cb6900 100644
--- a/tests/e2e/toolbar/mobile.spec.ts
+++ b/tests/e2e/toolbar/mobile.spec.ts
@@ -2,27 +2,37 @@ import { expect, test } from '@playwright/test'
import { CanvasHelper } from '#tests/helpers/canvas'
-test('mobile toolbar retains keyboard navigation after category transitions', async ({ page }) => {
- await page.setViewportSize({ width: 390, height: 844 })
- await page.goto('/?test')
- const canvas = new CanvasHelper(page)
- await canvas.waitForInit()
- const toolbar = page.getByTestId('mobile-toolbar-container')
- await expect(toolbar).toHaveAttribute('role', 'toolbar')
- const tools = page.getByTestId('mobile-toolbar-tools')
- await expect(tools).toBeVisible()
- await page.getByTestId('mobile-toolbar-next').click()
- const edit = page.getByTestId('mobile-toolbar-edit')
- await expect(edit).toBeVisible()
- await expect(tools).toHaveCount(0)
- const first = edit.getByRole('button').first()
- await expect(first).toHaveAttribute('aria-label', /.+/)
- await first.focus()
- await first.press('ArrowRight')
- await expect(edit.getByRole('button').nth(1)).toBeFocused()
- await page.getByTestId('mobile-toolbar-prev').click()
- await expect(tools).toBeVisible()
- await expect(edit).toHaveCount(0)
- await expect(tools.getByRole('button').first()).toHaveAttribute('aria-label', /.+/)
- canvas.assertNoErrors()
-})
+for (const animations of ['system', 'off'] as const) {
+ test(`mobile toolbar retains keyboard navigation with animations ${animations}`, async ({
+ page
+ }) => {
+ await page.addInitScript((animations) => {
+ localStorage.setItem(
+ 'open-pencil:preferences:v1',
+ JSON.stringify({ version: 1, appearance: { animations } })
+ )
+ }, animations)
+ await page.setViewportSize({ width: 390, height: 844 })
+ await page.goto('/?test')
+ const canvas = new CanvasHelper(page)
+ await canvas.waitForInit()
+ const toolbar = page.getByTestId('mobile-toolbar-container')
+ await expect(toolbar).toHaveAttribute('role', 'toolbar')
+ const tools = page.getByTestId('mobile-toolbar-tools')
+ await expect(tools).toBeVisible()
+ await page.getByTestId('mobile-toolbar-next').click()
+ const edit = page.getByTestId('mobile-toolbar-edit')
+ await expect(edit).toBeVisible()
+ await expect(tools).toHaveCount(0)
+ const first = edit.getByRole('button').first()
+ await expect(first).toHaveAttribute('aria-label', /.+/)
+ await first.focus()
+ await first.press('ArrowRight')
+ await expect(edit.getByRole('button').nth(1)).toBeFocused()
+ await page.getByTestId('mobile-toolbar-prev').click()
+ await expect(tools).toBeVisible()
+ await expect(edit).toHaveCount(0)
+ await expect(tools.getByRole('button').first()).toHaveAttribute('aria-label', /.+/)
+ canvas.assertNoErrors()
+ })
+}