Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/update requirments #503

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
}
]
}
2 changes: 1 addition & 1 deletion example/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
dm-cli==1.1.0
dm-cli==1.1.1