Skip to content

Commit b6bd1e2

Browse files
skip onboarding tour in cypress tests
1 parent c68ed68 commit b6bd1e2

3 files changed

Lines changed: 16 additions & 2 deletions

File tree

datahub-web-react/src/app/onboarding/OnboardingTour.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { useUserContext } from '../context/useUserContext';
88
import { REDESIGN_COLORS } from '../entityV2/shared/constants';
99
import { useIsThemeV2 } from '../useIsThemeV2';
1010
import { convertStepId, getConditionalStepIdsToAdd, getStepsToRender } from './utils';
11+
import useShouldSkipOnboardingTour from './useShouldSkipOnboardingTour';
1112

1213
type Props = {
1314
stepIds: string[];
@@ -56,7 +57,9 @@ export const OnboardingTour = ({ stepIds }: Props) => {
5657
});
5758
}
5859

59-
if (!filteredSteps.length) return null;
60+
const shouldSkipOnboardingTour = useShouldSkipOnboardingTour();
61+
62+
if (!filteredSteps.length || shouldSkipOnboardingTour) return null;
6063

6164
return (
6265
<Tour
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// this key is used in commands.js to turn off onboarding tours in cypress tests
2+
const SKIP_ONBOARDING_TOUR_KEY = 'skipOnboardingTour';
3+
4+
export default function useShouldSkipOnboardingTour() {
5+
const shouldSkipOnboardingTour = localStorage.getItem(SKIP_ONBOARDING_TOUR_KEY);
6+
7+
return shouldSkipOnboardingTour === 'true';
8+
}

smoke-test/tests/cypress/cypress/support/commands.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ export function getTimestampMillisNumDaysAgo(numDays) {
2222
return dayjs().subtract(numDays, "day").valueOf();
2323
}
2424

25+
const SKIP_ONBOARDING_TOUR_KEY = "skipOnboardingTour";
26+
2527
Cypress.Commands.add("login", () => {
2628
cy.request({
2729
method: "POST",
@@ -31,7 +33,7 @@ Cypress.Commands.add("login", () => {
3133
password: Cypress.env("ADMIN_PASSWORD"),
3234
},
3335
retryOnStatusCodeFailure: true,
34-
});
36+
}).then(() => localStorage.setItem(SKIP_ONBOARDING_TOUR_KEY, "true"));
3537
});
3638

3739
Cypress.Commands.add("loginWithCredentials", (username, password) => {
@@ -45,6 +47,7 @@ Cypress.Commands.add("loginWithCredentials", (username, password) => {
4547
}
4648
cy.contains("Sign In").click();
4749
cy.get(".ant-avatar-circle").should("be.visible");
50+
localStorage.setItem(SKIP_ONBOARDING_TOUR_KEY, "true");
4851
});
4952

5053
Cypress.Commands.add("deleteUrn", (urn) => {

0 commit comments

Comments
 (0)