From b7da501182cbc558a5641546545528bd3a77dba8 Mon Sep 17 00:00:00 2001 From: Dorian Date: Sun, 29 Mar 2026 21:04:44 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20login=20tests=20=E2=80=94=20mock=20healt?= =?UTF-8?q?h=20check=20for=20server=20startup=20progress?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Login.vue now shows "Starting server..." until health check passes. Tests need to mock server.echo and auth.isSetup RPCs and flush promises before asserting on the rendered form. 522 tests pass. Co-Authored-By: Claude Opus 4.6 (1M context) --- neode-ui/src/views/__tests__/login.test.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) 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()