Skip to content

Commit

Permalink
Merge pull request #570 from IABTechLab/ans-UID2-4377-disable-ui-tour…
Browse files Browse the repository at this point in the history
…-new-users

Do not show UI tour with updates for new users
  • Loading branch information
ashleysmithTTD authored Nov 4, 2024
2 parents f1080f4 + 10699c1 commit c2e9444
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/web/components/SiteTour/tourHelpers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);

Expand Down
5 changes: 5 additions & 0 deletions src/web/components/SiteTour/tourStorage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
6 changes: 6 additions & 0 deletions src/web/components/SiteTour/tourStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit c2e9444

Please sign in to comment.