Skip to content

Commit 2c9c293

Browse files
renemadsenclaude
andcommitted
fix(tests): add ToastrModule to dialog spec, mock getPayrollSettings in container spec
PayrollExportDialogComponent uses ToastrService (via ApiBaseService) which requires ToastConfig — add ToastrModule.forRoot() to test imports. TimePlanningsContainerComponent now calls settingsService.getPayrollSettings() on init to determine whether to show the payroll export button — add the mock method and a default return value to the existing test setup. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 9f8342f commit 2c9c293

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

eform-client/src/app/plugins/modules/time-planning-pn/components/plannings/time-planning-actions/payroll-export/payroll-export-dialog.component.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { NO_ERRORS_SCHEMA } from '@angular/core';
33
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
44
import { TranslateModule } from '@ngx-translate/core';
55
import { HttpClientTestingModule } from '@angular/common/http/testing';
6+
import { ToastrModule } from 'ngx-toastr';
67
import { PayrollExportDialogComponent } from './payroll-export-dialog.component';
78
import { TimePlanningPnPayrollExportService } from '../../../../services';
89
import { of } from 'rxjs';
@@ -31,7 +32,7 @@ describe('PayrollExportDialogComponent', () => {
3132

3233
await TestBed.configureTestingModule({
3334
declarations: [PayrollExportDialogComponent],
34-
imports: [TranslateModule.forRoot(), HttpClientTestingModule],
35+
imports: [TranslateModule.forRoot(), HttpClientTestingModule, ToastrModule.forRoot()],
3536
schemas: [NO_ERRORS_SCHEMA],
3637
providers: [
3738
{ provide: MAT_DIALOG_DATA, useValue: mockDialogData },
@@ -95,7 +96,7 @@ describe('PayrollExportDialogComponent', () => {
9596
TestBed.resetTestingModule();
9697
await TestBed.configureTestingModule({
9798
declarations: [PayrollExportDialogComponent],
98-
imports: [TranslateModule.forRoot(), HttpClientTestingModule],
99+
imports: [TranslateModule.forRoot(), HttpClientTestingModule, ToastrModule.forRoot()],
99100
schemas: [NO_ERRORS_SCHEMA],
100101
providers: [
101102
{ provide: MAT_DIALOG_DATA, useValue: { cutoffDay: 0, payrollSystem: 1 } },

eform-client/src/app/plugins/modules/time-planning-pn/components/plannings/time-plannings-container/time-plannings-container.component.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ describe('TimePlanningsContainerComponent', () => {
2828
getAssignedSite: jest.fn(),
2929
updateAssignedSite: jest.fn(),
3030
getAvailableTags: jest.fn(),
31+
getPayrollSettings: jest.fn(),
3132
} as any;
3233
mockDialog = {
3334
open: jest.fn(),
@@ -39,6 +40,7 @@ describe('TimePlanningsContainerComponent', () => {
3940
mockStore.select.mockReturnValue(of('en-US'));
4041
mockSettingsService.getAvailableSites.mockReturnValue(of({ success: true, model: [] }) as any);
4142
mockSettingsService.getAvailableTags.mockReturnValue(of({ success: true, model: [] }) as any);
43+
mockSettingsService.getPayrollSettings.mockReturnValue(of({ success: true, model: { payrollSystem: 0, cutoffDay: 19 } }) as any);
4244
mockPlanningsService.getPlannings.mockReturnValue(of({ success: true, model: [] }) as any);
4345

4446
await TestBed.configureTestingModule({

0 commit comments

Comments
 (0)