Skip to content

Commit 78a4f7a

Browse files
authored
Add filter in search box application to fix failed test (#406)
* Add filter in search box application to fix failed test * Fixed the 'Force Update' behavior of Fleet-77 * Fixed backward compatibility of Force Update
1 parent ef9a3ef commit 78a4f7a

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed

tests/cypress/e2e/unit_tests/p1_fleet.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,11 @@ describe('Test Self-Healing of resource modification when correctDrift option us
110110

111111
if (correctDrift === 'yes') {
112112
// Resources will be restored, hence count will be 1/1.
113+
cy.filterInSearchBox(appName);
113114
cy.verifyTableRow(0, appName, '1/1');
114115
} else {
115116
// Resource count will get increased as resource will not be restored
117+
cy.filterInSearchBox(appName);
116118
cy.verifyTableRow(0, appName, '2/2');
117119
}
118120
cy.deleteAllFleetRepos();
@@ -135,6 +137,7 @@ describe('Test Self-Healing of resource modification when correctDrift option us
135137
cy.modifyDeployedApplication(appName);
136138

137139
// Resource count will get increased as resource will not be restored
140+
cy.filterInSearchBox(appName);
138141
cy.verifyTableRow(0, appName, '2/2');
139142

140143
// Update exising GitRepo by enabling 'correctDrift'
@@ -154,6 +157,7 @@ describe('Test Self-Healing of resource modification when correctDrift option us
154157
cy.modifyDeployedApplication(appName);
155158

156159
// Resources will be restored, hence count will be 1/1.
160+
cy.filterInSearchBox(appName);
157161
cy.verifyTableRow(0, appName, '1/1');
158162

159163
cy.deleteAllFleetRepos();

tests/cypress/support/commands.ts

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,44 @@ Cypress.Commands.add('open3dotsMenu', (name, selection, checkNotInMenu=false) =>
320320
cy.wait(500);
321321
cy.get('body', { timeout: 10000 }).then(($body) => {
322322
if ($body.find('.card-title > h4').text().includes('Force Update')) {
323-
cy.get('[data-testid="deactivate-driver-confirm"] > span').should('be.visible').click();
324-
}
323+
const buttonSelector = '[data-testid="deactivate-driver-confirm"] > span';
324+
325+
cy.get(buttonSelector)
326+
.should('be.visible')
327+
.and('contain.text', 'Update')
328+
.click();
329+
// Below code repeat the Update process when object is modified.
330+
// When there is no object modified state, then it will work as expected.
331+
cy.wait(500);
332+
333+
cy.get('body').then(($body) => {
334+
if ($body.find(buttonSelector).length === 0) {
335+
cy.log('Button disappeared after click — Success');
336+
} else {
337+
cy.get(buttonSelector, { timeout: 30000 }).then(($btn) => {
338+
const text = $btn.text().trim();
339+
340+
// Button label changed when object modified,
341+
// it shows Update --> Updating... --> Error --> Update
342+
if (text === 'Update') {
343+
cy.log('No need to click on Update again');
344+
} else {
345+
cy.get(buttonSelector, { timeout: 30000 })
346+
.should(($btn) => {
347+
expect($btn.text().trim()).to.eq('Update');
348+
});
349+
350+
cy.get(buttonSelector)
351+
.should('be.visible')
352+
.and('contain.text', 'Update')
353+
.click();
354+
355+
cy.log('Second click complete');
356+
}
357+
});
358+
}
359+
});
360+
}
325361
})
326362
};
327363
// Ensure dropdown is not present

0 commit comments

Comments
 (0)