fix(E2E): Fix flaky Dashboard list delete test (#31933)

This commit is contained in:
Geido 2025-01-21 18:11:48 +01:00 committed by GitHub
parent 63843c5682
commit 79f21b09d2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 37 additions and 21 deletions

View File

@ -40,11 +40,25 @@ function openMenu() {
cy.get('[aria-label="more-vert"]').first().click();
}
function confirmDelete() {
function confirmDelete(bulk = false) {
interceptDelete();
interceptBulkDelete();
// Wait for modal dialog to be present and visible
cy.get('[role="dialog"][aria-modal="true"]').should('be.visible');
cy.getBySel('delete-modal-input').should('be.visible').clear().type('DELETE');
cy.getBySel('delete-modal-input')
.should('be.visible')
.then($input => {
cy.wrap($input).clear();
cy.wrap($input).type('DELETE');
});
cy.getBySel('modal-confirm-button').should('be.visible').click();
if (bulk) {
cy.wait('@bulkDelete');
} else {
cy.wait('@delete');
}
}
describe('Dashboards list', () => {
@ -159,7 +173,6 @@ describe('Dashboards list', () => {
});
it('should bulk delete correctly', () => {
interceptBulkDelete();
toggleBulkSelect();
// bulk deletes in card-view
@ -169,8 +182,7 @@ describe('Dashboards list', () => {
cy.getBySel('styled-card').eq(0).contains('1 - Sample dashboard').click();
cy.getBySel('styled-card').eq(1).contains('2 - Sample dashboard').click();
cy.getBySel('bulk-select-action').eq(0).contains('Delete').click();
confirmDelete();
cy.wait('@bulkDelete');
confirmDelete(true);
cy.getBySel('styled-card')
.eq(0)
.should('not.contain', '1 - Sample dashboard');
@ -185,8 +197,7 @@ describe('Dashboards list', () => {
cy.get('[data-test="table-row"] input[type="checkbox"]').eq(0).click();
cy.get('[data-test="table-row"] input[type="checkbox"]').eq(1).click();
cy.getBySel('bulk-select-action').eq(0).contains('Delete').click();
confirmDelete();
cy.wait('@bulkDelete');
confirmDelete(true);
cy.getBySel('table-row')
.eq(0)
.should('not.contain', '3 - Sample dashboard');
@ -195,31 +206,36 @@ describe('Dashboards list', () => {
.should('not.contain', '4 - Sample dashboard');
});
it('should delete correctly', () => {
interceptDelete();
it('should delete correctly in list mode', () => {
// deletes in list-view
setGridMode('list');
cy.getBySel('table-row')
.eq(0)
.contains('4 - Sample dashboard')
.should('exist');
cy.getBySel('dashboard-list-trash-icon').eq(0).click();
confirmDelete();
cy.getBySel('table-row')
.eq(0)
.should('not.contain', '4 - Sample dashboard');
});
it('should delete correctly in card mode', () => {
// deletes in card-view
setGridMode('card');
orderAlphabetical();
cy.getBySel('styled-card').eq(0).contains('1 - Sample dashboard');
cy.getBySel('styled-card')
.eq(0)
.contains('1 - Sample dashboard')
.should('exist');
openMenu();
cy.getBySel('dashboard-card-option-delete-button').click();
confirmDelete();
cy.wait('@delete');
cy.getBySel('styled-card')
.eq(0)
.should('not.contain', '1 - Sample dashboard');
// deletes in list-view
setGridMode('list');
cy.getBySel('table-row').eq(0).contains('2 - Sample dashboard');
cy.getBySel('dashboard-list-trash-icon').eq(0).click();
confirmDelete();
cy.wait('@delete');
cy.getBySel('table-row')
.eq(0)
.should('not.contain', '2 - Sample dashboard');
});
it('should edit correctly', () => {