mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-28 22:42:11 +01:00
feat(tests): update test command to include tuiAutoExit and add unit tests for SearchItemToRemitDialogComponent
This commit is contained in:
@@ -2,7 +2,10 @@
|
||||
"permissions": {
|
||||
"allow": [
|
||||
"mcp__context7__resolve-library-id",
|
||||
"mcp__context7__get-library-docs"
|
||||
"mcp__context7__get-library-docs",
|
||||
"Bash(npx nx test:*)",
|
||||
"Bash(npm test)",
|
||||
"Bash(npm run test:*)"
|
||||
],
|
||||
"deny": []
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ export class ReturnProcessItemComponent {
|
||||
} catch (error) {
|
||||
this.#logger.error(
|
||||
'Failed to validate return process',
|
||||
error,
|
||||
error as Error,
|
||||
() => ({
|
||||
returnProcessId: returnProcess.id,
|
||||
}),
|
||||
|
||||
@@ -162,7 +162,7 @@ export class ReturnProcessComponent {
|
||||
} catch (error) {
|
||||
this.#logger.error(
|
||||
'Failed to check canReturn for process',
|
||||
error,
|
||||
error as Error,
|
||||
() => ({
|
||||
processId: returnProcess.processId,
|
||||
}),
|
||||
|
||||
@@ -118,7 +118,7 @@ export class ReturnSummaryComponent {
|
||||
relativeTo: this.#activatedRoute,
|
||||
});
|
||||
} catch (error) {
|
||||
this.#logger.error('Error completing return process', error, () => ({
|
||||
this.#logger.error('Error completing return process', error as Error, () => ({
|
||||
function: 'returnItemsAndPrintRecipt',
|
||||
}));
|
||||
this.returnItemsAndPrintReciptStatus.set('error');
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { SearchItemToRemitDialogComponent } from './search-item-to-remit-dialog.component';
|
||||
import { DialogRef, DIALOG_DATA } from '@angular/cdk/dialog';
|
||||
import { DialogComponent } from '@isa/ui/dialog';
|
||||
|
||||
describe('SearchItemToRemitDialogComponent', () => {
|
||||
let component: SearchItemToRemitDialogComponent;
|
||||
let fixture: ComponentFixture<SearchItemToRemitDialogComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
const mockDialogRef = {
|
||||
updateSize: jest.fn(),
|
||||
close: jest.fn(),
|
||||
};
|
||||
|
||||
const mockData = { searchTerm: 'test' };
|
||||
|
||||
const mockDialogComponent = {
|
||||
// Mock DialogComponent properties if needed
|
||||
};
|
||||
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [SearchItemToRemitDialogComponent],
|
||||
providers: [
|
||||
{ provide: DialogRef, useValue: mockDialogRef },
|
||||
{ provide: DIALOG_DATA, useValue: mockData },
|
||||
{ provide: DialogComponent, useValue: mockDialogComponent },
|
||||
],
|
||||
}).compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(SearchItemToRemitDialogComponent);
|
||||
component = fixture.componentInstance;
|
||||
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -186,7 +186,7 @@ export class ScannerService {
|
||||
}
|
||||
|
||||
this.#status.set(ScannerStatus.Error);
|
||||
this.#logger.error('Failed to configure Scandit', error);
|
||||
this.#logger.error('Failed to configure Scandit', error as Error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -232,7 +232,7 @@ export class ScannerService {
|
||||
sub.add(componentRef.instance.scan.subscribe(handleScan));
|
||||
options?.abortSignal?.addEventListener('abort', handleAbort);
|
||||
} catch (error) {
|
||||
this.#logger.error('Failed to scan', error);
|
||||
this.#logger.error('Failed to scan', error as Error);
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -2,6 +2,7 @@ import { createComponentFactory, Spectator } from '@ngneat/spectator/jest';
|
||||
import { ConfirmationDialogComponent, ConfirmationDialogData, ConfirmationDialogResult } from './confirmation-dialog.component';
|
||||
import { DialogRef, DIALOG_DATA } from '@angular/cdk/dialog';
|
||||
import { ButtonComponent } from '@isa/ui/buttons';
|
||||
import { DialogComponent } from '../dialog.component';
|
||||
|
||||
describe('ConfirmationDialogComponent', () => {
|
||||
let spectator: Spectator<ConfirmationDialogComponent>;
|
||||
@@ -21,6 +22,10 @@ describe('ConfirmationDialogComponent', () => {
|
||||
{
|
||||
provide: DIALOG_DATA,
|
||||
useValue: mockData
|
||||
},
|
||||
{
|
||||
provide: DialogComponent,
|
||||
useValue: {}
|
||||
}
|
||||
],
|
||||
});
|
||||
@@ -89,7 +94,8 @@ describe('ConfirmationDialogComponent with custom text', () => {
|
||||
imports: [ButtonComponent],
|
||||
providers: [
|
||||
{ provide: DialogRef, useValue: { close: jest.fn() } },
|
||||
{ provide: DIALOG_DATA, useValue: customData }
|
||||
{ provide: DIALOG_DATA, useValue: customData },
|
||||
{ provide: DialogComponent, useValue: {} }
|
||||
],
|
||||
});
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import { createComponentFactory, Spectator } from '@ngneat/spectator/jest';
|
||||
import { DialogContentDirective } from './dialog-content.directive';
|
||||
import { DialogRef, DIALOG_DATA } from '@angular/cdk/dialog';
|
||||
import { Component } from '@angular/core';
|
||||
import { DialogComponent } from './dialog.component';
|
||||
|
||||
// Create a concrete component that extends the abstract directive for testing
|
||||
@Component({
|
||||
@@ -19,7 +20,8 @@ describe('DialogContentDirective', () => {
|
||||
component: TestDialogContentComponent,
|
||||
providers: [
|
||||
{ provide: DialogRef, useValue: mockDialogRef },
|
||||
{ provide: DIALOG_DATA, useValue: mockData }
|
||||
{ provide: DIALOG_DATA, useValue: mockData },
|
||||
{ provide: DialogComponent, useValue: {} }
|
||||
],
|
||||
});
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ describe('Dialog Injects', () => {
|
||||
|
||||
// Act
|
||||
const openDialog = TestBed.runInInjectionContext(() =>
|
||||
injectDialog(componentType, title)
|
||||
injectDialog(componentType, { title })
|
||||
);
|
||||
|
||||
// Assert
|
||||
@@ -61,7 +61,7 @@ describe('Dialog Injects', () => {
|
||||
|
||||
// Act
|
||||
const openDialog = TestBed.runInInjectionContext(() =>
|
||||
injectDialog(componentType, title)
|
||||
injectDialog(componentType, { title })
|
||||
);
|
||||
const result = openDialog({ data });
|
||||
|
||||
@@ -70,7 +70,7 @@ describe('Dialog Injects', () => {
|
||||
DialogComponent,
|
||||
expect.objectContaining({
|
||||
data,
|
||||
width: '30rem',
|
||||
minWidth: '30rem',
|
||||
hasBackdrop: true,
|
||||
disableClose: true,
|
||||
})
|
||||
@@ -87,7 +87,7 @@ describe('Dialog Injects', () => {
|
||||
|
||||
// Act
|
||||
const openDialog = TestBed.runInInjectionContext(() =>
|
||||
injectDialog(componentType, defaultTitle)
|
||||
injectDialog(componentType, { title: defaultTitle })
|
||||
);
|
||||
openDialog({ title: overrideTitle, data });
|
||||
|
||||
@@ -105,7 +105,7 @@ describe('Dialog Injects', () => {
|
||||
|
||||
// Act
|
||||
const openDialog = TestBed.runInInjectionContext(() =>
|
||||
injectDialog(componentType, defaultTitle)
|
||||
injectDialog(componentType, { title: defaultTitle })
|
||||
);
|
||||
openDialog({ data });
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import { createComponentFactory, Spectator } from '@ngneat/spectator/jest';
|
||||
import { MessageDialogComponent, MessageDialogData } from './message-dialog.component';
|
||||
import { DialogRef, DIALOG_DATA } from '@angular/cdk/dialog';
|
||||
import { ButtonComponent } from '@isa/ui/buttons';
|
||||
import { DialogComponent } from '../dialog.component';
|
||||
|
||||
// Test suite for default behavior
|
||||
describe('MessageDialogComponent', () => {
|
||||
@@ -22,6 +23,10 @@ describe('MessageDialogComponent', () => {
|
||||
{
|
||||
provide: DIALOG_DATA,
|
||||
useValue: mockData
|
||||
},
|
||||
{
|
||||
provide: DialogComponent,
|
||||
useValue: {}
|
||||
}
|
||||
],
|
||||
});
|
||||
@@ -73,7 +78,8 @@ describe('MessageDialogComponent with custom text', () => {
|
||||
imports: [ButtonComponent],
|
||||
providers: [
|
||||
{ provide: DialogRef, useValue: { close: jest.fn() } },
|
||||
{ provide: DIALOG_DATA, useValue: customData }
|
||||
{ provide: DIALOG_DATA, useValue: customData },
|
||||
{ provide: DialogComponent, useValue: {} }
|
||||
],
|
||||
});
|
||||
|
||||
|
||||
6032
package-lock.json
generated
6032
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -5,7 +5,7 @@
|
||||
"ng": "ng",
|
||||
"start": "nx serve isa-app --ssl",
|
||||
"pretest": "npx trash-cli testresults",
|
||||
"test": "npx nx run-many -t test --exclude isa-app",
|
||||
"test": "npx nx run-many --tuiAutoExit true -t test --exclude isa-app",
|
||||
"ci": "npx nx run-many -t test --exclude isa-app -c ci",
|
||||
"build": "nx build isa-app --configuration=development",
|
||||
"build-prod": "nx build isa-app --configuration=production",
|
||||
|
||||
Reference in New Issue
Block a user