Skip to content

Commit a629300

Browse files
authored
Full tests for row actions menu polling bug (#2648)
tests for row actions menu polling bug
1 parent b57531d commit a629300

File tree

3 files changed

+78
-46
lines changed

3 files changed

+78
-46
lines changed

.eslintrc.cjs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,18 @@ module.exports = {
114114
},
115115
{
116116
files: ['*.e2e.ts'],
117-
extends: ['plugin:playwright/playwright-test'],
117+
extends: ['plugin:playwright/recommended'],
118118
rules: {
119119
'playwright/expect-expect': [
120120
'warn',
121-
{ assertFunctionNames: ['expectVisible', 'expectRowVisible', 'expectOptions'] },
121+
{
122+
assertFunctionNames: [
123+
'expectVisible',
124+
'expectRowVisible',
125+
'expectOptions',
126+
'expectRowMenuStaysOpen',
127+
],
128+
},
122129
],
123130
'playwright/no-force-option': 'off',
124131
},

test/e2e/instance-disks.e2e.ts

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,12 @@
77
*/
88
import {
99
clickRowAction,
10-
closeToast,
1110
expect,
1211
expectNoToast,
1312
expectNotVisible,
1413
expectRowVisible,
1514
expectToast,
1615
expectVisible,
17-
openRowActions,
1816
stopInstance,
1917
test,
2018
} from './utils'
@@ -230,45 +228,3 @@ test('Change boot disk', async ({ page }) => {
230228

231229
await expect(page.getByText('Attach a disk to be able to set a boot disk')).toBeVisible()
232230
})
233-
234-
// silly test but we've reintroduced this bug like 3 times
235-
test("polling doesn't close row actions menu", async ({ page }) => {
236-
await page.goto('/projects/mock-project/instances/db1')
237-
238-
// stop, but don't wait until the state has changed
239-
await page.getByRole('button', { name: 'Stop' }).click()
240-
await page.getByRole('button', { name: 'Confirm' }).click()
241-
await closeToast(page)
242-
243-
const menu = page.getByRole('menu')
244-
const stopped = page.getByText('statestopped')
245-
246-
await expect(menu).toBeHidden()
247-
await expect(stopped).toBeHidden()
248-
249-
await openRowActions(page, 'disk-1')
250-
await expect(stopped).toBeHidden() // still not stopped yet
251-
await expect(menu).toBeVisible()
252-
253-
// now we're stopped, which means polling has happened, but the
254-
// menu remains visible
255-
await expect(stopped).toBeVisible()
256-
await expect(menu).toBeVisible()
257-
258-
// now start it so we can check the non-boot disks table
259-
await page.getByRole('button', { name: 'Start' }).click()
260-
await page.getByRole('button', { name: 'Confirm' }).click()
261-
await closeToast(page)
262-
263-
const running = page.getByText('staterunning') // not running yet
264-
await expect(running).toBeHidden()
265-
await expect(menu).toBeHidden()
266-
267-
await openRowActions(page, 'disk-2')
268-
await expect(running).toBeHidden() // still not running yet
269-
await expect(menu).toBeVisible()
270-
271-
// state change means polling has happened. menu is still visible
272-
await expect(running).toBeVisible()
273-
await expect(menu).toBeVisible()
274-
})

test/e2e/instance.e2e.ts

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88
import {
99
clickRowAction,
10+
closeToast,
1011
expect,
1112
expectRowVisible,
1213
openRowActions,
@@ -240,3 +241,71 @@ test('instance table', async ({ page }) => {
240241
state: expect.stringMatching(/^starting\d+s$/),
241242
})
242243
})
244+
245+
async function expectRowMenuStaysOpen(page: Page, rowSelector: string) {
246+
// stop, but don't wait until the state has changed
247+
await page.getByRole('button', { name: 'Stop' }).click()
248+
await page.getByRole('button', { name: 'Confirm' }).click()
249+
await closeToast(page)
250+
251+
const menu = page.getByRole('menu')
252+
const stopped = page.getByText('statestopped')
253+
254+
await expect(menu).toBeHidden()
255+
await expect(stopped).toBeHidden()
256+
257+
await openRowActions(page, rowSelector)
258+
await expect(stopped).toBeHidden() // still not stopped yet
259+
await expect(menu).toBeVisible()
260+
261+
// now we're stopped, which means polling has happened, but the
262+
// menu remains visible
263+
await expect(stopped).toBeVisible()
264+
await expect(menu).toBeVisible()
265+
}
266+
267+
// silly tests, but we've reintroduced this bug like 3 times
268+
269+
test("polling doesn't close row actions: IPs table", async ({ page }) => {
270+
await page.goto('/projects/mock-project/instances/db1/networking')
271+
await expectRowMenuStaysOpen(page, '123.4.56.0')
272+
})
273+
274+
test("polling doesn't close row actions: NICs table", async ({ page }) => {
275+
await page.goto('/projects/mock-project/instances/db1/networking')
276+
await expectRowMenuStaysOpen(page, 'my-nic')
277+
})
278+
279+
test("polling doesn't close row actions: boot disk", async ({ page }) => {
280+
await page.goto('/projects/mock-project/instances/db1')
281+
await expectRowMenuStaysOpen(page, 'disk-1')
282+
})
283+
284+
test("polling doesn't close row actions: other disk", async ({ page }) => {
285+
await page.goto('/projects/mock-project/instances/db1')
286+
await expectRowMenuStaysOpen(page, 'disk-2')
287+
})
288+
289+
test("polling doesn't close row actions: instances", async ({ page }) => {
290+
await page.goto('/projects/mock-project/instances')
291+
292+
// can't use the cool function because it's *slightly* different
293+
await clickRowAction(page, 'db1', 'Stop')
294+
await page.getByRole('button', { name: 'Confirm' }).click()
295+
await closeToast(page)
296+
297+
const menu = page.getByRole('menu')
298+
const stopped = page.getByText('stopped')
299+
300+
await expect(menu).toBeHidden()
301+
await expect(stopped).toBeHidden()
302+
303+
await openRowActions(page, 'db1')
304+
await expect(stopped).toBeHidden() // still not stopped yet
305+
await expect(menu).toBeVisible()
306+
307+
// now we're stopped, which means polling has happened, but the
308+
// menu remains visible
309+
await expect(stopped).toBeVisible()
310+
await expect(menu).toBeVisible()
311+
})

0 commit comments

Comments
 (0)