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

refactor: avoid splash pages in e2e tests (#810)

This commit is contained in:
olav 2022-03-23 12:45:23 +01:00 committed by GitHub
parent 47e43dc23c
commit cc0b9f7291
4 changed files with 17 additions and 12 deletions

View File

@ -1,6 +1,7 @@
/// <reference types="cypress" />
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',

View File

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

View File

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

View File

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