1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00

test: skip vercel toolbar in e2e tests (#8273)

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
https://github.com/cypress-io/cypress/issues/19564
This commit is contained in:
Nuno Góis 2024-09-26 12:53:31 +01:00 committed by GitHub
parent 5a874df915
commit eb01b44e69
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 0 deletions

View File

@ -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>;
}
}

View File

@ -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);
});