diff --git a/e2e/tests/plugin-form-ReadOnlyPrimitives.spec.ts b/e2e/tests/plugin-form-ReadOnlyPrimitives.spec.ts index 2230854af..9a7939086 100755 --- a/e2e/tests/plugin-form-ReadOnlyPrimitives.spec.ts +++ b/e2e/tests/plugin-form-ReadOnlyPrimitives.spec.ts @@ -7,92 +7,23 @@ test('Read only primitives', async ({ page }) => { 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.getByLabel('A required string')).not.toBeEditable() await expect( - page.getByTestId('stringRequired').getByTestId('form-textfield') - ).toBeEditable() - await page - .getByTestId('stringRequired') - .getByTestId('form-textfield') - .fill('Updated required string') + page.getByLabel('An optional string (optional)') + ).not.toBeEditable() - await expect( - page.getByTestId('stringOptional').getByTestId('form-textfield') - ).toBeEditable() - await page - .getByTestId('stringOptional') - .getByTestId('form-textfield') - .fill('Updated optional string') + await expect(page.getByLabel('A required number')).not.toBeEditable() - await expect( - page.getByTestId('numberRequired').getByTestId('form-textfield') - ).toBeEditable() - await page - .getByTestId('numberRequired') - .getByTestId('form-textfield') - .fill('2.2') + await expect(page.getByLabel('Numbers only (optional)')).not.toBeEditable() - await expect( - page.getByTestId('numberOptional').getByTestId('form-textfield') - ).toBeEditable() - await page.getByTestId('numberOptional').getByTestId('form-textfield').clear() + await expect(page.getByLabel('Integer only (optional)')).not.toBeEditable() await expect( - page.getByTestId('integer').getByTestId('form-textfield') - ).toBeEditable() - await page.getByTestId('integer').getByTestId('form-textfield').fill('33') + page.getByLabel('An optional checkbox (optional)') + ).not.toBeEditable() 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() + page.getByLabel('A required checbox (e.g. for confirmation purposes)') + ).not.toBeEditable() }) diff --git a/example/app/data/DemoDataSource/plugins/form/read_only_primitives/readOnlyPrimitives.entity.json b/example/app/data/DemoDataSource/plugins/form/read_only_primitives/readOnlyPrimitives.entity.json index 17e86607a..f6fe2aff0 100644 --- a/example/app/data/DemoDataSource/plugins/form/read_only_primitives/readOnlyPrimitives.entity.json +++ b/example/app/data/DemoDataSource/plugins/form/read_only_primitives/readOnlyPrimitives.entity.json @@ -4,8 +4,9 @@ "type": "./blueprints/ReadOnlyPrimitives", "stringRequired": "A required string", "stringOptional": "an optional string", - "numberRequired": 2, + "numberRequired": 2.34, "numberOptional": 3.14, + "integer": 30, "checkboxOptional": false, "checkboxRequired": true } diff --git a/example/app/data/DemoDataSource/recipes/plugins/form/read_only_primitives/readOnlyPrimitives.recipe.json b/example/app/data/DemoDataSource/recipes/plugins/form/read_only_primitives/readOnlyPrimitives.recipe.json index cb8fcbc96..b40b55f23 100644 --- a/example/app/data/DemoDataSource/recipes/plugins/form/read_only_primitives/readOnlyPrimitives.recipe.json +++ b/example/app/data/DemoDataSource/recipes/plugins/form/read_only_primitives/readOnlyPrimitives.recipe.json @@ -37,8 +37,7 @@ "checkboxOptional", "checkboxRequired" ], - "readOnly": true, - "editToggle": true + "readOnly": true } } ]