Skip to content

Commit 19f6fe1

Browse files
authored
Merge pull request #4309 from FlowFuse/fix-bulk-intermittant-e2e-tests
Fix bulk intermittent e2e tests
2 parents c547148 + 70d2c8d commit 19f6fe1

File tree

1 file changed

+33
-3
lines changed

1 file changed

+33
-3
lines changed

test/e2e/frontend/cypress/tests/devices/bulk.spec.js

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/// <reference types="cypress" />
12
describe('FlowForge - Devices', () => {
23
beforeEach(() => {
34
cy.login('bob', 'bbPassword')
@@ -31,6 +32,10 @@ describe('FlowForge - Devices', () => {
3132
cy.wait(['@getDevices']).then(({ response }) => {
3233
const devices = response.body.devices
3334

35+
// initial checks to help better understand test fail output
36+
expect(devices).to.be.an('array')
37+
expect(devices.length).to.be.greaterThan(3)
38+
3439
// select a single device
3540
cy.get('[data-el="devices-browser"] tbody tr').eq(0).find('.checkbox').click()
3641
// click the "Delete" button
@@ -51,9 +56,17 @@ describe('FlowForge - Devices', () => {
5156

5257
// select all devices
5358
cy.get('[data-el="devices-browser"] thead .checkbox').click()
59+
60+
// introduce a small delay to ensure the devices are selected before continuing
61+
// eslint-disable-next-line cypress/no-unnecessary-waiting
62+
cy.wait(30)
63+
64+
// ensure the delete button is now enabled
65+
cy.get('[data-action="bulk-delete-devices"]').should('not.be.disabled')
5466
// click the "Delete" button
5567
cy.get('[data-action="bulk-delete-devices"]').click()
5668
// ensure the dialog is visible and has the correct number of devices listed
69+
cy.get('[data-el="team-bulk-device-delete-dialog"]').should('be.visible')
5770
cy.get('[data-el="team-bulk-device-delete-dialog"] ul li').should('have.length', devices.length)
5871

5972
// ensure all device names are displayed in the dialog
@@ -71,17 +84,34 @@ describe('FlowForge - Devices', () => {
7184
cy.wait(['@getDevices']).then(({ response }) => {
7285
const devices = response.body.devices
7386

87+
// initial checks to help better understand test fail output
88+
expect(devices).to.be.an('array')
89+
expect(devices.length).to.be.greaterThan(3)
90+
91+
// wait for device browser to load table
92+
cy.get('[data-el="devices-browser"] tbody tr').should('have.length', devices.length)
93+
7494
// find 3 sacrificial devices with names ending "bulk-test-#" (where # is 1 ~ 3)
7595
const sacrificialDevices = devices.filter((device) => device.name.match(/bulk-test-\d$/))
76-
// select the sacrificial devices. NOTE the .chekbox is in col0 but the text is in col1
96+
97+
// select the sacrificial devices. NOTE the .checkbox is in col0 but the text is in col1
7798
sacrificialDevices.forEach((device) => {
78-
cy.get('[data-el="devices-browser"] tbody tr').contains(device.name).parent().closest('tr').find('.checkbox').click()
99+
cy.get('[data-el="devices-browser"] tbody tr').contains(device.name).parent().parent().find('.checkbox').click()
79100
})
80101

102+
// introduce a delay to ensure the devices are selected before continuing
103+
// eslint-disable-next-line cypress/no-unnecessary-waiting
104+
cy.wait(30)
105+
106+
// ensure 3 devices are selected
107+
cy.get('[data-el="devices-browser"] tbody tr input[type="checkbox"]:checked').should('have.length', 3)
108+
81109
// click the "Delete" button
110+
cy.get('[data-action="bulk-delete-devices"]').should('not.be.disabled')
82111
cy.get('[data-action="bulk-delete-devices"]').click()
83112

84-
// click the "Confirm" button
113+
// click the dialog "Confirm" button
114+
cy.get('[data-el="team-bulk-device-delete-dialog"]').should('be.visible')
85115
cy.get('[data-el="team-bulk-device-delete-dialog"] button').contains('Confirm').click()
86116

87117
// wait for the devices API call to complete

0 commit comments

Comments
 (0)