Skip to content

Commit

Permalink
test: table templates
Browse files Browse the repository at this point in the history
  • Loading branch information
roar-larsen committed Jan 3, 2024
1 parent 9845a44 commit 90da339
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 20 deletions.
55 changes: 45 additions & 10 deletions e2e/tests/plugin-table-car_list.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,42 +71,77 @@ test('Table car list example', async ({ page }) => {
await expect(page.getByText('1 - 1 of 1')).toBeVisible()
})

await test.step('Adding several cars to test pagination', async () => {
await test.step('Add car using multiple template', async () => {
await page.getByRole('tab', { name: 'cars (using many templates)' }).click()
await expect(
page.getByRole('button', { name: 'Open expandable row' })
).toHaveCount(1)
await expect(page.getByRole('button', { name: 'Next page' })).toBeDisabled()
await page.getByRole('button', { name: 'Add new row' }).click()
await page.getByRole('menuitem', { name: 'Template2' }).click()
await expect(
page.getByRole('button', { name: 'Open expandable row' })
).toHaveCount(2)
await expect(page.getByText('BMW')).toBeVisible()
await expect(page.getByText('X1')).toBeVisible()
await expect(page.getByText('Blue', { exact: true })).toBeVisible()
await expect(page.getByText('TDI 1.8')).toBeVisible()
})

await test.step('Add car using single template', async () => {
await page.getByRole('tab', { name: 'cars (using one template)' }).click()
await expect(
page.getByRole('button', { name: 'Open expandable row' })
).toHaveCount(2)
await expect(page.getByText('1 - 2 of 2')).toBeVisible()
await page.getByRole('button', { name: 'Add new row' }).click()
await expect(
page.getByRole('button', { name: 'Open expandable row' })
).toHaveCount(3)
await expect(page.getByText('1 - 3 of 3')).toBeVisible()
await expect(page.getByText('Audi', { exact: true })).toBeVisible()
await expect(page.getByText('A2')).toBeVisible()
await expect(page.getByText('Black')).toBeVisible()
await expect(page.getByText('TDI 1.6')).toBeVisible()
})

await test.step('Adding several cars to test pagination', async () => {
await page.reload()
await navigate()
await expect(
page.getByRole('button', { name: 'Open expandable row' })
).toHaveCount(3)
await expect(
page.getByRole('tabpanel').getByText('1 - 3 of 3')
).toBeVisible()
await page.getByRole('button', { name: 'Add new row' }).click()
await expect(
page.getByRole('button', { name: 'Open expandable row' })
).toHaveCount(4)
await expect(page.getByText('1 - 4 of 4')).toBeVisible()
await expect(
page.getByRole('tabpanel').getByText('1 - 4 of 4')
).toBeVisible()
await page.getByRole('button', { name: 'Add new row' }).click()
await expect(
page.getByRole('button', { name: 'Open expandable row' })
).toHaveCount(5)
await expect(page.getByText('1 - 5 of 5')).toBeVisible()
await expect(
page.getByRole('tabpanel').getByText('1 - 5 of 5')
).toBeVisible()
await page.getByRole('button', { name: 'Add new row' }).click()
await expect(
page.getByRole('button', { name: 'Open expandable row' })
).toHaveCount(6)
await expect(page.getByText('1 - 6 of 6')).toBeVisible()
await page.locator('#rowsPerPage').selectOption('5')
await expect(
page.getByRole('tabpanel').getByText('1 - 6 of 6')
).toBeVisible()
await page.getByRole('combobox').selectOption('5')
await page.getByRole('button', { name: 'Next page' }).click()
await expect(page.getByText('6 - 6 of 6')).toBeVisible()
await expect(
page.getByRole('tabpanel').getByText('6 - 6 of 6')
).toBeVisible()
await expect(page.getByRole('button', { name: 'Next page' })).toBeDisabled()
await page.getByRole('button', { name: 'Previous page' }).click()
await expect(page.getByText('1 - 5 of 6')).toBeVisible()
await expect(
page.getByRole('tabpanel').getByText('1 - 5 of 6')
).toBeVisible()
await expect(
page.getByRole('button', { name: 'Previous page' })
).toBeDisabled()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"name": "CarList",
"_templates_": [
{
"name": "a",
"name": "Audi",
"type": "./blueprints/Car",
"model": "none",
"model": "A2",
"color": "Black",
"engine": {
"type": "./blueprints/Engine",
Expand All @@ -15,24 +15,24 @@
}
},
{
"name": "b",
"name": "BMW",
"type": "./blueprints/Car",
"model": "none",
"color": "Black",
"model": "X1",
"color": "Blue",
"engine": {
"type": "./blueprints/Engine",
"name": "TDI 1.6",
"name": "TDI 1.8",
"hp": 122
}
},
{
"name": "c",
"name": "Chevrolet",
"type": "./blueprints/Car",
"model": "none",
"color": "Black",
"model": "Corvette",
"color": "Cyan",
"engine": {
"type": "./blueprints/Engine",
"name": "TDI 1.6",
"name": "TDI 2.0",
"hp": 123
}
}
Expand Down

0 comments on commit 90da339

Please sign in to comment.