2026-05-16 13:19:03 +00:00
|
|
|
import { expect, test, useEditorSetupWithClear } from '#tests/e2e/fixtures'
|
2026-02-28 04:32:15 +00:00
|
|
|
|
2026-05-16 13:19:03 +00:00
|
|
|
const editor = useEditorSetupWithClear('/?test&no-chrome&no-rulers')
|
2026-02-28 04:35:52 +00:00
|
|
|
|
2026-02-28 04:44:20 +00:00
|
|
|
async function expectCanvas(name: string) {
|
2026-05-16 13:19:03 +00:00
|
|
|
editor.canvas.assertNoErrors()
|
|
|
|
|
const buffer = await editor.canvas.canvas.screenshot()
|
2026-02-28 04:44:20 +00:00
|
|
|
expect(buffer).toMatchSnapshot(`${name}.png`)
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-28 04:35:52 +00:00
|
|
|
test('empty canvas', async () => {
|
2026-02-28 04:44:20 +00:00
|
|
|
await expectCanvas('empty-canvas')
|
2026-02-28 04:35:52 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('draw rectangle', async () => {
|
2026-05-16 13:19:03 +00:00
|
|
|
await editor.canvas.drawRect(100, 100, 200, 150)
|
2026-02-28 04:44:20 +00:00
|
|
|
await expectCanvas('draw-rectangle')
|
2026-02-28 04:35:52 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('draw ellipse', async () => {
|
2026-05-16 13:19:03 +00:00
|
|
|
await editor.canvas.drawEllipse(100, 100, 200, 150)
|
2026-02-28 04:44:20 +00:00
|
|
|
await expectCanvas('draw-ellipse')
|
2026-02-28 04:35:52 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('draw rectangle then move it', async () => {
|
2026-05-16 13:19:03 +00:00
|
|
|
await editor.canvas.drawRect(100, 100, 200, 150)
|
|
|
|
|
await editor.canvas.selectTool('select')
|
|
|
|
|
await editor.canvas.drag(200, 175, 400, 300)
|
|
|
|
|
await editor.canvas.waitForRender()
|
2026-02-28 04:44:20 +00:00
|
|
|
await expectCanvas('draw-rectangle-then-move-it')
|
2026-02-28 04:35:52 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('draw and delete', async () => {
|
2026-05-16 13:19:03 +00:00
|
|
|
await editor.canvas.drawRect(100, 100, 200, 150)
|
|
|
|
|
await editor.canvas.deleteSelection()
|
2026-02-28 04:44:20 +00:00
|
|
|
await expectCanvas('draw-and-delete')
|
2026-02-28 04:35:52 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('draw and undo', async () => {
|
2026-05-16 13:19:03 +00:00
|
|
|
await editor.canvas.drawRect(100, 100, 200, 150)
|
|
|
|
|
await editor.canvas.undo()
|
2026-02-28 04:44:20 +00:00
|
|
|
await expectCanvas('draw-and-undo')
|
2026-02-28 04:32:15 +00:00
|
|
|
})
|