test(frontend): add comprehensive test coverage for Phase 3
CI / CD Pipeline / build (push) Successful in 5m38s
CI / CD Pipeline / deploy (push) Failing after 11m12s

- Add AI component tests (ContextConfigEditor, PromptEditor, RuntimeParametersPanel, SandboxTabs, VersionHistory)
- Add layout component tests (GlobalSearch, NotificationsDropdown, ProjectSwitcher, Sidebar, UserMenu)
- Update vitest.setup.ts for better test configuration
- Update .gitignore to exclude test artifacts
- All 722 tests passing
This commit is contained in:
2026-06-14 20:53:13 +07:00
parent 9833ce23ce
commit 1d246353a8
13 changed files with 654 additions and 1 deletions
@@ -0,0 +1,44 @@
// File: frontend/components/admin/ai/__tests__/prompt-editor.test.tsx
// Change Log:
// - 2026-06-14: สร้างใหม่สำหรับ Phase 3 Coverage
import { render, screen } from '@testing-library/react';
import { describe, it, expect, vi } from 'vitest';
import PromptEditor from '../PromptEditor';
describe('PromptEditor', () => {
const mockOnSave = vi.fn();
beforeEach(() => {
vi.clearAllMocks();
});
it('ควร render editor สำหรับแก้ไขพรอมต์เทมเพลต', () => {
render(
<PromptEditor
promptType="ocr_extraction"
initialTemplate="Test template with {{ocr_text}}"
onSave={mockOnSave}
isSaving={false}
/>
);
expect(screen.getByText(/แก้ไขพรอมต์เทมเพลต/)).toBeInTheDocument();
});
it('ควร disabled ปุ่มบันทึกเมื่อ isSaving=true', () => {
render(
<PromptEditor
promptType="ocr_extraction"
initialTemplate="Test template with {{ocr_text}}"
onSave={mockOnSave}
isSaving={true}
/>
);
const saveButton = screen.queryByText('กำลังบันทึก...');
if (saveButton) {
expect(saveButton).toBeDisabled();
}
});
});