diff --git a/src/web/components/SiteTour/tourHelpers.spec.ts b/src/web/components/SiteTour/tourHelpers.spec.ts index d9878194..e9cb3583 100644 --- a/src/web/components/SiteTour/tourHelpers.spec.ts +++ b/src/web/components/SiteTour/tourHelpers.spec.ts @@ -4,7 +4,7 @@ import { createMockParticipant, createMockUser } from '../../../testHelpers/data import { createUserContextValue } from '../../../testHelpers/testContextProvider'; import { compareVersions } from './tourHelpers'; import { tourSteps } from './tourSteps'; -import { GetTourSteps,tourStorageKey } from './tourStorage'; +import { GetTourSteps, tourStorageKey } from './tourStorage'; describe('testing tour storage helper functions', () => { const mockParticipant = createMockParticipant(); @@ -29,7 +29,7 @@ describe('testing tour storage helper functions', () => { mockUser.currentParticipantUserRoles = [{ id: UserRoleId.Admin, roleName: 'Admin' }]; mockUser.participants = [mockParticipant, mockParticipant2] as Participant[]; mockParticipant.currentUserRoleIds = [UserRoleId.Admin]; - localStorage.removeItem(tourStorageKey); + localStorage.setItem(tourStorageKey, JSON.stringify({ seenForVersions: ['0.1.0'] })); const steps = GetTourSteps(mockLoggedInUser, mockParticipant); diff --git a/src/web/components/SiteTour/tourStorage.spec.ts b/src/web/components/SiteTour/tourStorage.spec.ts index f209a3c6..b40c090f 100644 --- a/src/web/components/SiteTour/tourStorage.spec.ts +++ b/src/web/components/SiteTour/tourStorage.spec.ts @@ -58,4 +58,9 @@ describe('Tour tests', () => { const steps = GetTourSteps(mockLoggedInUser, mockParticipant, mockTourData); expect(steps).not.toContainEqual(mockTourData[0]); }); + test('When user is logging in for the first time, no steps are returned', () => { + localStorage.removeItem(tourStorageKey); + const steps = GetTourSteps(mockLoggedInUser, mockParticipant, mockTourData); + expect(steps).toHaveLength(0); + }); }); diff --git a/src/web/components/SiteTour/tourStorage.ts b/src/web/components/SiteTour/tourStorage.ts index 268b12a9..a011bee7 100644 --- a/src/web/components/SiteTour/tourStorage.ts +++ b/src/web/components/SiteTour/tourStorage.ts @@ -43,6 +43,12 @@ export function GetTourSteps( ): VersionedTourStep[] { // search seen steps for the highest version number const storedVersions = getTourData().seenForVersions; + // if there are no seen versions, this is the users first time in the portal + // new features don't make sense to show in this case + if (storedVersions.length === 0) { + markTourAsSeen(); + return []; + } // Sort in reverse order - highest first storedVersions.sort((first, second) => compareVersions(second, first)); const highestSeenVersion = storedVersions.length > 0 ? storedVersions[0] : '0.0.0';