1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-04-10 01:16:39 +02:00

fix: frontend tests after Cypress upgrade (#9505)

The fix involved:

1. [Find the first button to click to create a feature
flag](9b4500cded) (there are 2)
2. [Find the button that's not disabled to remove
access](fad627c6b3)
3. [Don't wait for animations](5ce6ca59f5)
except in [this case](f4a7819ad1)
This commit is contained in:
Gastón Fournier 2025-03-11 10:43:26 +01:00 committed by GitHub
parent ec5cc71ca1
commit f718e00b39
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 30 additions and 9 deletions

View File

@ -150,7 +150,10 @@ describe('project-access', () => {
});
it('can remove access', () => {
cy.get(`[data-testid='${PA_REMOVE_BUTTON_ID}']`).first().click();
cy.get(`[data-testid='${PA_REMOVE_BUTTON_ID}']`)
.filter(':not(:disabled)')
.first()
.click();
cy.intercept(
'DELETE',

View File

@ -60,7 +60,7 @@ export const createFeature_UI = (
cy.wait(5_000);
cy.get('[data-testid=NAVIGATE_TO_CREATE_FEATURE').click(uiOpts);
cy.get('[data-testid=NAVIGATE_TO_CREATE_FEATURE').first().click(uiOpts);
cy.intercept('POST', `/api/admin/projects/${projectName}/features`).as(
'createFeature',
@ -72,10 +72,14 @@ export const createFeature_UI = (
cy.get("[data-testid='FORM_DESCRIPTION_INPUT'] textarea")
.first()
.type('hello-world', uiOpts);
if (!shouldWait)
return cy.get("[data-testid='FORM_CREATE_BUTTON']").click(uiOpts);
else cy.get("[data-testid='FORM_CREATE_BUTTON']").click(uiOpts);
return cy.wait('@createFeature');
const clicked = cy
.get("[data-testid='FORM_CREATE_BUTTON']")
.first()
.click(uiOpts);
if (shouldWait) {
return cy.wait('@createFeature');
}
return clicked;
};
export const createProject_UI = (
@ -161,7 +165,10 @@ export const addFlexibleRolloutStrategyToFeature_UI = (
cy.get('[data-testid=ADD_CONSTRAINT_ID]').click();
cy.get('[data-testid=DIALOGUE_CONFIRM_ID]').click();
}
cy.get(`[data-testid=STRATEGY_FORM_SUBMIT_ID]`).first().click();
// this one needs to wait until the dropdown selector of stickiness is set, that's why waitForAnimations: true
cy.get(`[data-testid=STRATEGY_FORM_SUBMIT_ID]`)
.first()
.click({ waitForAnimations: true });
return cy.wait('@addStrategyToFeature');
};
@ -209,7 +216,10 @@ export const updateFlexibleRolloutStrategy_UI = (
},
).as('updateStrategy');
cy.get(`[data-testid=STRATEGY_FORM_SUBMIT_ID]`).first().click();
// this one needs to wait until the dropdown selector of stickiness is set, that's why waitForAnimations: true
cy.get(`[data-testid=STRATEGY_FORM_SUBMIT_ID]`)
.first()
.click({ waitForAnimations: true });
return cy.wait('@updateStrategy');
};
@ -284,7 +294,10 @@ export const addUserIdStrategyToFeature_UI = (
},
).as('addStrategyToFeature');
cy.get(`[data-testid=STRATEGY_FORM_SUBMIT_ID]`).first().click();
// this one needs to wait until the dropdown selector of stickiness is set, that's why waitForAnimations: true
cy.get(`[data-testid=STRATEGY_FORM_SUBMIT_ID]`)
.first()
.click({ waitForAnimations: true });
return cy.wait('@addStrategyToFeature');
};

View File

@ -68,3 +68,8 @@ Cypress.Commands.overwrite('visit', (originalFn, url, options = {}) => {
return originalFn(url, options);
});
Cypress.Commands.overwrite('click', (originalFn, x, y, options = {}) => {
options.waitForAnimations = false;
return originalFn(x, y, options);
});