From cc0b9f7291a95894e66692b3efe5fa52181eceb8 Mon Sep 17 00:00:00 2001 From: olav Date: Wed, 23 Mar 2022 12:45:23 +0100 Subject: [PATCH] refactor: avoid splash pages in e2e tests (#810) --- frontend/cypress/integration/feature/feature.spec.ts | 8 ++++++++ frontend/src/component/splash/SplashPage/SplashPage.tsx | 9 +-------- .../splash/SplashPageRedirect/SplashPageRedirect.tsx | 5 +---- frontend/src/component/splash/splash.tsx | 7 +++++++ 4 files changed, 17 insertions(+), 12 deletions(-) create mode 100644 frontend/src/component/splash/splash.tsx diff --git a/frontend/cypress/integration/feature/feature.spec.ts b/frontend/cypress/integration/feature/feature.spec.ts index 03162bec0f..af5d83fe89 100644 --- a/frontend/cypress/integration/feature/feature.spec.ts +++ b/frontend/cypress/integration/feature/feature.spec.ts @@ -1,6 +1,7 @@ /// import { disableFeatureStrategiesProductionGuard } from '../../../src/component/feature/FeatureStrategy/FeatureStrategyProdGuard/FeatureStrategyProdGuard'; +import { activeSplashIds } from '../../../src/component/splash/splash'; const randomId = String(Math.random()).split('.')[1]; const featureToggleName = `unleash-e2e-${randomId}`; @@ -11,6 +12,13 @@ const baseUrl = Cypress.config().baseUrl; let strategyId = ''; describe('feature', () => { + before(() => { + // Visit all splash pages to mark them as seen. + activeSplashIds.forEach(splashId => { + cy.visit(`/splash/${splashId}`); + }); + }); + after(() => { cy.request({ method: 'DELETE', diff --git a/frontend/src/component/splash/SplashPage/SplashPage.tsx b/frontend/src/component/splash/SplashPage/SplashPage.tsx index 96c20f6ed3..bbac75b27c 100644 --- a/frontend/src/component/splash/SplashPage/SplashPage.tsx +++ b/frontend/src/component/splash/SplashPage/SplashPage.tsx @@ -5,14 +5,7 @@ import useSplashApi from 'hooks/api/actions/useSplashApi/useSplashApi'; import { SplashPageOperators } from 'component/splash/SplashPageOperators/SplashPageOperators'; import { useEffect } from 'react'; import { useAuthSplash } from 'hooks/api/getters/useAuth/useAuthSplash'; - -// All known splash IDs. -export const splashIds = ['environments', 'operators'] as const; - -// Active splash IDs that may be shown to the user. -export const activeSplashIds: SplashId[] = ['operators']; - -export type SplashId = typeof splashIds[number]; +import { splashIds, SplashId } from 'component/splash/splash'; export const SplashPage = () => { const splashId = useRequiredPathParam('splashId'); diff --git a/frontend/src/component/splash/SplashPageRedirect/SplashPageRedirect.tsx b/frontend/src/component/splash/SplashPageRedirect/SplashPageRedirect.tsx index 902876904f..b2e3951f61 100644 --- a/frontend/src/component/splash/SplashPageRedirect/SplashPageRedirect.tsx +++ b/frontend/src/component/splash/SplashPageRedirect/SplashPageRedirect.tsx @@ -4,10 +4,7 @@ import { matchPath } from 'react-router'; import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig'; import { IFlags } from 'interfaces/uiConfig'; import { IAuthSplash } from 'hooks/api/getters/useAuth/useAuthEndpoint'; -import { - activeSplashIds, - SplashId, -} from 'component/splash/SplashPage/SplashPage'; +import { activeSplashIds, SplashId } from 'component/splash/splash'; export const SplashPageRedirect = () => { const { pathname } = useLocation(); diff --git a/frontend/src/component/splash/splash.tsx b/frontend/src/component/splash/splash.tsx new file mode 100644 index 0000000000..907f1320b3 --- /dev/null +++ b/frontend/src/component/splash/splash.tsx @@ -0,0 +1,7 @@ +// All known splash IDs. +export const splashIds = ['environments', 'operators'] as const; + +// Active splash IDs that may be shown to the user. +export const activeSplashIds: SplashId[] = ['operators']; + +export type SplashId = typeof splashIds[number];