Skip to content

Commit

Permalink
Merge pull request #2601 from Hyperkid123/fix-broken-e2e-test-runs
Browse files Browse the repository at this point in the history
Fix broken e2e test runs
  • Loading branch information
Hyperkid123 authored Aug 4, 2023
2 parents 1fdd556 + 26d1f24 commit f2edb10
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 2 deletions.
4 changes: 3 additions & 1 deletion cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ export default defineConfig({
// required for the SSO redirect
chromeWebSecurity: false,
video: false,
setupNodeEvents() {
setupNodeEvents(on, config) {
require('cypress-localstorage-commands/plugin')(on, config);
return config;
// implement node event listeners here
},
},
Expand Down
7 changes: 7 additions & 0 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,14 @@ Cypress.Commands.add('login', () => {
() => {
cy.intercept({ url: '/beta/apps/*', times: 1 }, {});
cy.intercept({ url: '/api/', times: 4 }, {});
// This JS file causes randomly an uncaught exception on login page which blocks the tests
// Cannot read properties of undefined (reading 'setAttribute')
cy.intercept({ url: 'https://sso.stage.redhat.com/auth/resources/0833r/login/rhd-theme/dist/pfelements/bundle.js' }, {});
cy.visit('/');
// disable analytics integrations
cy.setLocalStorage('chrome:analytics:disable', 'true');
cy.setLocalStorage('chrome:segment:disable', 'true');

cy.wait(1000);
// login into the session
cy.get('#username-verification').type(Cypress.env('E2E_USER'));
Expand Down
1 change: 1 addition & 0 deletions cypress/support/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

// Import commands.js using ES2015 syntax:
import './commands';
import 'cypress-localstorage-commands';

// Alternatively you can use CommonJS syntax:
// require('./commands')
Expand Down
20 changes: 20 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"clean-webpack-plugin": "^4.0.0",
"css-loader": "^6.7.3",
"cypress": "^12.7.0",
"cypress-localstorage-commands": "^2.2.3",
"eslint": "^8.35.0",
"fork-ts-checker-webpack-plugin": "^7.3.0",
"git-revision-webpack-plugin": "^5.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/analytics/SegmentProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ const SegmentProvider: React.FC<SegmentProviderProps> = ({ activeModule, childre
}
analytics.current = AnalyticsBrowser.load(
{ writeKey: newKey },
{ initialPageview: false, disableClientPersistence: true, integrations: { All: !isITLessEnv } }
{ initialPageview: false, disableClientPersistence: true, integrations: { All: !isITLessEnv && !disableIntegrations } }
);
window.segment = analytics.current;
resetIntegrations(analytics.current);
Expand Down

0 comments on commit f2edb10

Please sign in to comment.