feat(ai-admin-console): complete implementation and resolve lint compilation errors

This commit is contained in:
2026-05-21 21:42:25 +07:00
parent 1580ab2c18
commit 91e9c714df
39 changed files with 3724 additions and 72 deletions
@@ -1,6 +1,8 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { render, screen, waitFor } from '@testing-library/react';
import type { ReactElement } from 'react';
import { CorrespondenceForm } from './form';
import { createTestQueryClient } from '@/lib/test-utils';
import {
useProjects,
useOrganizations,
@@ -94,6 +96,11 @@ const editInitialData = {
correspondenceNumber: 'CORR-001',
};
const renderWithQueryClient = (ui: ReactElement) => {
const { wrapper } = createTestQueryClient();
return render(ui, { wrapper });
};
describe('CorrespondenceForm (edit regression)', () => {
beforeEach(() => {
vi.clearAllMocks();
@@ -140,7 +147,7 @@ describe('CorrespondenceForm (edit regression)', () => {
});
it('keeps edit prefilled values after mount (no reset on initial render)', async () => {
render(<CorrespondenceForm initialData={editInitialData} uuid="corr-uuid-1" />);
renderWithQueryClient(<CorrespondenceForm initialData={editInitialData} uuid="corr-uuid-1" />);
expect(screen.getByLabelText('Subject *')).toHaveValue('Existing Subject');
@@ -156,7 +163,7 @@ describe('CorrespondenceForm (edit regression)', () => {
});
it('keeps dependent fields intact after async effects (reset guard)', async () => {
render(<CorrespondenceForm initialData={editInitialData} uuid="corr-uuid-2" />);
renderWithQueryClient(<CorrespondenceForm initialData={editInitialData} uuid="corr-uuid-2" />);
expect(screen.getByLabelText('Subject *')).toHaveValue('Existing Subject');
expect(screen.getByText('Current Document Number')).toBeInTheDocument();