Skip to content

Commit

Permalink
fix: update tests with new menu button
Browse files Browse the repository at this point in the history
  • Loading branch information
roar-larsen authored and pbullhove committed Nov 22, 2023
1 parent cc5c06a commit 6767ab0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
37 changes: 24 additions & 13 deletions e2e/tests/plugin-header-roles_header_example.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ test.beforeEach(async ({ page }) => {

test('Admin role', async ({ page }) => {
await page.getByRole('button', { name: 'Menu' }).nth(1).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.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.getByTestId('form-text-widget-Name')).toHaveValue(
'elonMusk'
)
Expand All @@ -29,13 +31,15 @@ test('Change to operator role and back', async ({ page }) => {

await test.step('Edit option not visible', async () => {
await page.getByRole('button', { name: 'Menu' }).nth(1).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 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 test.step('Edit option not visible through Explorer', async () => {
await page.getByRole('menuitem', { name: 'Explorer' }).click()
await page.getByRole('button', { name: 'Explorer' }).click()
await page
.locator('li')
.filter({ hasText: /^data sourceDemoDataSource$/ })
Expand All @@ -57,19 +61,26 @@ test('Change to operator role and back', async ({ page }) => {
.getByRole('button')
.click()
await page.getByRole('button', { name: 'file elonMusk' }).nth(1).click()
await expect(page.getByRole('code')).toBeVisible()
await page.getByRole('button', { name: 'Menu' }).nth(2).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 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 test.step('Change back to admin', async () => {
await page.getByRole('button', { name: 'Menu' }).nth(1).click()
await page.getByRole('menuitem', { name: 'Yaml' }).first().click()
await page
.getByRole('button', { name: 'Yaml', exact: true })
.first()
.click()
await page.getByRole('button', { name: 'User' }).click()
await page.getByLabel('admin').check()
await page.getByRole('button', { name: 'Save' }).click()
await page.getByRole('button', { name: 'Menu' }).nth(1).click()
await expect(page.getByRole('menuitem', { name: 'Edit' })).toBeVisible()
await expect(page.getByRole('button', { 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 @@ -50,6 +50,6 @@ test('About', async ({ page }) => {

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

0 comments on commit 6767ab0

Please sign in to comment.