Skip to content

Commit

Permalink
fix: force languages in cypress browser for tests (#8049)
Browse files Browse the repository at this point in the history
To fix this we had to create a free trial account on cypress and enable
the recording of the test. That way we found out the issue was with a
locale:
![image
(38)](https://github.com/user-attachments/assets/db2fad23-6fec-47c0-8c6f-a93f3e4e4c4c)

Probably, this works well locally because our local machines do have a
default locale, but probably we don't have one when running in CI, and
millify library is causing the tests to fail specifically at this line:
https://github.com/Unleash/unleash/blob/363911c4a1ce94dd467a950ec84ccdc9a3ec7d75/frontend/src/component/common/AvatarGroup/AvatarGroup.tsx#L89
(validated
[here](https://github.com/Unleash/unleash/pull/8040/files#diff-afc857890da2221bd34feed0ff45dd7745ff32fb0b27055214cbe69896d5311dL89)).

Unfortunately, upgrading millify didn't help, but downgrading to v5
(which doesn't support locales), solve the issue at the cost of not
having the up-to-date library:
#8048

I believe the issue is related to this locale `c` reported here:
cypress-io/cypress#7890 (comment)
because only after overriding the languages this worked
  • Loading branch information
gastonfournier authored Sep 3, 2024
1 parent 6a51a0b commit acecffd
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build_frontend_prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
pull_request:
paths:
- frontend/**
- .github/workflows/**frontend**

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion frontend/cypress/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ declare namespace Cypress {
// STRATEGY
addUserIdStrategyToFeature_UI(
featureName: string,
projectName?: string,
projectName: string,
): Chainable;
addFlexibleRolloutStrategyToFeature_UI(
options: AddFlexibleRolloutStrategyOptions,
Expand Down
15 changes: 4 additions & 11 deletions frontend/cypress/integration/feature/feature.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,10 @@ describe('feature', () => {
cy.addFlexibleRolloutStrategyToFeature_UI({
featureToggleName,
project: projectName,
}).then(() => {
cy.updateFlexibleRolloutStrategy_UI(
featureToggleName,
projectName,
).then(() =>
cy.deleteFeatureStrategy_UI(
featureToggleName,
false,
projectName,
),
);
});

cy.updateFlexibleRolloutStrategy_UI(featureToggleName, projectName);

cy.deleteFeatureStrategy_UI(featureToggleName, false, projectName);
});
});
4 changes: 4 additions & 0 deletions frontend/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ import {
//@ts-ignore
} from './API';

Cypress.on('window:before:load', (window) => {
Object.defineProperty(window.navigator, 'language', { value: 'en' });
Object.defineProperty(window.navigator, 'languages', { value: ['en'] });
});
Cypress.Commands.add('runBefore', runBefore);
Cypress.Commands.add('login_UI', login_UI);
Cypress.Commands.add('createSegment_UI', createSegment_UI);
Expand Down

0 comments on commit acecffd

Please sign in to comment.