Skip to content

Commit

Permalink
SF-3173 Show error when matching training pairs not selected (#2980)
Browse files Browse the repository at this point in the history
  • Loading branch information
RaymondLuong3 authored Jan 28, 2025
1 parent efa579c commit a5e77ed
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ <h4 class="explanation">
</button>
</div>
</mat-step>
<mat-step [completed]="isTrainingOptional || trainingSourceBooksSelected">
<mat-step
[completed]="(isTrainingOptional || trainingSourceBooksSelected) && translatedBooksSelectedInTrainingSources"
>
<ng-template matStepLabel>
{{ t("choose_books_for_training_header") }}
</ng-template>
Expand Down Expand Up @@ -133,15 +135,14 @@ <h2>{{ t("reference_books") }}</h2>
></app-book-multi-select>
}
}
@if (showBookSelectionError) {
<app-notice type="error">
{{ t("choose_books_for_training_error") }}
</app-notice>
}
@if (!translatedBooksSelectedInTrainingSources) {
<app-notice class="warn-translated-books-unselected" type="warning" icon="warning">
<app-notice class="error-translated-books-unselected" type="error">
{{ t("translated_book_selected_no_training_pair") }}
</app-notice>
} @else if (showBookSelectionError) {
<app-notice class="error-choose-training-books" type="error">
{{ t("choose_books_for_training_error") }}
</app-notice>
}
@if (translatedBooksWithNoSource.length > 0) {
<app-notice class="warn-source-books-missing" type="warning" icon="warning">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -484,10 +484,12 @@ describe('DraftGenerationStepsComponent', () => {
expect(component.stepper.selectedIndex).toBe(2);
component.onSourceTrainingBookSelect([2], config.trainingSources[0]);
fixture.detectChanges();
expect(fixture.nativeElement.querySelector('.warn-translated-books-unselected')).not.toBeNull();
expect(fixture.nativeElement.querySelector('.error-translated-books-unselected')).not.toBeNull();
component.tryAdvanceStep();
fixture.detectChanges();
expect(component.stepper.selectedIndex).toBe(3);
// The user cannot advance if reference books are not provided for training
expect(component.stepper.selectedIndex).toBe(2);
expect(fixture.nativeElement.querySelector('.error-choose-training-books')).toBeNull();
});

it('clears selected reference books when translated book is unselected', () => {
Expand Down

0 comments on commit a5e77ed

Please sign in to comment.