* build: typecheck the test suites Tests were in no TypeScript program: no tsconfig included tests/** or packages/*/tests/**, and bun strips types without checking them, so a fixture could drop a required field and keep passing until something read it. @types/bun moves to the root because it was installed per package only, and #cli-tests/* joins the paths the root config already carries. * test: fix the type errors the test suites were hiding Typechecking the tests turned up 1123 errors. Most were ordinary strictness, but some were real: `NodeChange` bound to Figma's plugin typings rather than the Kiwi codec in thirteen .fig tests, materializeInstance was called with six arguments against five so the blobs and source children were dropped, CanvasKit pixels were written to a plain object that never reached WASM, and assertions were made through accessors that do not exist, so they asserted nothing. Fixtures that had quietly lost a required field now carry it, nullable results are narrowed through the existing expectDefined helper rather than assumed, and stand-ins for CanvasKit and the editor go through one named helper instead of an unexplained cast at each site. No test was deleted, skipped, or weakened, and no `any`, non-null assertion, or ts-expect-error was introduced. * docs: record what typechecking the tests established Pins the app program's global types with an assertion rather than a note, since an unpinned types list lets any root @types package decide which platform src/** is judged against. The two environment faults that look like code regressions — Vite's dependency pre-bundle outliving a package rebuild, and heavy .fig suites failing under load — go to the development docs, where an explanation belongs. * fix: align @types/bun and keep node types resolvable when extended The root manifest declared a newer @types/bun than every package, which check:monorepo rejects, and pinning the app program's types left them unresolvable from a config that extends this one out of tree. * fix: fail the test typecheck when the compiler itself fails The gate matched diagnostics by substring, so a compiler or config failure that named no test file printed a pass while having checked nothing. Diagnostics are now split by whether they name a file: an unscoped one is the run failing and stops the gate, a test file's is a finding, and a source file's stays out by design. Also drops the parameter planComponentConstruction never read, and makes the inner-shadow verification script exit non-zero when it renders no image instead of logging and succeeding. * chore: merge master into tests-typecheck
158 lines
6.5 KiB
TypeScript
158 lines
6.5 KiB
TypeScript
import { expect, test, useEditorSetup } from '#tests/e2e/fixtures'
|
|
import { getPageChildren } from '#tests/helpers/store'
|
|
import {
|
|
toolbarFlyoutItemTestId,
|
|
toolbarFlyoutTestId,
|
|
toolbarToolTestId
|
|
} from '#tests/helpers/test-ids'
|
|
|
|
const editor = useEditorSetup()
|
|
|
|
test('shapes flyout opens', async () => {
|
|
await editor.page.getByTestId(toolbarFlyoutTestId('RECTANGLE')).click()
|
|
const rectangleItem = editor.page.getByTestId(toolbarFlyoutItemTestId('RECTANGLE'))
|
|
const polygonItem = editor.page.getByTestId(toolbarFlyoutItemTestId('POLYGON'))
|
|
|
|
await expect(polygonItem).toBeVisible()
|
|
await expect(rectangleItem).toHaveAttribute('data-active', 'true')
|
|
await expect(rectangleItem).toHaveAttribute('role', 'menuitemradio')
|
|
await expect(rectangleItem).toHaveAttribute('aria-checked', 'true')
|
|
await expect(rectangleItem.locator('[data-slot="flyout-item-indicator"] svg')).toHaveCount(1)
|
|
await expect(polygonItem).not.toHaveAttribute('data-active', 'true')
|
|
await expect(polygonItem).toHaveAttribute('aria-checked', 'false')
|
|
editor.canvas.assertNoErrors()
|
|
})
|
|
|
|
test('Polygon tool creates POLYGON node', async () => {
|
|
await editor.page.getByTestId(toolbarFlyoutItemTestId('POLYGON')).click()
|
|
await expect(editor.page.getByTestId(toolbarToolTestId('POLYGON'))).toHaveAttribute(
|
|
'aria-pressed',
|
|
'true'
|
|
)
|
|
await editor.canvas.drag(300, 200, 400, 300)
|
|
await editor.canvas.waitForRender()
|
|
|
|
const children = await getPageChildren(editor.page)
|
|
expect(children.some((n) => n.type === 'POLYGON')).toBe(true)
|
|
editor.canvas.assertNoErrors()
|
|
})
|
|
|
|
test('Star tool creates STAR node', async () => {
|
|
await editor.page.getByTestId(toolbarFlyoutTestId('RECTANGLE')).click()
|
|
await editor.page.getByTestId(toolbarFlyoutItemTestId('STAR')).click()
|
|
await editor.canvas.drag(150, 150, 250, 250)
|
|
await editor.canvas.waitForRender()
|
|
|
|
const children = await getPageChildren(editor.page)
|
|
expect(children.some((n) => n.type === 'STAR')).toBe(true)
|
|
editor.canvas.assertNoErrors()
|
|
})
|
|
|
|
test('shape flyout remembers its selection independently of the active tool', async () => {
|
|
await editor.canvas.pressKey('f')
|
|
await expect(editor.page.getByTestId(toolbarToolTestId('STAR'))).toHaveAttribute(
|
|
'aria-pressed',
|
|
'false'
|
|
)
|
|
|
|
await editor.page.getByTestId(toolbarFlyoutTestId('RECTANGLE')).click()
|
|
const starItem = editor.page.getByTestId(toolbarFlyoutItemTestId('STAR'))
|
|
const rectangleItem = editor.page.getByTestId(toolbarFlyoutItemTestId('RECTANGLE'))
|
|
|
|
await expect(starItem).toHaveAttribute('data-active', 'true')
|
|
await expect(starItem).toHaveAttribute('aria-checked', 'true')
|
|
await expect(starItem.locator('[data-slot="flyout-item-indicator"] svg')).toHaveCount(1)
|
|
await expect(rectangleItem).not.toHaveAttribute('data-active', 'true')
|
|
await expect(rectangleItem).toHaveAttribute('aria-checked', 'false')
|
|
|
|
await rectangleItem.hover()
|
|
await expect(rectangleItem).toHaveAttribute('data-highlighted', '')
|
|
await expect(starItem).toHaveAttribute('data-active', 'true')
|
|
editor.canvas.assertNoErrors()
|
|
})
|
|
|
|
test('Pen creates VECTOR node with 3 vertices on Enter', async () => {
|
|
await editor.canvas.pressKey('Escape')
|
|
await editor.canvas.pressKey('p')
|
|
await editor.canvas.click(100, 400)
|
|
await editor.canvas.waitForRender()
|
|
await editor.canvas.click(200, 400)
|
|
await editor.canvas.waitForRender()
|
|
await editor.canvas.click(200, 480)
|
|
await editor.canvas.waitForRender()
|
|
await editor.canvas.pressKey('Enter')
|
|
await editor.canvas.waitForRender()
|
|
|
|
const children = await getPageChildren(editor.page)
|
|
const vectors = children.filter((n) => n.type === 'VECTOR')
|
|
expect(vectors.length).toBeGreaterThan(0)
|
|
const last = vectors[vectors.length - 1]
|
|
expect(last.vectorNetwork?.vertices.length).toBe(3)
|
|
editor.canvas.assertNoErrors()
|
|
})
|
|
|
|
test('Pen Escape with 2 vertices cancels path without creating node', async () => {
|
|
const before = (await getPageChildren(editor.page)).filter((n) => n.type === 'VECTOR').length
|
|
|
|
await editor.canvas.pressKey('p')
|
|
await editor.canvas.click(350, 400)
|
|
await editor.canvas.waitForRender()
|
|
await editor.canvas.click(440, 400)
|
|
await editor.canvas.waitForRender()
|
|
await editor.canvas.pressKey('Escape')
|
|
await editor.canvas.waitForRender()
|
|
|
|
const after = (await getPageChildren(editor.page)).filter((n) => n.type === 'VECTOR').length
|
|
expect(after).toBe(before)
|
|
editor.canvas.assertNoErrors()
|
|
})
|
|
|
|
test('Pen close path creates VECTOR with closed region', async () => {
|
|
const before = (await getPageChildren(editor.page)).filter((n) => n.type === 'VECTOR').length
|
|
|
|
await editor.canvas.pressKey('p')
|
|
await editor.canvas.click(500, 200)
|
|
await editor.canvas.waitForRender()
|
|
await editor.canvas.click(580, 200)
|
|
await editor.canvas.waitForRender()
|
|
await editor.canvas.click(540, 270)
|
|
await editor.canvas.waitForRender()
|
|
await editor.canvas.click(500, 200)
|
|
await editor.canvas.waitForRender()
|
|
|
|
const after = (await getPageChildren(editor.page)).filter((n) => n.type === 'VECTOR').length
|
|
expect(after).toBeGreaterThan(before)
|
|
|
|
const vectors = (await getPageChildren(editor.page)).filter((n) => n.type === 'VECTOR')
|
|
const last = vectors[vectors.length - 1]
|
|
expect(last.vectorNetwork?.regions?.length).toBeGreaterThan(0)
|
|
editor.canvas.assertNoErrors()
|
|
})
|
|
|
|
test('Frame flyout shows Frame and Section items', async () => {
|
|
await editor.canvas.pressKey('f')
|
|
const frameButton = editor.page.getByTestId(toolbarToolTestId('FRAME'))
|
|
const frameOptions = editor.page.getByTestId(toolbarFlyoutTestId('FRAME'))
|
|
|
|
await expect(frameButton).toHaveAttribute('aria-pressed', 'true')
|
|
await expect(frameOptions).not.toHaveAttribute('data-active', 'true')
|
|
await expect(frameOptions).toHaveAttribute('data-state', 'closed')
|
|
|
|
await frameOptions.click()
|
|
await expect(frameOptions).toHaveAttribute('data-state', 'open')
|
|
await expect(frameOptions).not.toHaveAttribute('data-active', 'true')
|
|
const frameItem = editor.page.getByTestId(toolbarFlyoutItemTestId('FRAME'))
|
|
await expect(frameItem).toBeVisible()
|
|
await expect(frameItem).toHaveAttribute('data-active', 'true')
|
|
await expect(frameItem.locator('[data-slot="flyout-item-indicator"] svg')).toHaveCount(1)
|
|
const sectionItem = editor.page.getByTestId(toolbarFlyoutItemTestId('SECTION'))
|
|
await expect(sectionItem).toBeVisible()
|
|
await expect(sectionItem).not.toHaveAttribute('data-active', 'true')
|
|
await expect(sectionItem.locator('[data-slot="flyout-item-indicator"] svg')).toHaveCount(0)
|
|
|
|
await sectionItem.hover()
|
|
await expect(sectionItem).toHaveAttribute('data-highlighted', '')
|
|
await expect(frameItem).toHaveAttribute('data-active', 'true')
|
|
editor.canvas.assertNoErrors()
|
|
})
|