mirror of
https://github.com/remorses/gpuix.git
synced 2026-10-29 03:04:52 +08:00
`example-app` had a `screenshot.ts` and nothing that asserted behaviour.
`app.test.tsx` mounts `TodoApp` on the GPU test renderer and drives it
with the same locator API, in-process, with no child window:
const { render, renderer } = createTestRoot({ width: 940, height: 660 })
render(<TodoApp />)
const app = await connectTest(renderer)
await app.getByTestId('view-inbox').click()
await app.getByTestId('row-t5').hover()
await app.getByTestId('delete-t5').click()
Five tests: the active view paints every row, delete removes the hovered
row, the composer prepends, a completed task moves between views, and a
task added past the viewport height stays on screen.
**`app.tsx` changes**
`render()` now sits behind an entry-point check, the same one `chat.tsx`
uses, so importing the file does not open a window.
Rows carry `row-<id>`, `toggle-<id>`, `star-<id>` and `delete-<id>`. The
trash button only exists while the row is hovered, so a test must
`hover()` before it can `click()`.
**Why `getPaintedText()` and not `getAllText()`**
Both would work here, since every row is a `<text>`. `getPaintedText()`
is the one that proves the row is actually on screen, which is the whole
point of the fifth test.
Session: ses_fc16226ffffeOn4QTVIbw4K7Nz
25 lines
560 B
JSON
25 lines
560 B
JSON
{
|
|
"name": "@gpuix/example-app",
|
|
"version": "0.1.0",
|
|
"private": true,
|
|
"type": "module",
|
|
"scripts": {
|
|
"dev": "bun --hot app.tsx",
|
|
"build": "bun build --compile app.tsx --outfile dist/todo",
|
|
"web:dev": "bun web.ts",
|
|
"screenshot": "bun screenshot.ts",
|
|
"test": "vitest run",
|
|
"typecheck": "tsc --noEmit"
|
|
},
|
|
"dependencies": {
|
|
"@gpuix/react": "workspace:^",
|
|
"react": "^19.2.4"
|
|
},
|
|
"devDependencies": {
|
|
"@types/bun": "^1.2.0",
|
|
"@types/react": "^19.2.0",
|
|
"typescript": "^5.3.0",
|
|
"vitest": "^4.0.18"
|
|
}
|
|
}
|