Skip to content

Commit f628349

Browse files
committed
Tests: mount LoginView before store access
Mount the component before setting returnUrl and wait a tick for updates. This prevents inject() warnings and keeps the alert assertion stable.
1 parent 1db0c0d commit f628349

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

frontend/tests/views/LoginView.spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { describe, test, expect, beforeEach, vi } from 'vitest'
22
import { shallowMount, mount } from '@vue/test-utils'
3+
import { nextTick } from 'vue'
34
import LoginView from '@/views/LoginView.vue'
45
import { init_plugins } from '../lib/common'
56
import { useAuthStore } from '@/stores/auth'
@@ -112,11 +113,12 @@ describe('LoginView.vue', () => {
112113
// Check not redirected on clusters list but stayed on login page.
113114
expect(router.push).toHaveBeenCalledTimes(0)
114115
})
115-
test('should display info alert when redirected to login page', () => {
116+
test('should display info alert when redirected to login page', async () => {
117+
const wrapper = mount(LoginView, {})
116118
const authStore = useAuthStore()
117119
// Set returnUrl to simulate redirect from another page
118120
authStore.returnUrl = '/clusters/foo/dashboard'
119-
const wrapper = mount(LoginView, {})
121+
await nextTick()
120122
// Check InfoAlert component is present
121123
const infoAlert = wrapper.getComponent(InfoAlert)
122124
// Check the message content

0 commit comments

Comments
 (0)