Skip to content

Commit 14685b1

Browse files
authored
Upgrade playwright eslint plugin to get new rules (#1752)
* upgrade playwright eslint plugin to get expect-expect and no-useless-await * bump playwright for UI mode console log improvement
1 parent 2b3d519 commit 14685b1

File tree

8 files changed

+46
-43
lines changed

8 files changed

+46
-43
lines changed

.eslintrc.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,13 @@
5959
},
6060
{
6161
"files": ["*.e2e.ts"],
62-
"extends": ["plugin:playwright/playwright-test"]
62+
"extends": ["plugin:playwright/playwright-test"],
63+
"rules": {
64+
"playwright/expect-expect": [
65+
"warn",
66+
{ "additionalAssertFunctionNames": ["expectVisible"] }
67+
]
68+
}
6369
}
6470
]
6571
}

app/test/e2e/click-everything.e2e.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,6 @@ test('Click through disks page', async ({ page }) => {
7070
])
7171
})
7272

73-
// eslint-disable-next-line playwright/no-skipped-test
74-
test.skip('Click through access & IAM', async ({ page }) => {
75-
await page.click('role=link[name*="Access & IAM"]')
76-
// not implemented
77-
})
78-
7973
test('Click through images', async ({ page }) => {
8074
await page.click('role=link[name*="Images"]')
8175
await expectVisible(page, [

app/test/e2e/disk-create.e2e.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ test.describe('Disk create', () => {
2222
await expectVisible(page, ['role=cell[name="a-new-disk"]'])
2323
})
2424

25+
// expects are in the afterEach
26+
27+
/* eslint-disable playwright/expect-expect */
2528
test('from blank', async ({ page }) => {
2629
await page.getByRole('radio', { name: '512' }).click()
2730
})
@@ -42,4 +45,5 @@ test.describe('Disk create', () => {
4245
await page.getByRole('radio', { name: 'Snapshot' }).click()
4346
await page.getByRole('radio', { name: 'Blank' }).click()
4447
})
48+
/* eslint-enable playwright/expect-expect */
4549
})

app/test/e2e/instance-create.e2e.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,15 @@ test('can create an instance', async ({ page }) => {
5454

5555
// network tab works
5656
await page.getByRole('tab', { name: 'Network Interfaces' }).click()
57-
const table = await page.getByRole('table')
57+
const table = page.getByRole('table')
5858
await expectRowVisible(table, { name: 'default', vpc: 'mock-vpc', subnet: 'mock-subnet' })
59+
})
5960

60-
// trying to create another instance with the same name produces a visible
61-
// error
62-
await page.goto('/projects/mock-project/instances')
63-
await page.locator('text="New Instance"').click()
64-
await page.fill('input[name=name]', instanceName)
61+
test('duplicate instance name produces visible error', async ({ page }) => {
62+
await page.goto('/projects/mock-project/instances-new')
63+
await page.fill('input[name=name]', 'db1')
6564
await page.locator('button:has-text("Create instance")').click()
66-
await page.getByText('Instance name already exists')
65+
await expect(page.getByText('Instance name already exists')).toBeVisible()
6766
})
6867

6968
test('first preset is auto-selected in each tab', async ({ page }) => {

app/test/e2e/scroll-restore.e2e.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
import { type Page, expect, test } from './utils'
99

1010
async function expectScrollTop(page: Page, expected: number) {
11-
const container = await page.getByTestId('scroll-container')
11+
const container = page.getByTestId('scroll-container')
1212
const getScrollTop = () => container.evaluate((el: HTMLElement) => el.scrollTop)
1313
await expect.poll(getScrollTop).toBe(expected)
1414
}
1515

1616
async function scrollTo(page: Page, to: number) {
17-
const container = await page.getByTestId('scroll-container')
17+
const container = page.getByTestId('scroll-container')
1818
await container.evaluate((el: HTMLElement, to) => el.scrollTo(0, to), to)
1919
}
2020

app/test/e2e/vpcs.e2e.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ test('can nav to VpcPage from /', async ({ page }) => {
1313
await page.click('a:has-text("Networking")')
1414
await page.click('a:has-text("mock-vpc")')
1515
await expect(page.locator('text=mock-subnet')).toBeVisible()
16-
await expect(await page.title()).toEqual('mock-vpc / VPCs / mock-project / Oxide Console')
16+
expect(await page.title()).toEqual('mock-vpc / VPCs / mock-project / Oxide Console')
1717
})
1818

1919
test('can create and delete subnet', async ({ page }) => {
2020
await page.goto('/projects/mock-project/vpcs/mock-vpc')
2121
// only one row in table, the default mock-subnet
22-
const rows = await page.locator('tbody >> tr')
22+
const rows = page.locator('tbody >> tr')
2323
await expect(rows).toHaveCount(1)
2424
await expect(rows.nth(0).locator('text="mock-subnet"')).toBeVisible()
2525

package-lock.json

Lines changed: 23 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
"@figma-export/transform-svg-with-svgo": "^4.3.0",
8686
"@ladle/react": "^2.14.0",
8787
"@mswjs/http-middleware": "^0.8.0",
88-
"@playwright/test": "^1.36.1",
88+
"@playwright/test": "^1.37.1",
8989
"@testing-library/dom": "^9.3.1",
9090
"@testing-library/jest-dom": "^5.17.0",
9191
"@testing-library/react": "^14.0.0",
@@ -111,7 +111,7 @@
111111
"eslint": "^8.42.0",
112112
"eslint-config-prettier": "^8.8.0",
113113
"eslint-plugin-jsx-a11y": "^6.7.1",
114-
"eslint-plugin-playwright": "^0.12.0",
114+
"eslint-plugin-playwright": "^0.16.0",
115115
"eslint-plugin-prettier": "^4.0.0",
116116
"eslint-plugin-react": "^7.32.2",
117117
"eslint-plugin-react-hook-form": "^0.3.0",

0 commit comments

Comments
 (0)