Skip to content
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 @@ -220,7 +220,7 @@
{ provide: TabMenuService, useValue: EditorTabMenuService },
{ provide: PermissionsService, useMock: mockedPermissionsService },
{ provide: LynxWorkspaceService, useMock: mockedLynxWorkspaceService },
provideNoopAnimations()

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

View workflow job for this annotation

GitHub Actions / Lint and Prettier (22.13.0, 11.11.0, 11.10.0)

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

Expand Down Expand Up @@ -4051,6 +4051,45 @@
expect(spyConsolidate).not.toHaveBeenCalled();
flush();
}));

it('should remove the source tab when the source project is removed and tab groups are consolidated', fakeAsync(() => {
const env = new TestEnvironment();
env.wait();
env.breakpointObserver.emitObserveValue(true);
env.component['tabStateInitialized$'].next(true);
env.component['targetEditorLoaded$'].next();
env.wait();

// The source tab has been consolidated into the target tab group
expect(env.component.tabState.getTabGroup('target')?.tabs.map(tab => tab.type)).toEqual([
'project-source',
'project-target'
]);

env.removeSourceProject('project01');

expect(env.component.tabState.getTabGroup('target')?.tabs.map(tab => tab.type)).toEqual(['project-target']);
discardPeriodicTasks();
env.dispose();
}));

it('should remove the source tab when the source project is removed and tab groups are not consolidated', fakeAsync(() => {
const env = new TestEnvironment();
env.wait();
env.breakpointObserver.emitObserveValue(false);
env.component['tabStateInitialized$'].next(true);
env.component['targetEditorLoaded$'].next();
env.wait();

expect(env.component.tabState.getTabGroup('source')?.tabs.map(tab => tab.type)).toEqual(['project-source']);

env.removeSourceProject('project01');

// The blank tab takes the place of the removed source tab
expect(env.component.tabState.getTabGroup('source')?.tabs.map(tab => tab.type)).toEqual(['blank-tab']);
discardPeriodicTasks();
env.dispose();
}));
});

describe('initEditorTabs', () => {
Expand Down Expand Up @@ -5354,6 +5393,13 @@
this.fixture.detectChanges();
}

/** Simulates an administrator removing the source project on the project settings page. */
removeSourceProject(projectId: string): void {
const projectDoc: SFProjectProfileDoc = this.getProjectDoc(projectId);
projectDoc.submitJson0Op(op => op.unset(p => p.translateConfig.source!), false);
this.wait();
}

updateFontSize(projectId: string, size: number): void {
const projectDoc: SFProjectProfileDoc = this.getProjectDoc(projectId);
projectDoc.submitJson0Op(op => op.set(p => p.defaultFontSize, size), false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1505,7 +1505,9 @@ export class EditorComponent extends DataLoadingComponent implements OnDestroy,
}
}
} else if (existingSourceTab != null) {
this.tabState.removeTab('source', existingSourceTab.index);
// Remove from the group the tab is actually in, which is not the 'source' group when tab groups are
// consolidated for small screens
this.tabState.removeTab(existingSourceTab.groupId, existingSourceTab.index);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { TestBed } from '@angular/core/testing';
import { Json0OpBuilder } from 'realtime-server/lib/esm/common/utils/json0-op-builder';
import { LynxInsightFilter, LynxInsightType } from 'realtime-server/lib/esm/scriptureforge/models/lynx-insight';
import { createTestProject } from 'realtime-server/lib/esm/scriptureforge/models/sf-project-test-data';
import { SFProjectUserConfig } from 'realtime-server/lib/esm/scriptureforge/models/sf-project-user-config';
import { createTestProjectUserConfig } from 'realtime-server/lib/esm/scriptureforge/models/sf-project-user-config-test-data';
import { TextInfo } from 'realtime-server/lib/esm/scriptureforge/models/text-info';
import { Json0OpBuilder } from 'realtime-server/lib/esm/common/utils/json0-op-builder';
import { SFProjectUserConfig } from 'realtime-server/lib/esm/scriptureforge/models/sf-project-user-config';
import { BehaviorSubject, firstValueFrom, Subject } from 'rxjs';
import { anything, capture, instance, mock, resetCalls, verify, when } from 'ts-mockito';
import { ActivatedBookChapterService, RouteBookChapter } from 'xforge-common/activated-book-chapter.service';
Expand Down Expand Up @@ -380,6 +380,7 @@ describe('LynxInsightStateService', () => {
describe('panel state persistence', () => {
it('should not write to project user config on load when panel state is unchanged', () => {
verify(mockProjectUserConfigDoc.submitJson0Op(anything())).never();
expect().nothing();
});

it('should set only the panelData sub-path, preserving other lynxInsightState props', () => {
Expand Down
Loading