Skip to content

Commit

Permalink
test(form): fix integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
ingeridhellen committed Sep 15, 2023
1 parent 934566d commit 4613c87
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 43 deletions.
16 changes: 4 additions & 12 deletions e2e/tests/plugin-form-Nested.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ const navigate = async () => {

test('Change owner', async () => {
await expect(page.getByText('Owner', { exact: true })).toBeVisible
await page
.getByText('OwnerOpen')
.getByRole('button', { name: 'Open' })
.click()
await page.getByTestId('owner').getByRole('button', { name: 'Open' }).click()
await page.getByLabel('Name').fill('Jacob')
await page.getByLabel('Phone Number (optional)').fill('1234')
await page.getByRole('button', { name: 'Submit' }).click()
Expand Down Expand Up @@ -156,10 +153,8 @@ test('New car', async () => {
})

test('New customer', async () => {
await page
.getByText('CustomersOpen')
.getByRole('button', { name: 'Open' })
.click()
const customersDiv = page.getByTestId('customers')
await customersDiv.getByRole('button', { name: 'Open' }).click()
const lastTabPanel = page.getByRole('tabpanel').last()
await expect(lastTabPanel).toBeVisible()
await expect.soft(lastTabPanel.getByText('1 - 2 of 2')).toBeVisible()
Expand All @@ -174,10 +169,7 @@ test('New customer', async () => {
await page.getByRole('button', { name: 'close', exact: true }).click()
await page.reload()
await navigate()
await page
.getByText('CustomersOpen')
.getByRole('button', { name: 'Open' })
.click()
await customersDiv.getByRole('button', { name: 'Open' }).click()
await expect(page.getByText('Lewis')).toBeVisible()
await page.getByRole('button', { name: 'Open item' }).last().click()
await expect(page.getByRole('tab', { name: 'Lewis' })).toBeVisible()
Expand Down
26 changes: 8 additions & 18 deletions e2e/tests/plugin-form-UncontainedObject.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { test, expect } from '@playwright/test'
import { expect, test } from '@playwright/test'

test('uncontainedObject', async ({ page }) => {
await page.goto('http://localhost:3000/')
Expand All @@ -7,13 +7,6 @@ test('uncontainedObject', async ({ page }) => {
await page.getByText('uncontained_object', { exact: true }).click()
await page.getByText('UncontainedObject').click()

await expect(
page.getByTestId('ceo').getByText('Address: ^.employees[0]')
).toBeVisible()
await expect(
page.getByTestId('accountant').getByText('Address: ^.employees[0]')
).toBeVisible()

await page.getByTestId('ceo').getByRole('button', { name: 'Open' }).click()
await expect(page.getByRole('code').getByText('Miranda')).toBeVisible()
await expect(page.getByRole('code').getByText('1337')).toBeVisible()
Expand All @@ -27,7 +20,7 @@ test('uncontainedObject', async ({ page }) => {
// Add assistant
await page
.getByTestId('assistant')
.getByRole('button', { name: 'Select and save' })
.getByRole('button', { name: 'Add and save' })
.click()
await expect(page.getByRole('dialog')).toBeVisible()
await page.getByRole('dialog').getByText('plugins', { exact: true }).click()
Expand Down Expand Up @@ -56,7 +49,7 @@ test('uncontainedObject', async ({ page }) => {
// Add trainee
await page
.getByTestId('trainee')
.getByRole('button', { name: 'Select and save' })
.getByRole('button', { name: 'Add and save' })
.click()
await expect(page.getByRole('dialog')).toBeVisible()
await page.getByRole('dialog').getByText('plugins', { exact: true }).click()
Expand Down Expand Up @@ -84,7 +77,7 @@ test('uncontainedObject', async ({ page }) => {
// Change accountant
await page
.getByTestId('accountant')
.getByRole('button', { name: 'Select and save' })
.getByRole('button', { name: 'Edit and save' })
.click()
await expect(page.getByRole('dialog')).toBeVisible()
await page.getByRole('dialog').getByText('plugins', { exact: true }).click()
Expand All @@ -109,13 +102,10 @@ test('uncontainedObject', async ({ page }) => {
).toBeVisible()

//Remove trainee
await page.getByTestId('remove-trainee').click()
await expect(
page.getByTestId('trainee').getByRole('code').getByText('John')
).not.toBeVisible()
await expect(
page.getByTestId('trainee').getByRole('code').getByText('1234')
).not.toBeVisible()
const trainee = page.getByTestId('trainee')
await trainee.getByRole('button', { name: 'Remove and save' }).click()
await expect(trainee.getByRole('code').getByText('John')).not.toBeVisible()
await expect(trainee.getByRole('code').getByText('1234')).not.toBeVisible()

// Submit form
await page.getByRole('button', { name: 'Submit' }).click()
Expand Down
18 changes: 6 additions & 12 deletions e2e/tests/plugin-view_selector-car_garage.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { test, expect } from '@playwright/test'
import { expect, test } from '@playwright/test'

test('View selector - car garage', async ({ page }) => {
// Open self and verify page content and the sidebar:
Expand Down Expand Up @@ -30,10 +30,7 @@ test('View selector - car garage', async ({ page }) => {
await page.locator('a').filter({ hasText: 'Audi' }).click()
await expect(page.getByRole('tab', { name: 'home Home' })).toBeVisible()
await expect(page.getByRole('tabpanel').locator('#name')).toHaveValue('Audi')
await page
.getByText('View owner details and historyOpen')
.getByRole('button', { name: 'Open' })
.click()
await page.getByTestId('Owner').getByRole('button', { name: 'Open' }).click()
await expect(
page.getByRole('tab', { name: 'person Owner details' })
).toHaveAttribute('aria-selected', 'true')
Expand All @@ -49,7 +46,7 @@ test('View selector - car garage', async ({ page }) => {
).toHaveAttribute('aria-selected', 'true')

//Add earlier owner:
await page.getByTestId('add-earlierOwners').click()
await page.getByRole('button', { name: 'Add' }).click()
await page.getByRole('textbox').last().fill(' Joanna')
await page.getByRole('button', { name: 'Submit' }).click()
await expect(page.getByRole('alert')).toHaveText(['Document updated'])
Expand All @@ -58,7 +55,7 @@ test('View selector - car garage', async ({ page }) => {
// Select "home" and then open "technical". Verify that both owner and techincal tabs are open and selectable. Check also sub-tabs
await page.getByRole('tab', { name: 'home Home' }).click()
await page
.getByText('View technical informationOpen')
.getByTestId('Technical')
.getByRole('button', { name: 'Open' })
.click()
await expect(
Expand Down Expand Up @@ -113,7 +110,7 @@ test('View selector - car garage', async ({ page }) => {
// Testing that saving one car does not ovveride the other car:
await page.locator('a').filter({ hasText: 'Volvo' }).click()
await page
.getByText('View technical informationOpen')
.getByTestId('Technical')
.getByRole('button', { name: 'Open' })
.click()

Expand All @@ -125,10 +122,7 @@ test('View selector - car garage', async ({ page }) => {
'4500'
)
await page.getByRole('tab', { name: 'home Home' }).click()
await page
.getByText('View owner details and historyOpen')
.getByRole('button', { name: 'Open' })
.click()
await page.getByTestId('Owner').getByRole('button', { name: 'Open' }).click()
await page.getByRole('tab', { name: 'group Owner history' }).click()
await expect(page.getByRole('textbox').first()).toHaveValue('Jack')
await expect(page.getByRole('textbox').last()).toHaveValue('Maria')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,6 @@ test('should handle optional', async () => {
// Show optional in label
expect(screen.getByText('nested (optional)')).toBeDefined()
// Add button
expect(screen.getByTestId('add-nested')).toBeDefined()
expect(screen.getByRole('button', { name: 'Add and save' })).toBeDefined()
})
})

0 comments on commit 4613c87

Please sign in to comment.