import { describe, it, expect } from 'vitest'; import { ModelTest } from '../../src/admin/views/model-test.js'; describe('ModelTest component', () => { it('should render a details section with test form elements', () => { const html = String(); expect(html).toContain(' { const html = String(); expect(html).toContain('onclick="runTest()"'); }); it('should have valid JavaScript in the inline script', () => { const html = String(); const scriptMatch = html.match(/]*>([\s\S]*?)<\/script>/); expect(scriptMatch).not.toBeNull(); const scriptContent = scriptMatch![1]; expect(() => { new Function(scriptContent); }).not.toThrow(); }); it('should have runTest and toggleRawResponse functions in the script', () => { const html = String(); const scriptMatch = html.match(/]*>([\s\S]*?)<\/script>/); const scriptContent = scriptMatch![1]; expect(scriptContent).toContain('window.runTest ='); expect(scriptContent).toContain('window.toggleRawResponse ='); }); it('should send apiKeyId when API key dropdown is selected', () => { const html = String(); const scriptMatch = html.match(/]*>([\s\S]*?)<\/script>/); const scriptContent = scriptMatch![1]; // Verify the script reads apiKeySource and handles both apiKey and apiKeyId expect(scriptContent).toContain('apiKeySource'); expect(scriptContent).toContain('apiKeyId'); expect(scriptContent).toContain("apiKeySource.value !== 'manual'"); }); it('should use a toggle link instead of nested details for raw response', () => { const html = String(); // Should NOT have nested details inside error section expect(html).not.toMatch(/