-
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 #443 from Lemoncode/dev
New minor release, fixes, new components and new icons
- Loading branch information
Showing
116 changed files
with
1,802 additions
and
779 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 @@ | ||
NODE_ENV=test |
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,63 @@ | ||
import { test, expect } from '@playwright/test'; | ||
import { Group } from 'konva/lib/Group'; | ||
import { dragAndDrop, getByShapeType, getLocatorPosition } from '../helpers'; | ||
|
||
test('can add input component to canvas and edit', async ({ page }) => { | ||
await page.goto(''); | ||
const component = page.getByAltText('Input', { exact: true }); | ||
|
||
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); | ||
const input = page.getByRole('textbox').first(); | ||
const inputValue = await input.getAttribute('value'); | ||
expect(inputValue).toEqual('Placeholder'); | ||
|
||
const textContent = 'User'; | ||
await input.fill(textContent); | ||
await page.keyboard.press('Enter'); | ||
const inputShape = (await getByShapeType(page, 'input')) as Group; | ||
expect(inputShape).toBeDefined(); | ||
const textShape = inputShape.children.find( | ||
child => child.attrs.text === textContent | ||
); | ||
expect(textShape).toBeDefined(); | ||
}); | ||
|
||
test('can add and edit input, and delete last letter', async ({ page }) => { | ||
await page.goto(''); | ||
const component = page.getByAltText('Input', { exact: true }); | ||
|
||
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); | ||
|
||
const input = page.getByRole('textbox').first(); | ||
const inputValue = await input.getAttribute('value'); | ||
expect(inputValue).toEqual('Placeholder'); | ||
|
||
const textContent = 'user'; | ||
await input.fill(textContent); | ||
|
||
await page.keyboard.press('Backspace'); | ||
|
||
const updatedInputValue = await input.inputValue(); | ||
expect(updatedInputValue).toEqual('use'); | ||
|
||
await page.keyboard.press('Enter'); | ||
|
||
const inputShape = (await getByShapeType(page, 'input')) as Group; | ||
expect(inputShape).toBeDefined(); | ||
const textShape = inputShape.children.find( | ||
child => child.attrs.text === 'use' | ||
); | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import { test, expect } from '@playwright/test'; | ||
import { | ||
dragAndDrop, | ||
getByShapeType, | ||
getLocatorPosition, | ||
getTransformer, | ||
getAllByShapeType, | ||
} from '../helpers'; | ||
import { Group } from 'konva/lib/Group'; | ||
|
||
test('drop new shape in canvas, ensure new is selected, former is unselected - different shapes', 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 transformer = await getTransformer(page); | ||
expect(transformer).toBeDefined(); | ||
expect(transformer.index).toEqual(1); | ||
expect(transformer._nodes.length).toEqual(1); | ||
|
||
const component2 = page.getByAltText('Label', { exact: true }); | ||
expect(component2).toBeDefined(); | ||
|
||
const offset = 200; | ||
|
||
const position2 = await getLocatorPosition(component2); | ||
await dragAndDrop(page, position2, { | ||
x: position2.x + 500 + offset, | ||
y: position2.y - 240 + offset, | ||
}); | ||
|
||
const inputShape2 = (await getByShapeType(page, 'label')) as Group; | ||
expect(inputShape2).toBeDefined(); | ||
|
||
const transformer2 = await getTransformer(page); | ||
expect(transformer2).toBeDefined(); | ||
expect(transformer2.index).toEqual(2); | ||
expect(transformer2._nodes.length).toEqual(1); | ||
}); | ||
|
||
test('drop new shape in canvas, ensure new is selected, former is unselected - same shapes', 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 inputShapes: Group[] = (await getAllByShapeType( | ||
page, | ||
'input' | ||
)) as Group[]; | ||
expect(inputShapes[0]).toBeDefined(); | ||
|
||
const transformer = await getTransformer(page); | ||
expect(transformer).toBeDefined(); | ||
expect(transformer.index).toEqual(1); | ||
expect(transformer._nodes.length).toEqual(1); | ||
|
||
const component2 = page.getByAltText('Input', { exact: true }); | ||
expect(component2).toBeDefined(); | ||
|
||
const offset = 200; | ||
|
||
const position2 = await getLocatorPosition(component2); | ||
await dragAndDrop(page, position2, { | ||
x: position2.x + 500 + offset, | ||
y: position2.y - 240 + offset, | ||
}); | ||
|
||
const inputShapes2: Group[] = (await getAllByShapeType( | ||
page, | ||
'input' | ||
)) as Group[]; | ||
expect(inputShapes2[1]).toBeDefined(); | ||
expect(inputShapes2.length).toEqual(2); | ||
|
||
const transformer2 = await getTransformer(page); | ||
expect(transformer2).toBeDefined(); | ||
expect(transformer2.index).toEqual(2); | ||
expect(transformer2._nodes.length).toEqual(1); | ||
}); |
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,22 @@ | ||
import { test, expect } from '@playwright/test'; | ||
import { dragAndDrop, addComponentsToCanvas, getTransformer } from '../helpers'; | ||
|
||
test('Should perform multiple selection when dragging and dropping over multiple components in the canvas', async ({ | ||
page, | ||
}) => { | ||
await page.goto(''); | ||
|
||
//Drag and drop component to canvas | ||
const componentsAtCanvas = ['Input', 'Input', 'Icon', 'Label']; | ||
await addComponentsToCanvas(page, componentsAtCanvas); | ||
|
||
//Click Away | ||
await page.mouse.click(800, 130); | ||
|
||
//Perform items selection by drag and drop | ||
await dragAndDrop(page, { x: 260, y: 130 }, { x: 1000, y: 550 }); | ||
|
||
//Assert | ||
const selectedItems = await getTransformer(page); | ||
expect(selectedItems._nodes.length).toEqual(3); | ||
}); |
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,55 @@ | ||
import { test, expect } from '@playwright/test'; | ||
import { | ||
dragAndDrop, | ||
getByShapeType, | ||
getLocatorPosition, | ||
getTransformer, | ||
} from '../helpers'; | ||
import { Group } from 'konva/lib/Group'; | ||
|
||
test('no shapes on canvas, transformer not defined', async ({ page }) => { | ||
await page.goto(''); | ||
const transformer = await getTransformer(page); | ||
expect(transformer).not.toBeDefined(); | ||
}); | ||
|
||
test('drop shape in canvas, ensure is selected', 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 transformer = await getTransformer(page); | ||
expect(transformer).toBeDefined(); | ||
expect(transformer.index).toEqual(1); | ||
expect(transformer._nodes.length).toEqual(1); | ||
}); | ||
|
||
test('drop shape in canvas, click on canvas, drop diselected', 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(); | ||
|
||
await page.click('canvas'); | ||
|
||
const transformer = await getTransformer(page); | ||
expect(transformer).toBeDefined(); | ||
expect(transformer.index).toEqual(1); | ||
expect(transformer._nodes.length).toEqual(0); | ||
}); |
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,7 @@ | ||
import Konva from 'konva'; | ||
|
||
declare global { | ||
interface Window { | ||
__TESTING_KONVA_LAYER__: Konva.Layer; | ||
} | ||
} |
Oops, something went wrong.