-
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.
Merge pull request #556 from Lemoncode/dev
Deployment
- Loading branch information
Showing
219 changed files
with
3,914 additions
and
507 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
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,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(); | ||
}); |
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,158 @@ | ||
import { test, expect } from '@playwright/test'; | ||
import { | ||
addComponentsToCanvas, | ||
dragAndDrop, | ||
getWithinCanvasItemList, | ||
} from '../helpers'; | ||
import { E2E_CanvasItemKeyAttrs } from '../helpers/types/e2e-types'; | ||
import { | ||
clickCopyUiButton, | ||
clickPasteUiButton, | ||
} from '../helpers/ui-buttons.helpers'; | ||
|
||
test.describe('Copy/Paste functionality tests', () => { | ||
test.beforeEach(async ({ page }) => { | ||
await page.goto(''); | ||
}); | ||
|
||
test('Should copy and paste a single shape using the ToolBar UI buttons', async ({ | ||
page, | ||
}) => { | ||
//Arrange one Input component | ||
const addInputIntoCanvas = ['Input']; | ||
await addComponentsToCanvas(page, addInputIntoCanvas); | ||
|
||
//Copy and assert there are only one component within the canvas | ||
await clickCopyUiButton(page); | ||
const insideCanvasItemList = (await getWithinCanvasItemList( | ||
page | ||
)) as E2E_CanvasItemKeyAttrs[]; | ||
expect(insideCanvasItemList.length).toEqual(1); | ||
|
||
//Paste and assert there are 2 Input Components and that they have different IDs | ||
await clickPasteUiButton(page); | ||
const updatedInsideCanvasItemList = (await getWithinCanvasItemList( | ||
page | ||
)) as E2E_CanvasItemKeyAttrs[]; | ||
const [originalComponent, copiedComponent] = updatedInsideCanvasItemList; | ||
|
||
expect(updatedInsideCanvasItemList.length).toEqual(2); | ||
expect(originalComponent.shapeType).toEqual(copiedComponent.shapeType); | ||
expect(originalComponent['data-id']).not.toEqual( | ||
copiedComponent['data-id'] | ||
); | ||
}); | ||
|
||
test('Should copy and paste a single shape using keyboard commands', async ({ | ||
page, | ||
}) => { | ||
// NOTE: This test has the same steps as the previous one, except for the keyboard commands. | ||
//Arrange one Input component | ||
const addInputIntoCanvas = ['Input']; | ||
await addComponentsToCanvas(page, addInputIntoCanvas); | ||
|
||
//Copy and assert there are only one component within the canvas | ||
await page.keyboard.press('ControlOrMeta+c'); | ||
const insideCanvasItemList = (await getWithinCanvasItemList( | ||
page | ||
)) as E2E_CanvasItemKeyAttrs[]; | ||
expect(insideCanvasItemList.length).toEqual(1); | ||
|
||
//Paste and assert there are 2 Input Components and that they have different IDs | ||
await page.keyboard.press('ControlOrMeta+v'); | ||
const updatedInsideCanvasItemList = (await getWithinCanvasItemList( | ||
page | ||
)) as E2E_CanvasItemKeyAttrs[]; | ||
const [originalComponent, copiedComponent] = updatedInsideCanvasItemList; | ||
|
||
expect(updatedInsideCanvasItemList.length).toEqual(2); | ||
expect(originalComponent.shapeType).toEqual(copiedComponent.shapeType); | ||
expect(originalComponent['data-id']).not.toEqual( | ||
copiedComponent['data-id'] | ||
); | ||
}); | ||
|
||
/* | ||
test('Should copy and paste a multiple shapes using the ToolBar UI buttons', async ({ | ||
page, | ||
}) => { | ||
//Add several components into the canvas | ||
const addInputIntoCanvas = ['Input', 'Combobox', 'Icon']; | ||
await addComponentsToCanvas(page, addInputIntoCanvas); | ||
//Select items by drag and drop | ||
await dragAndDrop(page, { x: 260, y: 130 }, { x: 1000, y: 550 }); | ||
//Copy and assert there are 3 components within the canvas | ||
await clickCopyUiButton(page); | ||
const insideCanvasItemList = (await getWithinCanvasItemList( | ||
page | ||
)) as E2E_CanvasItemKeyAttrs[]; | ||
const [originalComp_1, originalComp_2, originalComp_3] = | ||
insideCanvasItemList; | ||
expect(insideCanvasItemList.length).toEqual(3); | ||
//Paste | ||
await clickPasteUiButton(page); | ||
const updatedInsideCanvasItemList = (await getWithinCanvasItemList( | ||
page | ||
)) as E2E_CanvasItemKeyAttrs[]; | ||
const [, , , copiedComp_1, copiedComp_2, copiedComp_3] = | ||
updatedInsideCanvasItemList; | ||
//Assert there are 6 Components, | ||
expect(updatedInsideCanvasItemList.length).toEqual(6); | ||
//Assert they match the same shapes respectively | ||
expect(originalComp_1.shapeType).toEqual(copiedComp_1.shapeType); | ||
expect(originalComp_2.shapeType).toEqual(copiedComp_2.shapeType); | ||
expect(originalComp_3.shapeType).toEqual(copiedComp_3.shapeType); | ||
//Assert they have different IDs | ||
expect(originalComp_1['data-id']).not.toEqual(copiedComp_1['data-id']); | ||
expect(originalComp_2['data-id']).not.toEqual(copiedComp_2['data-id']); | ||
expect(originalComp_3['data-id']).not.toEqual(copiedComp_3['data-id']); | ||
}); | ||
*/ | ||
test('Should copy and paste a multiple shapes using keyboard commands', async ({ | ||
page, | ||
}) => { | ||
// NOTE: This test has the same steps as the previous one, except for the keyboard commands. | ||
//Add several components into the canvas | ||
const addInputIntoCanvas = ['Input', 'Combobox', 'Icon']; | ||
await addComponentsToCanvas(page, addInputIntoCanvas); | ||
|
||
//Select items by drag and drop | ||
await dragAndDrop(page, { x: 260, y: 130 }, { x: 1000, y: 550 }); | ||
|
||
//Copy and assert there are 3 components within the canvas | ||
await page.keyboard.press('ControlOrMeta+c'); | ||
const insideCanvasItemList = (await getWithinCanvasItemList( | ||
page | ||
)) as E2E_CanvasItemKeyAttrs[]; | ||
const [originalComp_1, originalComp_2, originalComp_3] = | ||
insideCanvasItemList; | ||
expect(insideCanvasItemList.length).toEqual(3); | ||
|
||
//Paste | ||
await page.keyboard.press('ControlOrMeta+v'); | ||
const updatedInsideCanvasItemList = (await getWithinCanvasItemList( | ||
page | ||
)) as E2E_CanvasItemKeyAttrs[]; | ||
const [, , , copiedComp_1, copiedComp_2, copiedComp_3] = | ||
updatedInsideCanvasItemList; | ||
|
||
//Assert there are 6 Components, | ||
expect(updatedInsideCanvasItemList.length).toEqual(6); | ||
|
||
//Assert they match the same shapes respectively | ||
expect(originalComp_1.shapeType).toEqual(copiedComp_1.shapeType); | ||
expect(originalComp_2.shapeType).toEqual(copiedComp_2.shapeType); | ||
expect(originalComp_3.shapeType).toEqual(copiedComp_3.shapeType); | ||
|
||
//Assert they have different IDs | ||
expect(originalComp_1['data-id']).not.toEqual(copiedComp_1['data-id']); | ||
expect(originalComp_2['data-id']).not.toEqual(copiedComp_2['data-id']); | ||
expect(originalComp_3['data-id']).not.toEqual(copiedComp_3['data-id']); | ||
}); | ||
}); |
Oops, something went wrong.