From 302a15561128b344e455b4b7c3fce7b23c45da5a Mon Sep 17 00:00:00 2001 From: crisnicandrei <62384997+crisnicandrei@users.noreply.github.com> Date: Tue, 26 Nov 2024 18:59:03 +0200 Subject: [PATCH 1/3] Revert the dialog component removal This pr reverts the removal of the dialog component from the onboarding component and only redirects the user after completing the process --- .../onboarding/onboarding.component.spec.ts | 17 ++++++++++++++--- .../onboarding/onboarding.component.ts | 5 +---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/app/onboarding/components/onboarding/onboarding.component.spec.ts b/src/app/onboarding/components/onboarding/onboarding.component.spec.ts index 8a55e4758..816f50612 100644 --- a/src/app/onboarding/components/onboarding/onboarding.component.spec.ts +++ b/src/app/onboarding/components/onboarding/onboarding.component.spec.ts @@ -59,9 +59,7 @@ const mockMessageService = { }; const mockRouter = { - async navigate(path: any[]) { - return {}; - }, + navigate: jasmine.createSpy('navigate'), }; describe('OnboardingComponent #onboarding', () => { @@ -212,4 +210,17 @@ describe('OnboardingComponent #onboarding', () => { expect(getItemSpy).toHaveBeenCalledWith('shareToken'); expect(removeItemSpy).toHaveBeenCalledWith('shareToken'); }); + + it('should navigate to /app if shareToken is not in localStorage', async () => { + const { instance, fixture } = await shallow.render(); + + spyOn(localStorage, 'getItem').and.returnValue(null); + + instance.setScreen(OnboardingScreen.done); + instance.selectedPendingArchive = null; + fixture.detectChanges(); + await fixture.whenStable(); + + expect(mockRouter.navigate).toHaveBeenCalledWith(['/app']); + }); }); diff --git a/src/app/onboarding/components/onboarding/onboarding.component.ts b/src/app/onboarding/components/onboarding/onboarding.component.ts index 09446fa81..68570f4f1 100644 --- a/src/app/onboarding/components/onboarding/onboarding.component.ts +++ b/src/app/onboarding/components/onboarding/onboarding.component.ts @@ -90,14 +90,11 @@ export class OnboardingComponent implements OnInit { this.selectedPendingArchive = null; } if (screen === OnboardingScreen.done) { - if (this.acceptedInvite) { - this.router.navigate(['/app', 'welcome-invitation']); - } if (localStorage.getItem('shareToken')) { localStorage.removeItem('shareToken'); this.router.navigate(['/app', 'shares']); } else { - this.router.navigate(['/app', 'welcome']); + this.router.navigate(['/app']); } } } From f89aaaa6abb098200fdd1e5cd2b73ac51ec40c03 Mon Sep 17 00:00:00 2001 From: crisnicandrei <62384997+crisnicandrei@users.noreply.github.com> Date: Tue, 3 Dec 2024 17:38:16 +0200 Subject: [PATCH 2/3] fix test --- .../components/onboarding/onboarding.component.spec.ts | 7 ++++--- .../components/onboarding/onboarding.component.ts | 5 +++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/app/onboarding/components/onboarding/onboarding.component.spec.ts b/src/app/onboarding/components/onboarding/onboarding.component.spec.ts index 816f50612..e51b89a2f 100644 --- a/src/app/onboarding/components/onboarding/onboarding.component.spec.ts +++ b/src/app/onboarding/components/onboarding/onboarding.component.spec.ts @@ -211,16 +211,17 @@ describe('OnboardingComponent #onboarding', () => { expect(removeItemSpy).toHaveBeenCalledWith('shareToken'); }); - it('should navigate to /app if shareToken is not in localStorage', async () => { + 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']); + expect(mockRouter.navigate).toHaveBeenCalledWith(['/app', 'welcome']); }); }); diff --git a/src/app/onboarding/components/onboarding/onboarding.component.ts b/src/app/onboarding/components/onboarding/onboarding.component.ts index 68570f4f1..ff7b05806 100644 --- a/src/app/onboarding/components/onboarding/onboarding.component.ts +++ b/src/app/onboarding/components/onboarding/onboarding.component.ts @@ -90,9 +90,14 @@ export class OnboardingComponent implements OnInit { this.selectedPendingArchive = null; } if (screen === OnboardingScreen.done) { + if (!this.isGlam && this.acceptedInvite) { + this.router.navigate(['/app', 'welcome-invitation']); + } if (localStorage.getItem('shareToken')) { localStorage.removeItem('shareToken'); this.router.navigate(['/app', 'shares']); + } else if (!this.isGlam) { + this.router.navigate(['/app', 'welcome']); } else { this.router.navigate(['/app']); } From f66ed3048106cea0c30d17cbdfce9111571c653d Mon Sep 17 00:00:00 2001 From: crisnicandrei <62384997+crisnicandrei@users.noreply.github.com> Date: Tue, 3 Dec 2024 17:48:52 +0200 Subject: [PATCH 3/3] fix test coverage --- .../onboarding/onboarding.component.spec.ts | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/app/onboarding/components/onboarding/onboarding.component.spec.ts b/src/app/onboarding/components/onboarding/onboarding.component.spec.ts index e51b89a2f..42b30fd56 100644 --- a/src/app/onboarding/components/onboarding/onboarding.component.spec.ts +++ b/src/app/onboarding/components/onboarding/onboarding.component.spec.ts @@ -224,4 +224,35 @@ describe('OnboardingComponent #onboarding', () => { 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', + ]); + }); });