Skip to content

Commit fb52f5e

Browse files
committed
fix e2e test failure by closing menu
1 parent 979b3d5 commit fb52f5e

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

test/e2e/instance-networking.e2e.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import { expect, test } from '@playwright/test'
99

1010
import {
1111
clickRowAction,
12+
clickRowActions,
1213
expectRowVisible,
1314
expectVisible,
14-
openRowActions,
1515
stopInstance,
1616
} from './utils'
1717

@@ -79,21 +79,23 @@ test('Instance networking tab — NIC table', async ({ page }) => {
7979
await expect(nic3).toBeVisible()
8080

8181
// See that the primary NIC cannot be deleted when other NICs exist
82-
await openRowActions(page, 'nic-3')
83-
await expect(page.getByRole('menuitem', { name: 'Delete' })).toBeDisabled()
84-
await page.getByRole('menuitem', { name: 'Delete' }).hover()
82+
await clickRowActions(page, 'nic-3')
83+
const deleteButton = page.getByRole('menuitem', { name: 'Delete' })
84+
await expect(deleteButton).toBeDisabled()
85+
await deleteButton.hover()
8586
await expect(page.getByText('This network interface is primary and cannot')).toBeVisible()
8687

88+
// close the menu for nic-3, without the next line fails in FF and Safari (but not Chrome)
89+
await clickRowActions(page, 'nic-3')
90+
8791
// Delete the non-primary NIC
8892
await clickRowAction(page, 'my-nic', 'Delete')
8993
await expect(page.getByText('Are you sure you want to delete my-nic?')).toBeVisible()
9094
await page.getByRole('button', { name: 'Confirm' }).click()
9195
await expect(page.getByRole('cell', { name: 'my-nic' })).toBeHidden()
9296

9397
// Now the primary NIC is deletable
94-
await openRowActions(page, 'nic-3')
95-
await expect(page.getByRole('menuitem', { name: 'Delete' })).toBeEnabled()
96-
await page.getByRole('menuitem', { name: 'Delete' }).click()
98+
await clickRowAction(page, 'nic-3', 'Delete')
9799
await page.getByRole('button', { name: 'Confirm' }).click()
98100
await expect(nic3).toBeHidden()
99101
})

test/e2e/instance.e2e.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
*/
88
import {
99
clickRowAction,
10+
clickRowActions,
1011
closeToast,
1112
expect,
1213
expectRowVisible,
13-
openRowActions,
1414
test,
1515
type Page,
1616
} from './utils'
@@ -41,7 +41,7 @@ test('can start a failed instance', async ({ page }) => {
4141
await page.goto('/projects/mock-project/instances')
4242

4343
// check the start button disabled message on a running instance
44-
await openRowActions(page, 'db1')
44+
await clickRowActions(page, 'db1')
4545
await page.getByRole('menuitem', { name: 'Start' }).hover()
4646
await expect(
4747
page.getByText('Only stopped or failed instances can be started')
@@ -118,14 +118,14 @@ test('can reboot a running instance', async ({ page }) => {
118118
test('cannot reboot a failed instance', async ({ page }) => {
119119
await page.goto('/projects/mock-project/instances')
120120
await expectInstanceState(page, 'you-fail', 'failed')
121-
await openRowActions(page, 'you-fail')
121+
await clickRowActions(page, 'you-fail')
122122
await expect(page.getByRole('menuitem', { name: 'Reboot' })).toBeDisabled()
123123
})
124124

125125
test('cannot reboot a starting instance, or a stopped instance', async ({ page }) => {
126126
await page.goto('/projects/mock-project/instances')
127127
await expectInstanceState(page, 'not-there-yet', 'starting')
128-
await openRowActions(page, 'not-there-yet')
128+
await clickRowActions(page, 'not-there-yet')
129129
await expect(page.getByRole('menuitem', { name: 'Reboot' })).toBeDisabled()
130130
// hit escape to close the menu so clickRowAction succeeds
131131
await page.keyboard.press('Escape')
@@ -136,21 +136,21 @@ test('cannot reboot a starting instance, or a stopped instance', async ({ page }
136136
await expectInstanceState(page, 'not-there-yet', 'stopping')
137137
await expectInstanceState(page, 'not-there-yet', 'stopped')
138138
// reboot is still disabled for a stopped instance
139-
await openRowActions(page, 'not-there-yet')
139+
await clickRowActions(page, 'not-there-yet')
140140
await expect(page.getByRole('menuitem', { name: 'Reboot' })).toBeDisabled()
141141
})
142142

143143
test('cannot resize a running or starting instance', async ({ page }) => {
144144
await page.goto('/projects/mock-project/instances')
145145

146146
await expectInstanceState(page, 'db1', 'running')
147-
await openRowActions(page, 'db1')
147+
await clickRowActions(page, 'db1')
148148
await expect(page.getByRole('menuitem', { name: 'Resize' })).toBeDisabled()
149149

150150
await page.keyboard.press('Escape') // get out of the menu
151151

152152
await expectInstanceState(page, 'not-there-yet', 'starting')
153-
await openRowActions(page, 'not-there-yet')
153+
await clickRowActions(page, 'not-there-yet')
154154
await expect(page.getByRole('menuitem', { name: 'Resize' })).toBeDisabled()
155155
})
156156

@@ -254,7 +254,7 @@ async function expectRowMenuStaysOpen(page: Page, rowSelector: string) {
254254
await expect(menu).toBeHidden()
255255
await expect(stopped).toBeHidden()
256256

257-
await openRowActions(page, rowSelector)
257+
await clickRowActions(page, rowSelector)
258258
await expect(stopped).toBeHidden() // still not stopped yet
259259
await expect(menu).toBeVisible()
260260

@@ -300,7 +300,7 @@ test("polling doesn't close row actions: instances", async ({ page }) => {
300300
await expect(menu).toBeHidden()
301301
await expect(stopped).toBeHidden()
302302

303-
await openRowActions(page, 'db1')
303+
await clickRowActions(page, 'db1')
304304
await expect(stopped).toBeHidden() // still not stopped yet
305305
await expect(menu).toBeVisible()
306306

test/e2e/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ export async function closeToast(page: Page) {
154154
export const clipboardText = async (page: Page) =>
155155
page.evaluate(() => navigator.clipboard.readText())
156156

157-
export const openRowActions = async (page: Page, name: string) => {
157+
export const clickRowActions = async (page: Page, name: string) => {
158158
await page
159159
.getByRole('row', { name, exact: false })
160160
.getByRole('button', { name: 'Row actions' })
@@ -163,7 +163,7 @@ export const openRowActions = async (page: Page, name: string) => {
163163

164164
/** Select row by `rowName`, click the row actions button, and click `actionName` */
165165
export async function clickRowAction(page: Page, rowName: string, actionName: string) {
166-
await openRowActions(page, rowName)
166+
await clickRowActions(page, rowName)
167167
await page.getByRole('menuitem', { name: actionName }).click()
168168
}
169169

0 commit comments

Comments
 (0)