Files
crewli/apps/app/tests/playwright-ct/v2/draggableblock.ct.spec.ts

40 lines
1.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { expect, test } from '@playwright/experimental-ct-vue'
import DraggableBlock from '@/components-v2/shared/DraggableBlock.vue'
test('drag past threshold emits dragstart then dragend with delta @ct', async ({ mount }) => {
const events: string[] = []
const component = await mount(DraggableBlock, {
props: { line1Left: { text: 'DJ Foo' } },
on: {
dragstart: () => events.push('dragstart'),
dragend: (d: { x: number; y: number }) => events.push(`dragend:${d.x},${d.y}`),
click: () => events.push('click'),
},
})
const box = (await component.boundingBox())!
await component.page().mouse.move(box.x + 10, box.y + 10)
await component.page().mouse.down()
await component.page().mouse.move(box.x + 40, box.y + 22)
await component.page().mouse.up()
expect(events[0]).toBe('dragstart')
expect(events.some(e => e.startsWith('dragend:'))).toBe(true)
expect(events).not.toContain('click')
})
test('static states render for @visual baseline @visual', async ({ mount }) => {
const component = await mount(DraggableBlock, {
props: {
line1Left: { text: 'DJ Foo', tag: { label: 'confirmed', severity: 'success' } },
line1Right: { pill: 'Main' },
line2Left: '21:0022:00',
line2Right: { progress: 60 },
selected: true,
},
})
await expect(component).toHaveScreenshot('draggableblock-selected.png')
})