Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the old welcome dialog and invitation dialog components #493

Merged
merged 3 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ const mockMessageService = {
};

const mockRouter = {
async navigate(path: any[]) {
return {};
},
navigate: jasmine.createSpy('navigate'),
};

describe('OnboardingComponent #onboarding', () => {
Expand Down Expand Up @@ -212,4 +210,49 @@ describe('OnboardingComponent #onboarding', () => {
expect(getItemSpy).toHaveBeenCalledWith('shareToken');
expect(removeItemSpy).toHaveBeenCalledWith('shareToken');
});

it('should navigate to /app/welcome if shareToken is not in localStorage and isGlam is false', async () => {
const { instance, fixture } = await shallow.render();

spyOn(localStorage, 'getItem').and.returnValue(null);
instance.isGlam = false;
instance.acceptedInvite = false;
instance.setScreen(OnboardingScreen.done);
instance.selectedPendingArchive = null;
fixture.detectChanges();
await fixture.whenStable();

expect(mockRouter.navigate).toHaveBeenCalledWith(['/app', 'welcome']);
});

it('should navigate to /app if shareToken is not in localStorage and isGlam is true', async () => {
const { instance, fixture } = await shallow.render();

spyOn(localStorage, 'getItem').and.returnValue(null);
instance.isGlam = true;
instance.acceptedInvite = false;
instance.setScreen(OnboardingScreen.done);
instance.selectedPendingArchive = null;
fixture.detectChanges();
await fixture.whenStable();

expect(mockRouter.navigate).toHaveBeenCalledWith(['/app']);
});

it('should navigate to /app/welcome-invite if shareToken is not in localStorage and isGlam is true', async () => {
const { instance, fixture } = await shallow.render();

spyOn(localStorage, 'getItem').and.returnValue(null);
instance.isGlam = false;
instance.acceptedInvite = true;
instance.setScreen(OnboardingScreen.done);
instance.selectedPendingArchive = null;
fixture.detectChanges();
await fixture.whenStable();

expect(mockRouter.navigate).toHaveBeenCalledWith([
'/app',
'welcome-invitation',
]);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,16 @@ export class OnboardingComponent implements OnInit {
this.selectedPendingArchive = null;
}
if (screen === OnboardingScreen.done) {
if (this.acceptedInvite) {
if (!this.isGlam && this.acceptedInvite) {
this.router.navigate(['/app', 'welcome-invitation']);
}
if (localStorage.getItem('shareToken')) {
localStorage.removeItem('shareToken');
this.router.navigate(['/app', 'shares']);
} else {
} else if (!this.isGlam) {
this.router.navigate(['/app', 'welcome']);
} else {
this.router.navigate(['/app']);
}
}
}
Expand Down
Loading