Skip to content

Commit

Permalink
test: skip vercel toolbar in e2e tests (#8273)
Browse files Browse the repository at this point in the history
Some e2e Cypress tests were failing due to the Vercel live feedback
toolbar covering interactive elements, preventing test actions from
completing:
https://github.com/Unleash/unleash/actions/runs/11048512034/job/30692949711#step:4:136

This PR addresses the issue by disabling the Vercel toolbar specifically
during Cypress tests. This is done by setting the
`x-vercel-skip-toolbar` header, which Vercel provides to prevent the
toolbar from interfering with automated tests. You can find more
information about this feature in the Vercel documentation: [Disable
Toolbar for
Automation](https://vercel.com/docs/workflow-collaboration/vercel-toolbar/managing-toolbar#disable-toolbar-for-automation).

Specific type declarations were needed due to
cypress-io/cypress#19564
  • Loading branch information
nunogois authored Sep 26, 2024
1 parent 5a874df commit eb01b44
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
9 changes: 9 additions & 0 deletions frontend/cypress/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,14 @@ declare namespace Cypress {
environment: IEnvironment,
options?: Partial<Cypress.RequestOptions>,
): Chainable;
visit(
options: Partial<Cypress.VisitOptions & PopulatePreloadsOptions> & {
url: string;
},
): Cypress.Chainable<Cypress.AUTWindow>;
visit(
url: string,
options?: Partial<Cypress.VisitOptions & PopulatePreloadsOptions>,
): Cypress.Chainable<Cypress.AUTWindow>;
}
}
10 changes: 10 additions & 0 deletions frontend/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,13 @@ Cypress.Commands.add(
updateFlexibleRolloutStrategy_UI,
);
Cypress.Commands.add('createEnvironment_API', createEnvironment_API);
Cypress.Commands.overwrite('visit', (originalFn, url, options = {}) => {
if (!options.headers) {
options.headers = {};
}

// Add the x-vercel-skip-toolbar header. See: https://vercel.com/docs/workflow-collaboration/vercel-toolbar/managing-toolbar#disable-toolbar-for-automation
options.headers['x-vercel-skip-toolbar'] = '1';

return originalFn(url, options);
});

0 comments on commit eb01b44

Please sign in to comment.