test: add cloud-mode auth fallback regression test

Make isCloud dynamic in test mock so cloud mode can be toggled per test.
Add test asserting CurrentUserButton is shown for logged-out cloud users
when workflow tabs are in the sidebar (covers showCurrentUser = isCloud || isLoggedIn).
This commit is contained in:
Glary-Bot
2026-04-20 02:55:54 +00:00
committed by Connor Byrne
parent dc9eda326a
commit afe77ec928

View File

@@ -24,6 +24,7 @@ import { useSidebarTabStore } from '@/stores/workspace/sidebarTabStore'
const mockData = vi.hoisted(() => ({
isLoggedIn: false,
isDesktop: false,
isCloud: false,
setShowConflictRedDot: (_value: boolean) => {}
}))
@@ -36,7 +37,9 @@ vi.mock('@/composables/auth/useCurrentUser', () => ({
}))
vi.mock('@/platform/distribution/types', () => ({
isCloud: false,
get isCloud() {
return mockData.isCloud
},
isNightly: false,
get isDesktop() {
return mockData.isDesktop
@@ -193,6 +196,7 @@ describe('TopMenuSection', () => {
localStorage.clear()
mockData.isDesktop = false
mockData.isLoggedIn = false
mockData.isCloud = false
mockData.setShowConflictRedDot(false)
})
@@ -220,6 +224,14 @@ describe('TopMenuSection', () => {
expect(container.querySelector('login-button-stub')).not.toBeNull()
expect(container.querySelector('current-user-button-stub')).toBeNull()
})
it('should display CurrentUserButton when user is logged out on cloud', () => {
mockData.isLoggedIn = false
mockData.isCloud = true
const { container } = createSidebarTabsWrapper()
expect(container.querySelector('current-user-button-stub')).not.toBeNull()
expect(container.querySelector('login-button-stub')).toBeNull()
})
})
it('shows the active jobs label with the current count', async () => {