diff --git a/neode-ui/src/views/__tests__/login.test.ts b/neode-ui/src/views/__tests__/login.test.ts index 678a4823..0ac17d99 100644 --- a/neode-ui/src/views/__tests__/login.test.ts +++ b/neode-ui/src/views/__tests__/login.test.ts @@ -1,5 +1,5 @@ import { describe, it, expect, vi, beforeEach } from 'vitest' -import { shallowMount } from '@vue/test-utils' +import { shallowMount, flushPromises } from '@vue/test-utils' import { createPinia, setActivePinia } from 'pinia' import { createI18n } from 'vue-i18n' import { defineComponent, h } from 'vue' @@ -89,6 +89,12 @@ describe('Login View', () => { setActivePinia(createPinia()) vi.clearAllMocks() pushMock.mockResolvedValue(undefined) + // Mock health check so Login renders the form (not "Starting server...") + mockedRpc.call.mockImplementation(async (opts: any) => { + if (opts.method === 'server.echo') return { message: 'pong' } + if (opts.method === 'auth.isSetup') return { isSetup: true } + return null + }) }) function mountLogin() { @@ -108,19 +114,22 @@ describe('Login View', () => { expect(wrapper.exists()).toBe(true) }) - it('contains a password input', () => { + it('contains a password input', async () => { const wrapper = mountLogin() + await flushPromises() const input = wrapper.find('input[type="password"]') expect(input.exists()).toBe(true) }) - it('shows title text', () => { + it('shows title text', async () => { const wrapper = mountLogin() + await flushPromises() expect(wrapper.text()).toContain('Welcome Back') }) - it('has a login button', () => { + it('has a login button', async () => { const wrapper = mountLogin() + await flushPromises() const buttons = wrapper.findAll('button') const loginBtn = buttons.find(b => b.text().includes('Login') || b.text().includes('Create')) expect(loginBtn).toBeDefined()