-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
184 changed files
with
3,099 additions
and
648 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
import { test, expect } from '@playwright/test'; | ||
import { | ||
dragAndDrop, | ||
getLocatorPosition, | ||
getByShapeType, | ||
getShapePosition, | ||
moveSelected, | ||
} from '../helpers'; | ||
import { Group } from 'konva/lib/Group'; | ||
|
||
const numShifts: number = 10; | ||
|
||
test('move shape with the keyboard - left', async ({ page }) => { | ||
await page.goto(''); | ||
|
||
const component = page.getByAltText('Input', { exact: true }); | ||
const position = await getLocatorPosition(component); | ||
|
||
await dragAndDrop(page, position, { | ||
x: position.x + 500, | ||
y: position.y - 240, | ||
}); | ||
|
||
const inputShape = (await getByShapeType(page, 'input')) as Group; | ||
expect(inputShape).toBeDefined(); | ||
|
||
const draggedPosition = await getShapePosition(inputShape); | ||
|
||
moveSelected(page, 'ArrowLeft', numShifts); | ||
|
||
const inputShapeMoved = (await getByShapeType(page, 'input')) as Group; | ||
const movedPosition = await getShapePosition(inputShapeMoved); | ||
|
||
expect(movedPosition.x === draggedPosition.x - numShifts * 2).toBeTruthy(); | ||
expect(movedPosition.y === draggedPosition.y).toBeTruthy(); | ||
}); | ||
|
||
test('move shape with the keyboard - up', async ({ page }) => { | ||
await page.goto(''); | ||
|
||
const component = page.getByAltText('Input', { exact: true }); | ||
const position = await getLocatorPosition(component); | ||
|
||
await dragAndDrop(page, position, { | ||
x: position.x + 500, | ||
y: position.y - 240, | ||
}); | ||
|
||
const inputShape = (await getByShapeType(page, 'input')) as Group; | ||
expect(inputShape).toBeDefined(); | ||
|
||
const draggedPosition = await getShapePosition(inputShape); | ||
|
||
moveSelected(page, 'ArrowUp', numShifts); | ||
|
||
const inputShapeMoved = (await getByShapeType(page, 'input')) as Group; | ||
const movedPosition = await getShapePosition(inputShapeMoved); | ||
|
||
expect(movedPosition.x === draggedPosition.x).toBeTruthy(); | ||
expect(movedPosition.y === draggedPosition.y - numShifts * 2).toBeTruthy(); | ||
}); | ||
|
||
test('move shape with the keyboard - down', async ({ page }) => { | ||
await page.goto(''); | ||
|
||
const component = page.getByAltText('Input', { exact: true }); | ||
const position = await getLocatorPosition(component); | ||
|
||
await dragAndDrop(page, position, { | ||
x: position.x + 500, | ||
y: position.y - 240, | ||
}); | ||
|
||
const inputShape = (await getByShapeType(page, 'input')) as Group; | ||
expect(inputShape).toBeDefined(); | ||
|
||
const draggedPosition = await getShapePosition(inputShape); | ||
|
||
moveSelected(page, 'ArrowDown', numShifts); | ||
|
||
const inputShapeMoved = (await getByShapeType(page, 'input')) as Group; | ||
const movedPosition = await getShapePosition(inputShapeMoved); | ||
|
||
expect(movedPosition.x === draggedPosition.x).toBeTruthy(); | ||
expect(movedPosition.y === draggedPosition.y + numShifts * 2).toBeTruthy(); | ||
}); | ||
|
||
test('move shape with the keyboard - right', async ({ page }) => { | ||
await page.goto(''); | ||
|
||
const component = page.getByAltText('Input', { exact: true }); | ||
const position = await getLocatorPosition(component); | ||
|
||
await dragAndDrop(page, position, { | ||
x: position.x + 500, | ||
y: position.y - 240, | ||
}); | ||
|
||
const inputShape = (await getByShapeType(page, 'input')) as Group; | ||
expect(inputShape).toBeDefined(); | ||
|
||
const draggedPosition = await getShapePosition(inputShape); | ||
|
||
moveSelected(page, 'ArrowRight', numShifts); | ||
|
||
const inputShapeMoved = (await getByShapeType(page, 'input')) as Group; | ||
const movedPosition = await getShapePosition(inputShapeMoved); | ||
|
||
expect(movedPosition.x === draggedPosition.x + numShifts * 2).toBeTruthy(); | ||
expect(movedPosition.y === draggedPosition.y).toBeTruthy(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export interface E2E_CanvasItemKeyAttrs { | ||
x: number; | ||
y: number; | ||
['data-id']: string; | ||
width: number; | ||
height: number; | ||
shapeType: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Page } from '@playwright/test'; | ||
|
||
export const clickUndoUiButton = async (page: Page) => | ||
await page.getByRole('button', { name: 'Undo' }).click(); | ||
|
||
export const clickRedoUiButton = async (page: Page) => | ||
await page.getByRole('button', { name: 'Redo' }).click(); | ||
|
||
export const clickCopyUiButton = async (page: Page) => | ||
await page.getByRole('button', { name: 'Copy' }).click(); | ||
|
||
export const clickPasteUiButton = async (page: Page) => | ||
await page.getByRole('button', { name: 'Paste' }).click(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
import { test, expect } from '@playwright/test'; | ||
import { Group } from 'konva/lib/Group'; | ||
import { dragAndDrop, getByShapeType, getLocatorPosition } from '../helpers'; | ||
|
||
test('can add textarea to canvas, edit content, and verify shape text', async ({ | ||
page, | ||
}) => { | ||
await page.goto(''); | ||
const component = page.getByAltText('Textarea'); | ||
await component.scrollIntoViewIfNeeded(); | ||
|
||
const position = await getLocatorPosition(component); | ||
const targetPosition = { | ||
x: position.x + 500, | ||
y: position.y - 240, | ||
}; | ||
await dragAndDrop(page, position, targetPosition); | ||
await page.mouse.dblclick(targetPosition.x, targetPosition.y + 40); | ||
const textarea = page.getByRole('textbox').first(); | ||
const textareaContent = await textarea.inputValue(); | ||
expect(textareaContent).toEqual('Your text here...'); | ||
|
||
const textContent = 'Hello'; | ||
await textarea.fill(textContent); | ||
await page.mouse.click(800, 130); | ||
const textareaShape = (await getByShapeType(page, 'textarea')) as Group; | ||
|
||
expect(textareaShape).toBeDefined(); | ||
const textShape = textareaShape.children.find( | ||
child => child.attrs.text === textContent | ||
); | ||
expect(textShape).toBeDefined(); | ||
}); | ||
|
||
test('cancels textarea edit on Escape and verifies original shape text', async ({ | ||
page, | ||
}) => { | ||
await page.goto(''); | ||
const component = page.getByAltText('Textarea'); | ||
await component.scrollIntoViewIfNeeded(); | ||
|
||
const position = await getLocatorPosition(component); | ||
const targetPosition = { | ||
x: position.x + 500, | ||
y: position.y - 240, | ||
}; | ||
await dragAndDrop(page, position, targetPosition); | ||
await page.mouse.dblclick(targetPosition.x, targetPosition.y + 40); | ||
const textarea = page.getByRole('textbox').first(); | ||
|
||
const textContent = 'Hello'; | ||
await textarea.fill(textContent); | ||
await page.keyboard.press('Escape'); | ||
const originalTextContent = 'Your text here...'; | ||
const textareaShape = (await getByShapeType(page, 'textarea')) as Group; | ||
|
||
expect(textareaShape).toBeDefined(); | ||
const textShape = textareaShape.children.find( | ||
child => child.attrs.text === originalTextContent | ||
); | ||
expect(textShape).toBeDefined(); | ||
}); | ||
|
||
test('can add and edit input, and delete last letter', async ({ page }) => { | ||
await page.goto(''); | ||
const component = page.getByAltText('Textarea'); | ||
await component.scrollIntoViewIfNeeded(); | ||
|
||
const position = await getLocatorPosition(component); | ||
const targetPosition = { | ||
x: position.x + 500, | ||
y: position.y - 240, | ||
}; | ||
await dragAndDrop(page, position, targetPosition); | ||
await page.mouse.dblclick(targetPosition.x, targetPosition.y + 40); | ||
const textarea = page.getByRole('textbox').first(); | ||
|
||
const textContent = 'World'; | ||
await textarea.fill(textContent); | ||
await page.keyboard.press('Backspace'); | ||
const updatedTextareaContent = await textarea.inputValue(); | ||
expect(updatedTextareaContent).toEqual('Worl'); | ||
|
||
await page.mouse.click(800, 130); | ||
|
||
const textareaShape = (await getByShapeType(page, 'textarea')) as Group; | ||
expect(textareaShape).toBeDefined(); | ||
const textShape = textareaShape.children.find( | ||
child => child.attrs.text === 'Worl' | ||
); | ||
expect(textShape).toBeDefined(); | ||
}); | ||
|
||
test('adds multi-line text to textarea on canvas and verifies shape text', async ({ | ||
page, | ||
}) => { | ||
await page.goto(''); | ||
const component = page.getByAltText('Textarea'); | ||
await component.scrollIntoViewIfNeeded(); | ||
|
||
const position = await getLocatorPosition(component); | ||
const targetPosition = { | ||
x: position.x + 500, | ||
y: position.y - 240, | ||
}; | ||
await dragAndDrop(page, position, targetPosition); | ||
await page.mouse.dblclick(targetPosition.x, targetPosition.y + 40); | ||
const textarea = page.getByRole('textbox').first(); | ||
|
||
const textContent = 'Line 1\nLine 2'; | ||
await textarea.fill(textContent); | ||
|
||
await page.mouse.click(800, 130); | ||
|
||
const textareaShape = (await getByShapeType(page, 'textarea')) as Group; | ||
expect(textareaShape).toBeDefined(); | ||
const textShape = textareaShape.children.find( | ||
child => child.attrs.text === textContent | ||
); | ||
expect(textShape).toBeDefined(); | ||
}); |
Oops, something went wrong.