Skip to content

Commit

Permalink
fix: update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
awesthouse committed Jun 17, 2024
1 parent f3ce0d3 commit ebc8c9f
Show file tree
Hide file tree
Showing 16 changed files with 220 additions and 280 deletions.
3 changes: 1 addition & 2 deletions e2e/tests/plugin-form-Nested.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ test('View accountant yaml', async () => {

test('Adding a trainee', async () => {
const trainee = page.getByTestId('trainee')
// await trainee.getByLabel('Add and save').click()
await page.getByTestId('trainee').getByLabel('Create new entity').click()
await page.getByTestId('trainee').getByText('Create').click()
await trainee.getByTestId('form-text-widget-Name').fill('Peter Pan')
await trainee
.getByTestId('form-number-widget-Phone Number (Optional)')
Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/plugin-form-UncontainedObject.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ test('uncontainedObject', async ({ page }) => {
await test.step('Assert Accountant', async () => {
await page
.getByTestId('accountant')
.getByRole('button', { name: 'Collapse' })
.getByRole('button', { name: 'Collapse Accountant' })
.click()
await expect(
page.getByTestId('accountant').getByRole('code').getByText('Miranda')
Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/plugin-form-dimensional_scalar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ test('Dimensional scalar', async ({ page }) => {
page.getByTestId('maximumWaveHeight').getByRole('paragraph').first()
).toContainText('New Maximum')
await expect(
page.getByTestId('maximumWaveHeight').locator('span')
page.getByTestId('maximumWaveHeight').locator('span').locator('span')
).toContainText('€')
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ test('Model uncontained complex attribute', async ({ page }) => {
await expect(page.getByLabel('Name')).toHaveValue('TheBlackPearl')
await page.getByLabel('Open in tab').click()
await expect(page.getByRole('tab', { name: 'captain' })).toBeVisible()
await expect(
page.getByText('CaptainJackSparrow', { exact: true })
).toBeVisible()
await expect(page.getByRole('code')).toContainText('CaptainJackSparrow')
await page.getByRole('button', { name: 'Edit' }).nth(1).click()
await expect(page.getByRole('textbox')).toHaveValue('CaptainJackSparrow')
await expect(
Expand Down
20 changes: 10 additions & 10 deletions e2e/tests/plugin-form-relative_reference.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ test('Relative reference', async ({ page }) => {
await expect(page.getByRole('alert')).not.toBeVisible()
await page.getByRole('button', { name: 'Close data' }).click()

await page.getByTestId('job').getByText('Job').click()
await page.getByTestId('job').getByRole('button').first().click()
await expect(page.getByRole('code')).toBeVisible()
await page.getByRole('button', { name: 'Edit' }).last().click()
await page.getByTestId('input').getByText('Input').click()
Expand All @@ -40,7 +40,7 @@ test('Relative reference', async ({ page }) => {
await page.getByRole('button', { name: 'close', exact: true }).click()
await expect(page.getByRole('alert')).not.toBeVisible()
await page.getByRole('button', { name: 'Close job' }).click()
await page.getByTestId('data').getByText('Data').click()
await page.getByTestId('data').getByRole('button').first().click()
await expect(page.getByRole('code')).toBeVisible()
await page.getByRole('button', { name: 'Edit' }).last().click()
await expect(page.getByTestId('form-number-widget-A Number')).toHaveValue(
Expand All @@ -50,13 +50,13 @@ test('Relative reference', async ({ page }) => {
})

await test.step('Update local reference', async () => {
await page.getByTestId('task').getByText('Task').click()
await page.getByTestId('task').getByRole('button').first().click()
await expect(page.getByRole('code')).toBeVisible()
await page.getByRole('button', { name: 'Edit' }).last().click()
await expect(page.getByTestId('form-text-widget-Name').last()).toHaveValue(
'ChildTask'
)
await page.getByTestId('data').getByText('Data').last().click()
await page.getByTestId('data').getByRole('button').first().click()
await expect(page.getByRole('code')).toBeVisible()
await page.getByRole('button', { name: 'Edit' }).last().click()
await expect(page.getByTestId('form-number-widget-A Number')).toHaveValue(
Expand All @@ -68,7 +68,7 @@ test('Relative reference', async ({ page }) => {
await page.getByRole('button', { name: 'close', exact: true }).click()
await expect(page.getByRole('alert')).not.toBeVisible()
await page.getByRole('button', { name: 'Close data' }).click()
await page.getByTestId('job').getByText('Job').last().click()
await page.getByTestId('job').getByRole('button').first().click()
await expect(page.getByRole('code')).toBeVisible()
await page.getByRole('button', { name: 'Edit' }).last().click()
await page.getByTestId('input').getByText('Input').click()
Expand All @@ -78,7 +78,7 @@ test('Relative reference', async ({ page }) => {
'2'
)
await page.getByRole('button', { name: 'Close task' }).click()
await page.getByTestId('data').getByText('Data').click()
await page.getByTestId('data').getByRole('button').first().click()
await expect(page.getByRole('code')).toBeVisible()
await page.getByRole('button', { name: 'Edit' }).last().click()
await expect(page.getByTestId('form-number-widget-A Number')).toHaveValue(
Expand All @@ -88,11 +88,11 @@ test('Relative reference', async ({ page }) => {
})

await test.step('Nested local reference', async () => {
await page.getByTestId('tasks').getByText('Tasks').click()
await page.getByTestId('tasks').getByRole('button').first().click()
await page.getByTestId('expandListItem-0').click()
await expect(page.getByRole('code')).toBeVisible()
await page.getByRole('button', { name: 'Edit' }).last().click()
await page.getByText('Data', { exact: true }).nth(1).click()
await page.getByTestId('data').first().click()
await expect(page.getByRole('code')).toBeVisible()
await page.getByRole('button', { name: 'Edit' }).last().click()
await expect(page.getByTestId('form-number-widget-A Number')).toHaveValue(
Expand All @@ -104,10 +104,10 @@ test('Relative reference', async ({ page }) => {
await page.getByRole('button', { name: 'close', exact: true }).click()
await expect(page.getByRole('alert')).not.toBeVisible()
await page.getByRole('button', { name: 'Close data' }).click()
await page.getByText('Job', { exact: true }).nth(3).click()
await page.getByTestId('job').first().click()
await expect(page.getByRole('code')).toBeVisible()
await page.getByRole('button', { name: 'Edit' }).last().click()
await page.getByText('Input', { exact: true }).last().click()
await page.getByTestId('input').getByRole('button').first().click()
await expect(page.getByRole('code')).toBeVisible()
await page.getByRole('button', { name: 'Edit' }).last().click()
await expect(page.getByTestId('form-number-widget-A Number')).toHaveValue(
Expand Down
40 changes: 16 additions & 24 deletions e2e/tests/plugin-header-roles_header_example.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { expect, test } from '@playwright/test'

test.use({ permissions: ['clipboard-write'] })

test.beforeEach(async ({ page }) => {
await page.goto('http://localhost:3000/')
await page.getByRole('button', { name: 'DemoDataSource' }).click()
Expand All @@ -11,12 +13,10 @@ test.beforeEach(async ({ page }) => {

test('Admin role', async ({ page }) => {
await page.getByLabel('AppSelector').nth(1).click()
await expect(
page.getByRole('button', { name: 'Yaml', exact: true })
).toBeVisible()
await expect(page.getByRole('button', { name: 'Edit' })).toBeVisible()
await expect(page.getByRole('button', { name: 'Explorer' })).toBeVisible()
await page.getByRole('button', { name: 'Edit' }).click()
await expect(page.getByRole('menuitem', { name: 'Yaml' })).toBeVisible()
await expect(page.getByRole('menuitem', { name: 'Edit' })).toBeVisible()
await expect(page.getByRole('menuitem', { name: 'Explorer' })).toBeVisible()
await page.getByRole('menuitem', { name: 'Edit' }).click()
await expect(page.getByTestId('form-text-widget-Name')).toHaveValue(
'elonMusk'
)
Expand All @@ -31,16 +31,13 @@ test('Change to operator role and back', async ({ page }) => {

await test.step('Edit option not visible', async () => {
await page.getByLabel('AppSelector').nth(1).click()

await expect(
page.getByRole('button', { name: 'Yaml', exact: true })
).toBeVisible()
await expect(page.getByRole('button', { name: 'Edit' })).not.toBeVisible()
await expect(page.getByRole('button', { name: 'Explorer' })).toBeVisible()
await expect(page.getByRole('menuitem', { name: 'Yaml' })).toBeVisible()
await expect(page.getByRole('menuitem', { name: 'Edit' })).not.toBeVisible()
await expect(page.getByRole('menuitem', { name: 'Explorer' })).toBeVisible()
})

await test.step('Edit option not visible through Explorer', async () => {
await page.getByRole('button', { name: 'Explorer' }).click()
await page.getByRole('menuitem', { name: 'Explorer' }).click()
await page
.locator('li')
.filter({ hasText: /^data sourceDemoDataSource$/ })
Expand All @@ -64,25 +61,20 @@ test('Change to operator role and back', async ({ page }) => {
await page.getByRole('button', { name: 'file elonMusk' }).nth(1).click()
await expect(page.getByRole('code')).toBeVisible()
await page.getByLabel('AppSelector').nth(1).click()
await expect(
page.getByRole('button', { name: 'Yaml', exact: true })
).toBeVisible()
await expect(page.getByRole('button', { name: 'Edit' })).not.toBeVisible()
await expect(page.getByRole('button', { name: 'Explorer' })).toBeVisible()
await page.getByRole('button', { name: 'Yaml', exact: true }).click()
await expect(page.getByRole('menuitem', { name: 'Yaml' })).toBeVisible()
await expect(page.getByRole('menuitem', { name: 'Edit' })).not.toBeVisible()
await expect(page.getByRole('menuitem', { name: 'Explorer' })).toBeVisible()
await page.getByRole('menuitem', { name: 'Yaml' }).click()
})

await test.step('Change back to admin', async () => {
await page.getByLabel('AppSelector').nth(1).click()

await page
.getByRole('button', { name: 'Yaml', exact: true })
.first()
.click()
await page.getByRole('menuitem', { name: 'Yaml' }).first().click()
await page.getByRole('button', { name: 'User' }).click()
await page.getByLabel('admin').check()
await page.getByRole('button', { name: 'Save' }).click()
await page.getByLabel('AppSelector').nth(1).click()
await expect(page.getByRole('button', { name: 'Edit' })).toBeVisible()
await expect(page.getByRole('menuitem', { name: 'Edit' })).toBeVisible()
})
})
2 changes: 1 addition & 1 deletion e2e/tests/plugin-header.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ test('About', async ({ page }) => {

test('Recipe list', async ({ page }) => {
await page.getByLabel('AppSelector').click()
await page.getByRole('button', { name: 'Edit' }).click()
await page.getByRole('menuitem', { name: 'Edit' }).click()
await expect(page.getByTestId('form-text-widget-Name')).toHaveValue('example')
})
Loading

0 comments on commit ebc8c9f

Please sign in to comment.