From ae2094b94789e1fad6e9f8a2ae148613e1ae5e68 Mon Sep 17 00:00:00 2001 From: Raymond Luong Date: Thu, 19 Feb 2026 15:32:01 -0700 Subject: [PATCH] SF-3710 Do not autoselect translate books when starting a draft --- .../draft-generation-steps.component.spec.ts | 86 +------------------ .../draft-generation-steps.component.ts | 18 ---- 2 files changed, 2 insertions(+), 102 deletions(-) diff --git a/src/SIL.XForge.Scripture/ClientApp/src/app/translate/draft-generation/draft-generation-steps/draft-generation-steps.component.spec.ts b/src/SIL.XForge.Scripture/ClientApp/src/app/translate/draft-generation/draft-generation-steps/draft-generation-steps.component.spec.ts index c7ad7b66c2..a18d636c06 100644 --- a/src/SIL.XForge.Scripture/ClientApp/src/app/translate/draft-generation/draft-generation-steps/draft-generation-steps.component.spec.ts +++ b/src/SIL.XForge.Scripture/ClientApp/src/app/translate/draft-generation/draft-generation-steps/draft-generation-steps.component.spec.ts @@ -1100,90 +1100,6 @@ describe('DraftGenerationStepsComponent', () => { }); }); - describe('target contains previously selected books', () => { - const availableBooks = [{ bookNum: 2 }, { bookNum: 3 }]; - const allBooks = [{ bookNum: 1 }, ...availableBooks, { bookNum: 4 }]; - const draftingSourceBooks = availableBooks.concat({ bookNum: 5 }); - const draftingSourceId = 'draftingSource'; - const config = { - trainingSources: [ - { - projectRef: 'source1', - shortName: 'sP1', - writingSystem: { tag: 'eng' }, - texts: availableBooks.concat({ bookNum: 1 }) - }, - { - projectRef: 'source2', - shortName: 'sP2', - writingSystem: { tag: 'eng' }, - texts: availableBooks - } - ] as [DraftSource, DraftSource], - trainingTargets: [ - { - projectRef: projectId, - shortName: 'tT', - writingSystem: { tag: 'nllb' }, - texts: allBooks.filter(b => b.bookNum !== 4) - } - ] as [DraftSource], - draftingSources: [ - { - projectRef: draftingSourceId, - shortName: 'dS', - writingSystem: { tag: 'eng' }, - texts: draftingSourceBooks - } - ] as [DraftSource] - }; - - const mockTargetProjectDoc = { - id: 'project01', - data: createTestProjectProfile({ - texts: [{ bookNum: 1 }, { bookNum: 2 }, { bookNum: 3 }], - translateConfig: { - draftConfig: { - lastSelectedTrainingDataFiles: [], - lastSelectedTrainingScriptureRanges: [ - { projectId: 'source1', scriptureRange: 'GEN;1SA' }, - { projectId: 'source2', scriptureRange: '1SA;2SA' } - ], - lastSelectedTranslationScriptureRanges: [{ projectId: 'draftingSource', scriptureRange: 'EXO;LEV' }] - } - } - }) - } as SFProjectProfileDoc; - - beforeEach(fakeAsync(() => { - when(mockDraftSourceService.getDraftProjectSources()).thenReturn(of(config)); - when(mockActivatedProjectService.projectDoc).thenReturn(mockTargetProjectDoc); - when(mockActivatedProjectService.projectDoc$).thenReturn(of(mockTargetProjectDoc)); - setupProjectProfileMock( - draftingSourceId, - draftingSourceBooks.map(b => b.bookNum) - ); - when(mockFeatureFlagService.showDeveloperTools).thenReturn(createTestFeatureFlag(false)); - - fixture = TestBed.createComponent(DraftGenerationStepsComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - tick(); - })); - - it('should restore previously selected ranges', () => { - expect(component.selectedTranslateBooksAsString()).toEqual('Exodus and Leviticus'); - expect(component.booksToTranslate()).toEqual([ - { number: 2, selected: true }, - { number: 3, selected: true } - ]); - expect(component.selectedTrainingBooksByProj('project01')).toEqual([{ number: 1, selected: true }]); - //for source1, Genesis was previously selected, but it's no longer present on both source and target - expect(component.selectedTrainingBooksByProj('source1')).toEqual([{ number: 1, selected: true }]); - expect(component.selectedTrainingBooksByProj('source2')).toEqual([]); - }); - }); - describe('can add additional training data', () => { const availableBooks = [{ bookNum: 2 }, { bookNum: 3 }]; const draftingSourceId = 'draftingSource'; @@ -1403,6 +1319,8 @@ describe('DraftGenerationStepsComponent', () => { })); it('should localize and concatenate the books to translate', () => { + expect(component.selectedTranslateBooksAsString()).toEqual(''); + component.onTranslateBookSelect([3], config.draftingSources[0]); expect(component.selectedTranslateBooksAsString()).toEqual('Leviticus'); }); diff --git a/src/SIL.XForge.Scripture/ClientApp/src/app/translate/draft-generation/draft-generation-steps/draft-generation-steps.component.ts b/src/SIL.XForge.Scripture/ClientApp/src/app/translate/draft-generation/draft-generation-steps/draft-generation-steps.component.ts index b27f175060..0b68436201 100644 --- a/src/SIL.XForge.Scripture/ClientApp/src/app/translate/draft-generation/draft-generation-steps/draft-generation-steps.component.ts +++ b/src/SIL.XForge.Scripture/ClientApp/src/app/translate/draft-generation/draft-generation-steps/draft-generation-steps.component.ts @@ -368,7 +368,6 @@ export class DraftGenerationStepsComponent implements OnInit { } this.setInitialTrainingBooks(projectId!); - this.setInitialTranslateBooks(); // Store the books that are not in the target this.unusableTrainingTargetBooks = [...trainingSourceBooks].filter( @@ -694,23 +693,6 @@ export class DraftGenerationStepsComponent implements OnInit { this.showBookSelectionError = false; } - private setInitialTranslateBooks(): void { - // Get the previously selected translation books from the target project - const previousTranslation = - this.activatedProject.projectDoc?.data?.translateConfig.draftConfig.lastSelectedTranslationScriptureRanges ?? []; - for (const range of previousTranslation) { - const source = this.draftingSources.find(s => s.projectRef === range.projectId); - if (source !== undefined) { - for (const bookNum of booksFromScriptureRange(range.scriptureRange)) { - const sourceBook = this.availableTranslateBooks[source.projectRef].find(b => b.number === bookNum); - if (sourceBook !== undefined) { - sourceBook.selected = true; - } - } - } - } - } - private setInitialTrainingBooks(targetProjectId: string): void { // Get the previously selected training books from the target project const previousTraining =