-
-
Notifications
You must be signed in to change notification settings - Fork 337
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
1 parent
435a6a6
commit bbaaec7
Showing
16 changed files
with
516 additions
and
33 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
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 was deleted.
Oops, something went wrong.
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,86 @@ | ||
{ | ||
"root": "y3c19mb", | ||
"nodes": { | ||
"ft63r75": { | ||
"id": "ft63r75", | ||
"name": "textField1", | ||
"type": "element", | ||
"props": { | ||
"label": { | ||
"type": "const", | ||
"value": "textField1" | ||
} | ||
}, | ||
"layout": {}, | ||
"parentId": "w173rcy", | ||
"attributes": { | ||
"component": { | ||
"type": "const", | ||
"value": "TextField" | ||
} | ||
}, | ||
"parentProp": "children", | ||
"parentIndex": "a0" | ||
}, | ||
"rl83rbf": { | ||
"id": "rl83rbf", | ||
"name": "textField2", | ||
"type": "element", | ||
"props": { | ||
"label": { | ||
"type": "const", | ||
"value": "textField2" | ||
} | ||
}, | ||
"layout": {}, | ||
"parentId": "w173rcy", | ||
"attributes": { | ||
"component": { | ||
"type": "const", | ||
"value": "TextField" | ||
} | ||
}, | ||
"parentProp": "children", | ||
"parentIndex": "a1" | ||
}, | ||
"w173rcy": { | ||
"id": "w173rcy", | ||
"name": "pageRow", | ||
"type": "element", | ||
"props": {}, | ||
"layout": {}, | ||
"parentId": "y4d19z0", | ||
"attributes": { | ||
"component": { | ||
"type": "const", | ||
"value": "PageRow" | ||
} | ||
}, | ||
"parentProp": "children", | ||
"parentIndex": "a0" | ||
}, | ||
"y3c19mb": { | ||
"id": "y3c19mb", | ||
"name": "Application", | ||
"type": "app", | ||
"parentId": null, | ||
"attributes": {}, | ||
"parentProp": null, | ||
"parentIndex": null | ||
}, | ||
"y4d19z0": { | ||
"id": "y4d19z0", | ||
"name": "page1", | ||
"type": "page", | ||
"parentId": "y3c19mb", | ||
"attributes": { | ||
"title": { | ||
"type": "const", | ||
"value": "Page 1" | ||
} | ||
}, | ||
"parentProp": "pages", | ||
"parentIndex": "a0" | ||
} | ||
} | ||
} |
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,136 @@ | ||
import { test, expect } from '@playwright/test'; | ||
import { ToolpadHome } from '../../models/ToolpadHome'; | ||
import { ToolpadEditor } from '../../models/ToolpadEditor'; | ||
import clickCenter from '../../utils/clickCenter'; | ||
import domInput from './domInput.json'; | ||
|
||
test('can place new components from catalog', async ({ page, browserName }) => { | ||
const homeModel = new ToolpadHome(page); | ||
const editorModel = new ToolpadEditor(page, browserName); | ||
|
||
await homeModel.goto(); | ||
const app = await homeModel.createApplication({}); | ||
await editorModel.goto(app.id); | ||
|
||
await editorModel.pageRoot.waitFor(); | ||
|
||
const canvasInputLocator = editorModel.appCanvas.locator('input'); | ||
|
||
await expect(canvasInputLocator).toHaveCount(0); | ||
|
||
const TEXT_FIELD_COMPONENT_ID = 'TextField'; | ||
|
||
// Drag in a first component | ||
|
||
await editorModel.dragNewComponentToAppCanvas(TEXT_FIELD_COMPONENT_ID); | ||
|
||
await expect(canvasInputLocator).toHaveCount(1); | ||
await expect(canvasInputLocator).toBeVisible(); | ||
|
||
// Drag in a second component | ||
|
||
await editorModel.dragNewComponentToAppCanvas(TEXT_FIELD_COMPONENT_ID); | ||
|
||
await expect(canvasInputLocator).toHaveCount(2); | ||
}); | ||
|
||
test('can move elements in page', async ({ page, browserName }) => { | ||
const homeModel = new ToolpadHome(page); | ||
const editorModel = new ToolpadEditor(page, browserName); | ||
|
||
await homeModel.goto(); | ||
const app = await homeModel.createApplication({ dom: domInput }); | ||
await editorModel.goto(app.id); | ||
|
||
await editorModel.pageRoot.waitFor(); | ||
|
||
const canvasMoveElementHandleSelector = ':has-text("TextField")[draggable]'; | ||
|
||
const canvasInputLocator = editorModel.appCanvas.locator('input'); | ||
const canvasMoveElementHandleLocator = editorModel.appCanvas.locator( | ||
canvasMoveElementHandleSelector, | ||
); | ||
|
||
const firstTextFieldLocator = canvasInputLocator.first(); | ||
const secondTextFieldLocator = canvasInputLocator.nth(1); | ||
|
||
await firstTextFieldLocator.focus(); | ||
await firstTextFieldLocator.fill('textField1'); | ||
|
||
await secondTextFieldLocator.focus(); | ||
await secondTextFieldLocator.fill('textField2'); | ||
|
||
await expect(firstTextFieldLocator).toHaveAttribute('value', 'textField1'); | ||
await expect(secondTextFieldLocator).toHaveAttribute('value', 'textField2'); | ||
|
||
await expect(canvasMoveElementHandleLocator).not.toBeVisible(); | ||
|
||
// Move first element by dragging it to the right side of second element | ||
|
||
await clickCenter(page, firstTextFieldLocator); | ||
|
||
const secondTextFieldBoundingBox = await secondTextFieldLocator.boundingBox(); | ||
expect(secondTextFieldBoundingBox).toBeDefined(); | ||
|
||
const moveTargetX = secondTextFieldBoundingBox!.x + secondTextFieldBoundingBox!.width; | ||
const moveTargetY = secondTextFieldBoundingBox!.y + secondTextFieldBoundingBox!.height / 2; | ||
|
||
await editorModel.dragToAppCanvas( | ||
canvasMoveElementHandleSelector, | ||
true, | ||
moveTargetX, | ||
moveTargetY, | ||
); | ||
|
||
await expect(firstTextFieldLocator).toHaveAttribute('value', 'textField2'); | ||
await expect(secondTextFieldLocator).toHaveAttribute('value', 'textField1'); | ||
}); | ||
|
||
test('can delete elements from page', async ({ page, browserName }) => { | ||
const homeModel = new ToolpadHome(page); | ||
const editorModel = new ToolpadEditor(page, browserName); | ||
|
||
await homeModel.goto(); | ||
const app = await homeModel.createApplication({ dom: domInput }); | ||
await editorModel.goto(app.id); | ||
|
||
await editorModel.pageRoot.waitFor(); | ||
|
||
const canvasInputLocator = editorModel.appCanvas.locator('input'); | ||
const canvasRemoveElementButtonLocator = editorModel.appCanvas.locator( | ||
'button[aria-label="Remove element"]', | ||
); | ||
|
||
await expect(canvasInputLocator).toHaveCount(2); | ||
|
||
// Delete element by clicking | ||
|
||
await expect(canvasRemoveElementButtonLocator).not.toBeVisible(); | ||
|
||
const firstTextFieldLocator = canvasInputLocator.first(); | ||
|
||
await clickCenter(page, firstTextFieldLocator); | ||
await canvasRemoveElementButtonLocator.click(); | ||
|
||
await expect(canvasInputLocator).toHaveCount(1); | ||
|
||
// Delete element by pressing key | ||
|
||
await clickCenter(page, firstTextFieldLocator); | ||
await page.keyboard.press('Backspace'); | ||
|
||
await expect(canvasInputLocator).toHaveCount(0); | ||
}); | ||
|
||
test('can create new component', async ({ page, browserName }) => { | ||
const homeModel = new ToolpadHome(page); | ||
const editorModel = new ToolpadEditor(page, browserName); | ||
|
||
await homeModel.goto(); | ||
const app = await homeModel.createApplication({}); | ||
|
||
await editorModel.goto(app.id); | ||
|
||
await editorModel.createPage('somePage'); | ||
await editorModel.createComponent('someComponent'); | ||
}); |
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,86 @@ | ||
{ | ||
"root": "y3c19mb", | ||
"nodes": { | ||
"ft63r75": { | ||
"id": "ft63r75", | ||
"name": "textField1", | ||
"type": "element", | ||
"props": { | ||
"label": { | ||
"type": "const", | ||
"value": "textField1" | ||
} | ||
}, | ||
"layout": {}, | ||
"parentId": "w173rcy", | ||
"attributes": { | ||
"component": { | ||
"type": "const", | ||
"value": "TextField" | ||
} | ||
}, | ||
"parentProp": "children", | ||
"parentIndex": "a0" | ||
}, | ||
"rl83rbf": { | ||
"id": "rl83rbf", | ||
"name": "textField2", | ||
"type": "element", | ||
"props": { | ||
"label": { | ||
"type": "const", | ||
"value": "textField2" | ||
} | ||
}, | ||
"layout": {}, | ||
"parentId": "w173rcy", | ||
"attributes": { | ||
"component": { | ||
"type": "const", | ||
"value": "TextField" | ||
} | ||
}, | ||
"parentProp": "children", | ||
"parentIndex": "a1" | ||
}, | ||
"w173rcy": { | ||
"id": "w173rcy", | ||
"name": "pageRow", | ||
"type": "element", | ||
"props": {}, | ||
"layout": {}, | ||
"parentId": "y4d19z0", | ||
"attributes": { | ||
"component": { | ||
"type": "const", | ||
"value": "PageRow" | ||
} | ||
}, | ||
"parentProp": "children", | ||
"parentIndex": "a0" | ||
}, | ||
"y3c19mb": { | ||
"id": "y3c19mb", | ||
"name": "Application", | ||
"type": "app", | ||
"parentId": null, | ||
"attributes": {}, | ||
"parentProp": null, | ||
"parentIndex": null | ||
}, | ||
"y4d19z0": { | ||
"id": "y4d19z0", | ||
"name": "page1", | ||
"type": "page", | ||
"parentId": "y3c19mb", | ||
"attributes": { | ||
"title": { | ||
"type": "const", | ||
"value": "Page 1" | ||
} | ||
}, | ||
"parentProp": "pages", | ||
"parentIndex": "a0" | ||
} | ||
} | ||
} |
Oops, something went wrong.