Skip to content

Commit

Permalink
fix: updated based on #499 and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
roar-larsen committed Sep 15, 2023
1 parent 09982a0 commit 7e5d333
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 82 deletions.
89 changes: 10 additions & 79 deletions e2e/tests/plugin-form-ReadOnlyPrimitives.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@
"checkboxOptional",
"checkboxRequired"
],
"readOnly": true,
"editToggle": true
"readOnly": true
}
}
]
Expand Down

0 comments on commit 7e5d333

Please sign in to comment.