diff --git a/frontend/src/app/features/training-and-qualifications/add-edit-training/select-training-category/select-training-category.component.spec.ts b/frontend/src/app/features/training-and-qualifications/add-edit-training/select-training-category/select-training-category.component.spec.ts index d008190e28..3e83e8a2d4 100644 --- a/frontend/src/app/features/training-and-qualifications/add-edit-training/select-training-category/select-training-category.component.spec.ts +++ b/frontend/src/app/features/training-and-qualifications/add-edit-training/select-training-category/select-training-category.component.spec.ts @@ -121,14 +121,14 @@ describe('SelectTrainingCategoryComponent', () => { expect(cancelLink).toBeTruthy(); }); - it('should show an accordian with the correct categories in', async () => { + it('should show an accordion with the correct categories in', async () => { const { component, getByTestId } = await setup(true); expect(component.categories).toEqual([ { id: 1, seq: 10, category: 'Activity provision/Well-being', trainingCategoryGroup: 'Care skills and knowledge' }, { id: 2, seq: 20, category: 'Autism', trainingCategoryGroup: 'Specific conditions and disabilities' }, { id: 37, seq: 1, category: 'Other', trainingCategoryGroup: null }, ]); - expect(getByTestId('accordian')).toBeTruthy(); + expect(getByTestId('groupedAccordion')).toBeTruthy(); }); it('should call the training service and navigate to the details page', async () => { diff --git a/frontend/src/app/features/training-and-qualifications/add-multiple-training/select-training-category-multiple/select-training-category-multiple.component.spec.ts b/frontend/src/app/features/training-and-qualifications/add-multiple-training/select-training-category-multiple/select-training-category-multiple.component.spec.ts index 3e1be784fa..10d86daaa3 100644 --- a/frontend/src/app/features/training-and-qualifications/add-multiple-training/select-training-category-multiple/select-training-category-multiple.component.spec.ts +++ b/frontend/src/app/features/training-and-qualifications/add-multiple-training/select-training-category-multiple/select-training-category-multiple.component.spec.ts @@ -137,14 +137,14 @@ describe('SelectTrainingCategoryMultipleComponent', () => { expect(routerSpy).toHaveBeenCalledWith(['/dashboard'], { fragment: 'training-and-qualifications' }); }); - it('should show an accordian with the correct categories in', async () => { + it('should show an accordion with the correct categories in', async () => { const { component, getByTestId } = await setup(true); expect(component.categories).toEqual([ { id: 1, seq: 10, category: 'Activity provision/Well-being', trainingCategoryGroup: 'Care skills and knowledge' }, { id: 2, seq: 20, category: 'Autism', trainingCategoryGroup: 'Specific conditions and disabilities' }, { id: 37, seq: 1, category: 'Other', trainingCategoryGroup: null }, ]); - expect(getByTestId('accordian')).toBeTruthy(); + expect(getByTestId('groupedAccordion')).toBeTruthy(); }); it('should return to the select staff page if there is no selected staff', async () => { diff --git a/frontend/src/app/features/workers/main-job-role/main-job-role.component.html b/frontend/src/app/features/workers/main-job-role/main-job-role.component.html index c8f2797ea4..7d48ddd06c 100644 --- a/frontend/src/app/features/workers/main-job-role/main-job-role.component.html +++ b/frontend/src/app/features/workers/main-job-role/main-job-role.component.html @@ -14,7 +14,9 @@

{{ worker ? 'Update' : 'Select' }} their mai [accordions]="jobGroups" textShowHideAll="job roles" [preFilledId]="preFilledId" - data-testid="accordian" + data-testid="groupedAccordion" + [hasError]="submitted && form.invalid" + [errorMessage]="formErrorsMap[0].type[0].message" > diff --git a/frontend/src/app/features/workers/main-job-role/main-job-role.component.spec.ts b/frontend/src/app/features/workers/main-job-role/main-job-role.component.spec.ts index 1e873e3f2e..bcd0bb5c34 100644 --- a/frontend/src/app/features/workers/main-job-role/main-job-role.component.spec.ts +++ b/frontend/src/app/features/workers/main-job-role/main-job-role.component.spec.ts @@ -32,71 +32,74 @@ describe('MainJobRoleComponent', () => { } else { path = 'staff-record-summary'; } - const { fixture, getByText, getByTestId, getByLabelText, queryByTestId } = await render(MainJobRoleComponent, { - imports: [SharedModule, RouterModule, RouterTestingModule, HttpClientTestingModule, ReactiveFormsModule], - declarations: [ProgressBarComponent], - schemas: [NO_ERRORS_SCHEMA], - providers: [ - UntypedFormBuilder, - AlertService, - WindowRef, - { - provide: PermissionsService, - useFactory: MockPermissionsService.factory(), - deps: [HttpClient, Router, UserService], - }, - { - provide: UserService, - useFactory: MockUserService.factory(0, Roles.Admin), - deps: [HttpClient], - }, - { - provide: WorkerService, - useClass: MockWorkerServiceWithUpdateWorker, - }, - { - provide: ActivatedRoute, - useValue: { - parent: { + const { fixture, getByText, getAllByText, getByTestId, getByLabelText, queryByTestId } = await render( + MainJobRoleComponent, + { + imports: [SharedModule, RouterModule, RouterTestingModule, HttpClientTestingModule, ReactiveFormsModule], + declarations: [ProgressBarComponent], + schemas: [NO_ERRORS_SCHEMA], + providers: [ + UntypedFormBuilder, + AlertService, + WindowRef, + { + provide: PermissionsService, + useFactory: MockPermissionsService.factory(), + deps: [HttpClient, Router, UserService], + }, + { + provide: UserService, + useFactory: MockUserService.factory(0, Roles.Admin), + deps: [HttpClient], + }, + { + provide: WorkerService, + useClass: MockWorkerServiceWithUpdateWorker, + }, + { + provide: ActivatedRoute, + useValue: { + parent: { + snapshot: { + url: [{ path }], + data: { + establishment: { uid: 'mocked-uid' }, + primaryWorkplace: {}, + }, + }, + }, snapshot: { - url: [{ path }], + params: {}, data: { - establishment: { uid: 'mocked-uid' }, - primaryWorkplace: {}, + jobs: [ + { + id: 4, + jobRoleGroup: 'Professional and related roles', + title: 'Allied health professional (not occupational therapist)', + }, + { + id: 10, + jobRoleGroup: 'Care providing roles', + title: 'Care worker', + }, + { + id: 23, + title: 'Registered nurse', + jobRoleGroup: 'Professional and related roles', + }, + { + id: 27, + title: 'Social worker', + jobRoleGroup: 'Professional and related roles', + }, + ], }, }, }, - snapshot: { - params: {}, - data: { - jobs: [ - { - id: 4, - jobRoleGroup: 'Professional and related roles', - title: 'Allied health professional (not occupational therapist)', - }, - { - id: 10, - jobRoleGroup: 'Care providing roles', - title: 'Care worker', - }, - { - id: 23, - title: 'Registered nurse', - jobRoleGroup: 'Professional and related roles', - }, - { - id: 27, - title: 'Social worker', - jobRoleGroup: 'Professional and related roles', - }, - ], - }, - }, }, - }, - ], - }); + ], + }, + ); const component = fixture.componentInstance; const injector = getTestBed(); @@ -128,6 +131,7 @@ describe('MainJobRoleComponent', () => { fixture, getByTestId, getByText, + getAllByText, getByLabelText, router, routerSpy, @@ -176,7 +180,7 @@ describe('MainJobRoleComponent', () => { it('should show the accordion', async () => { const { getByTestId } = await setup(false, true); - expect(getByTestId('accordian')).toBeTruthy(); + expect(getByTestId('groupedAccordion')).toBeTruthy(); }); it('should show the accordion headings', async () => { @@ -295,13 +299,13 @@ describe('MainJobRoleComponent', () => { }); it('should return an error message if user clicked submit without selecting a job role', async () => { - const { fixture, getByText } = await setup(true, false, true); + const { fixture, getByText, getAllByText } = await setup(true, false, true); userEvent.click(getByText('Save this staff record')); fixture.detectChanges(); expect(getByText('There is a problem')).toBeTruthy(); - expect(getByText('Select the job role')).toBeTruthy(); + expect(getAllByText('Select the job role')).toHaveSize(2); }); }); diff --git a/frontend/src/app/features/workers/main-job-role/main-job-role.component.ts b/frontend/src/app/features/workers/main-job-role/main-job-role.component.ts index 8345f5fcfb..7c443f756f 100644 --- a/frontend/src/app/features/workers/main-job-role/main-job-role.component.ts +++ b/frontend/src/app/features/workers/main-job-role/main-job-role.component.ts @@ -7,7 +7,6 @@ import { BackLinkService } from '@core/services/backLink.service'; import { ErrorSummaryService } from '@core/services/error-summary.service'; import { NewWorkerMandatoryInfo, WorkerService } from '@core/services/worker.service'; import { EstablishmentService } from '@core/services/establishment.service'; -import { Contracts } from '@core/model/contracts.enum'; import { AlertService } from '@core/services/alert.service'; @Component({ diff --git a/frontend/src/app/shared/components/accordions/radio-button-accordion/grouped-radio-button-accordion/grouped-radio-button-accordion.component.html b/frontend/src/app/shared/components/accordions/radio-button-accordion/grouped-radio-button-accordion/grouped-radio-button-accordion.component.html index c0d02f2846..19695185de 100644 --- a/frontend/src/app/shared/components/accordions/radio-button-accordion/grouped-radio-button-accordion/grouped-radio-button-accordion.component.html +++ b/frontend/src/app/shared/components/accordions/radio-button-accordion/grouped-radio-button-accordion/grouped-radio-button-accordion.component.html @@ -10,7 +10,7 @@ -

+

Error: {{ errorMessage }}

diff --git a/frontend/src/app/shared/directives/select-training-category/select-training-category.component.html b/frontend/src/app/shared/directives/select-training-category/select-training-category.component.html index be174b35ad..672d6de479 100644 --- a/frontend/src/app/shared/directives/select-training-category/select-training-category.component.html +++ b/frontend/src/app/shared/directives/select-training-category/select-training-category.component.html @@ -14,7 +14,7 @@

{{ title }}

[accordions]="trainingGroups" textShowHideAll="categories" [preFilledId]="preFilledId" - data-testid="accordian" + data-testid="groupedAccordion" [hasError]="submitted && error" [errorMessage]="formErrorsMap[0].type[0].message" >