import { mount } from '@vue/test-utils' import { beforeEach, describe, expect, it, vi } from 'vitest' import TotpLoginModal from '@/components/auth/TotpLoginModal.vue' const { showErrorMock } = vi.hoisted(() => ({ showErrorMock: vi.fn(), })) vi.mock('vue-i18n', () => ({ useI18n: () => ({ t: (key: string) => key, }), })) vi.mock('@/stores', () => ({ useAppStore: () => ({ showError: (...args: any[]) => showErrorMock(...args), }), })) describe('TotpLoginModal', () => { beforeEach(() => { showErrorMock.mockReset() }) it('sends verification errors to toast and does not render inline red text', async () => { const wrapper = mount(TotpLoginModal, { props: { tempToken: 'temp-token', userEmailMasked: 'u***@example.com', }, }) ;(wrapper.vm as unknown as { setError: (message: string) => void }).setError('Invalid code') await wrapper.vm.$nextTick() expect(showErrorMock).toHaveBeenCalledWith('Invalid code') expect(wrapper.text()).not.toContain('Invalid code') expect(wrapper.find('.bg-red-50').exists()).toBe(false) }) })