Skip to content
Open
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
19 changes: 18 additions & 1 deletion src/SIL.XForge.Scripture/ClientApp/src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
{ provide: ErrorReportingService, useMock: mockedErrorReportingService },
{ provide: BreakpointObserver, useClass: TestBreakpointObserver },
{ provide: DialogService, useMock: mockedDialogService },
provideNoopAnimations()

Check warning on line 126 in src/SIL.XForge.Scripture/ClientApp/src/app/app.component.spec.ts

View workflow job for this annotation

GitHub Actions / Lint and Prettier (22.23.4, 11.11.0, 12.11.2)

`provideNoopAnimations` is deprecated. 20.2 Use `animate.enter` or `animate.leave` instead. Intent to remove in v23
]
}));

Expand Down Expand Up @@ -372,6 +372,20 @@
expect(env.location.path()).toEqual('/projects');
}));

it('shows the removed from project dialog once when the project keeps changing', fakeAsync(() => {
const env = new TestEnvironment();
env.navigate(['/projects', 'project01']);
env.init();

expect(env.selectedProjectId).toEqual('project01');
// The sync that removes the user goes on to change the project before the app has navigated away
env.removeUserFromProject('project01', { thenChangeProjectTimes: 2 });

verify(mockedDialogService.message(anything())).once();
verify(mockedSFProjectService.localDelete('project01')).once();
expect(env.location.path()).toEqual('/projects');
}));

it('response to remote project change for serval admin', fakeAsync(() => {
const env = new TestEnvironment();
env.setCurrentUser('user05');
Expand Down Expand Up @@ -1009,9 +1023,12 @@
this.wait();
}

removeUserFromProject(projectId: string): void {
removeUserFromProject(projectId: string, { thenChangeProjectTimes = 0 } = {}): void {
const projectDoc = this.realtimeService.get<SFProjectProfileDoc>(SFProjectProfileDoc.COLLECTION, projectId);
projectDoc.submitJson0Op(op => op.unset<string>(p => p.userRoles['user01']), false);
for (let i = 0; i < thenChangeProjectTimes; i++) {
projectDoc.submitJson0Op(op => op.inc(p => p.sync.queuedCount, 1), false);
}
this.wait();
}

Expand Down
6 changes: 5 additions & 1 deletion src/SIL.XForge.Scripture/ClientApp/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,13 @@ export class AppComponent extends DataLoadingComponent implements OnInit, OnDest
}
// See if the user was removed from the project
if (!(this.currentUserDoc.id in this._selectedProjectDoc.data.userRoles)) {
// The user has been removed from the project
// The user has been removed from the project, so unsubscribe to prevent multiple notices
this.selectedProjectChangedSub?.unsubscribe();
this.selectedProjectDeleteSub?.unsubscribe();
void this.showProjectDeletedDialog();
void this.projectService.localDelete(this._selectedProjectDoc.id);
// showProjectDeletedDialog redirects, so return early to avoid redirect checkAppAccess would do
return;
}

checkAppAccess(
Expand Down
Loading