251223:1649 On going update to 1.7.0: Refoctory drawing Module & document number Module
Some checks failed
Spec Validation / validate-markdown (push) Has been cancelled
Spec Validation / validate-diagrams (push) Has been cancelled
Spec Validation / check-todos (push) Has been cancelled

This commit is contained in:
admin
2025-12-23 16:49:16 +07:00
parent 0d6432ab83
commit 7db6a003db
81 changed files with 4703 additions and 1449 deletions

View File

@@ -114,21 +114,25 @@ describe('use-correspondence hooks', () => {
const mockResponse = { id: 1, title: 'New Correspondence' };
vi.mocked(correspondenceService.create).mockResolvedValue(mockResponse);
const { wrapper, queryClient } = createTestQueryClient();
const { wrapper } = createTestQueryClient();
const { result } = renderHook(() => useCreateCorrespondence(), { wrapper });
await act(async () => {
await result.current.mutateAsync({
title: 'New Correspondence',
subject: 'New Correspondence',
projectId: 1,
correspondenceTypeId: 1,
typeId: 1,
originatorId: 1,
recipients: []
});
});
expect(correspondenceService.create).toHaveBeenCalledWith({
title: 'New Correspondence',
subject: 'New Correspondence',
projectId: 1,
correspondenceTypeId: 1,
typeId: 1,
originatorId: 1,
recipients: []
});
expect(toast.success).toHaveBeenCalledWith('Correspondence created successfully');
});
@@ -146,9 +150,11 @@ describe('use-correspondence hooks', () => {
await act(async () => {
try {
await result.current.mutateAsync({
title: '',
subject: '',
projectId: 1,
correspondenceTypeId: 1,
typeId: 1,
originatorId: 1,
recipients: []
});
} catch {
// Expected to throw
@@ -163,7 +169,7 @@ describe('use-correspondence hooks', () => {
describe('useUpdateCorrespondence', () => {
it('should update correspondence and invalidate cache', async () => {
const mockResponse = { id: 1, title: 'Updated Correspondence' };
const mockResponse = { id: 1, subject: 'Updated Correspondence' };
vi.mocked(correspondenceService.update).mockResolvedValue(mockResponse);
const { wrapper } = createTestQueryClient();
@@ -172,12 +178,12 @@ describe('use-correspondence hooks', () => {
await act(async () => {
await result.current.mutateAsync({
id: 1,
data: { title: 'Updated Correspondence' },
data: { subject: 'Updated Correspondence' },
});
});
expect(correspondenceService.update).toHaveBeenCalledWith(1, {
title: 'Updated Correspondence',
subject: 'Updated Correspondence',
});
expect(toast.success).toHaveBeenCalledWith('Correspondence updated successfully');
});
@@ -210,11 +216,11 @@ describe('use-correspondence hooks', () => {
await act(async () => {
await result.current.mutateAsync({
id: 1,
data: { recipientIds: [2, 3] },
data: { note: 'Ready for review' },
});
});
expect(correspondenceService.submit).toHaveBeenCalledWith(1, { recipientIds: [2, 3] });
expect(correspondenceService.submit).toHaveBeenCalledWith(1, { note: 'Ready for review' });
expect(toast.success).toHaveBeenCalledWith('Correspondence submitted successfully');
});
});
@@ -230,13 +236,13 @@ describe('use-correspondence hooks', () => {
await act(async () => {
await result.current.mutateAsync({
id: 1,
data: { action: 'approve', comment: 'LGTM' },
data: { action: 'APPROVE', comments: 'LGTM' },
});
});
expect(correspondenceService.processWorkflow).toHaveBeenCalledWith(1, {
action: 'approve',
comment: 'LGTM',
action: 'APPROVE',
comments: 'LGTM',
});
expect(toast.success).toHaveBeenCalledWith('Action completed successfully');
});
@@ -255,7 +261,7 @@ describe('use-correspondence hooks', () => {
try {
await result.current.mutateAsync({
id: 1,
data: { action: 'approve' },
data: { action: 'APPROVE' },
});
} catch {
// Expected to throw

View File

@@ -110,6 +110,8 @@ describe('use-rfa hooks', () => {
await result.current.mutateAsync({
projectId: 1,
subject: 'Test RFA',
rfaTypeId: 1,
toOrganizationId: 1
});
});
@@ -132,6 +134,8 @@ describe('use-rfa hooks', () => {
await result.current.mutateAsync({
projectId: 1,
subject: '',
rfaTypeId: 1,
toOrganizationId: 1
});
} catch {
// Expected
@@ -175,13 +179,13 @@ describe('use-rfa hooks', () => {
await act(async () => {
await result.current.mutateAsync({
id: 1,
data: { action: 'approve', comment: 'Approved' },
data: { action: 'APPROVE', comments: 'Approved' },
});
});
expect(rfaService.processWorkflow).toHaveBeenCalledWith(1, {
action: 'approve',
comment: 'Approved',
action: 'APPROVE',
comments: 'Approved',
});
expect(toast.success).toHaveBeenCalledWith('Workflow status updated successfully');
});
@@ -200,7 +204,7 @@ describe('use-rfa hooks', () => {
try {
await result.current.mutateAsync({
id: 1,
data: { action: 'reject' },
data: { action: 'REJECT' },
});
} catch {
// Expected