-
Notifications
You must be signed in to change notification settings - Fork 1
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
f24e283
commit 09982a0
Showing
4 changed files
with
219 additions
and
0 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,98 @@ | ||
import { expect, test } from '@playwright/test' | ||
|
||
test('Read only primitives', async ({ page }) => { | ||
await page.goto('http://localhost:3000/') | ||
await page.getByText('plugins', { exact: true }).click() | ||
await page.getByText('form').click() | ||
await page.getByText('read_only_primitives').click() | ||
await page.getByText('ReadOnlyPrimitives').click() | ||
|
||
const checkNotEditable = async () => { | ||
await expect( | ||
page.getByTestId('stringRequired').getByTestId('form-textfield') | ||
).not.toBeEditable() | ||
|
||
await expect( | ||
page.getByTestId('stringOptional').getByTestId('form-textfield') | ||
).not.toBeEditable() | ||
|
||
await expect( | ||
page.getByTestId('numberRequired').getByTestId('form-textfield') | ||
).not.toBeEditable() | ||
|
||
await expect( | ||
page.getByTestId('numberOptional').getByTestId('form-textfield') | ||
).not.toBeEditable() | ||
|
||
await expect( | ||
page.getByTestId('integer').getByTestId('form-textfield') | ||
).not.toBeEditable() | ||
|
||
await expect( | ||
page.getByTestId('checkboxOptional').getByTestId('form-checkbox') | ||
).not.toBeEditable() | ||
|
||
await expect( | ||
page.getByTestId('checkboxRequired').getByTestId('form-checkbox') | ||
).not.toBeEditable() | ||
} | ||
|
||
await checkNotEditable() | ||
|
||
await page.getByRole('button', { name: 'Edit' }).click() | ||
|
||
await expect( | ||
page.getByTestId('stringRequired').getByTestId('form-textfield') | ||
).toBeEditable() | ||
await page | ||
.getByTestId('stringRequired') | ||
.getByTestId('form-textfield') | ||
.fill('Updated required string') | ||
|
||
await expect( | ||
page.getByTestId('stringOptional').getByTestId('form-textfield') | ||
).toBeEditable() | ||
await page | ||
.getByTestId('stringOptional') | ||
.getByTestId('form-textfield') | ||
.fill('Updated optional string') | ||
|
||
await expect( | ||
page.getByTestId('numberRequired').getByTestId('form-textfield') | ||
).toBeEditable() | ||
await page | ||
.getByTestId('numberRequired') | ||
.getByTestId('form-textfield') | ||
.fill('2.2') | ||
|
||
await expect( | ||
page.getByTestId('numberOptional').getByTestId('form-textfield') | ||
).toBeEditable() | ||
await page.getByTestId('numberOptional').getByTestId('form-textfield').clear() | ||
|
||
await expect( | ||
page.getByTestId('integer').getByTestId('form-textfield') | ||
).toBeEditable() | ||
await page.getByTestId('integer').getByTestId('form-textfield').fill('33') | ||
|
||
await expect( | ||
page.getByTestId('checkboxOptional').getByTestId('form-checkbox') | ||
).toBeEditable() | ||
await page | ||
.getByTestId('checkboxOptional') | ||
.getByTestId('form-checkbox') | ||
.check() | ||
|
||
await expect( | ||
page.getByTestId('checkboxRequired').getByTestId('form-checkbox') | ||
).toBeEditable() | ||
await page | ||
.getByTestId('checkboxRequired') | ||
.getByTestId('form-checkbox') | ||
.uncheck() | ||
|
||
await page.getByRole('button', { name: 'Submit' }).click() | ||
await expect(page.getByRole('alert')).toHaveText(['Document updated']) | ||
|
||
await checkNotEditable() | ||
}) |
65 changes: 65 additions & 0 deletions
65
...DataSource/plugins/form/read_only_primitives/blueprints/ReadOnlyPrimitives.blueprint.json
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,65 @@ | ||
{ | ||
"name": "ReadOnlyPrimitives", | ||
"type": "CORE:Blueprint", | ||
"attributes": [ | ||
{ | ||
"name": "type", | ||
"type": "dmss://system/SIMOS/BlueprintAttribute", | ||
"attributeType": "string" | ||
}, | ||
{ | ||
"name": "name", | ||
"type": "dmss://system/SIMOS/BlueprintAttribute", | ||
"attributeType": "string" | ||
}, | ||
{ | ||
"name": "stringOptional", | ||
"type": "CORE:BlueprintAttribute", | ||
"attributeType": "string", | ||
"label": "An optional string", | ||
"optional": true | ||
}, | ||
{ | ||
"name": "stringRequired", | ||
"type": "CORE:BlueprintAttribute", | ||
"attributeType": "string", | ||
"label": "A required string", | ||
"optional": false | ||
}, | ||
{ | ||
"name": "numberRequired", | ||
"type": "CORE:BlueprintAttribute", | ||
"attributeType": "number", | ||
"label": "A required number", | ||
"optional": false | ||
}, | ||
{ | ||
"name": "numberOptional", | ||
"type": "CORE:BlueprintAttribute", | ||
"attributeType": "number", | ||
"label": "Numbers only", | ||
"optional": true | ||
}, | ||
{ | ||
"name": "integer", | ||
"type": "CORE:BlueprintAttribute", | ||
"attributeType": "integer", | ||
"label": "Integer only", | ||
"optional": true | ||
}, | ||
{ | ||
"name": "checkboxOptional", | ||
"type": "CORE:BlueprintAttribute", | ||
"attributeType": "boolean", | ||
"label": "An optional checkbox", | ||
"optional": true | ||
}, | ||
{ | ||
"name": "checkboxRequired", | ||
"type": "CORE:BlueprintAttribute", | ||
"attributeType": "boolean", | ||
"label": "A required checbox (e.g. for confirmation purposes)", | ||
"optional": false | ||
} | ||
] | ||
} |
11 changes: 11 additions & 0 deletions
11
.../app/data/DemoDataSource/plugins/form/read_only_primitives/readOnlyPrimitives.entity.json
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,11 @@ | ||
{ | ||
"_id": "readOnlyPrimitives", | ||
"name": "ReadOnlyPrimitives", | ||
"type": "./blueprints/ReadOnlyPrimitives", | ||
"stringRequired": "A required string", | ||
"stringOptional": "an optional string", | ||
"numberRequired": 2, | ||
"numberOptional": 3.14, | ||
"checkboxOptional": false, | ||
"checkboxRequired": true | ||
} |
45 changes: 45 additions & 0 deletions
45
...a/DemoDataSource/recipes/plugins/form/read_only_primitives/readOnlyPrimitives.recipe.json
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,45 @@ | ||
{ | ||
"type": "CORE:RecipeLink", | ||
"_blueprintPath_": "/plugins/form/read_only_primitives/blueprints/ReadOnlyPrimitives", | ||
"initialUiRecipe": { | ||
"name": "ViewSelector", | ||
"type": "CORE:UiRecipe", | ||
"plugin": "@development-framework/dm-core-plugins/view_selector", | ||
"config": { | ||
"type": "PLUGINS:dm-core-plugins/view_selector/ViewSelectorConfig", | ||
"childTabsOnRender": true, | ||
"asSidebar": false, | ||
"items": [ | ||
{ | ||
"type": "PLUGINS:dm-core-plugins/view_selector/ViewSelectorItem", | ||
"view": { | ||
"type": "CORE:ReferenceViewConfig", | ||
"recipe": "ReadOnly" | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
"uiRecipes": [ | ||
{ | ||
"name": "ReadOnly", | ||
"type": "CORE:UiRecipe", | ||
"plugin": "@development-framework/dm-core-plugins/form", | ||
"category": "edit", | ||
"config": { | ||
"type": "PLUGINS:dm-core-plugins/form/FormInput", | ||
"fields": [ | ||
"stringRequired", | ||
"stringOptional", | ||
"numberRequired", | ||
"numberOptional", | ||
"integer", | ||
"checkboxOptional", | ||
"checkboxRequired" | ||
], | ||
"readOnly": true, | ||
"editToggle": true | ||
} | ||
} | ||
] | ||
} |