Skip to content

Commit

Permalink
test: readonly primitives
Browse files Browse the repository at this point in the history
  • Loading branch information
roar-larsen committed Sep 15, 2023
1 parent f24e283 commit 09982a0
Show file tree
Hide file tree
Showing 4 changed files with 219 additions and 0 deletions.
98 changes: 98 additions & 0 deletions e2e/tests/plugin-form-ReadOnlyPrimitives.spec.ts
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()
})
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
}
]
}
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
}
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
}
}
]
}

0 comments on commit 09982a0

Please sign in to comment.