import { flushPromises, mount } from '@vue/test-utils' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import AccountTestModal from '../AccountTestModal.vue' const { getAvailableModels, copyToClipboard } = vi.hoisted(() => ({ getAvailableModels: vi.fn(), copyToClipboard: vi.fn() })) vi.mock('@/api/admin', () => ({ adminAPI: { accounts: { getAvailableModels } } })) vi.mock('@/composables/useClipboard', () => ({ useClipboard: () => ({ copyToClipboard }) })) vi.mock('vue-i18n', async () => { const actual = await vi.importActual('vue-i18n') const messages: Record = { 'admin.accounts.geminiImagePromptDefault': 'Generate a cute orange cat astronaut sticker on a clean pastel background.' } return { ...actual, useI18n: () => ({ t: (key: string, params?: Record) => { if (key === 'admin.accounts.geminiImageReceived' && params?.count) { return `received-${params.count}` } return messages[key] || key } }) } }) function createStreamResponse(lines: string[]) { const encoder = new TextEncoder() const chunks = lines.map((line) => encoder.encode(line)) let index = 0 return { ok: true, body: { getReader: () => ({ read: vi.fn().mockImplementation(async () => { if (index < chunks.length) { return { done: false, value: chunks[index++] } } return { done: true, value: undefined } }) }) } } as Response } function mountModal() { return mount(AccountTestModal, { props: { show: false, account: { id: 42, name: 'Gemini Image Test', platform: 'gemini', type: 'apikey', status: 'active' } } as any, global: { stubs: { BaseDialog: { template: '
' }, Select: { template: '
' }, TextArea: { props: ['modelValue'], emits: ['update:modelValue'], template: '