From afe77ec928a7d3d341b3d6ee750b37f2e9cfbc1b Mon Sep 17 00:00:00 2001 From: Glary-Bot Date: Mon, 20 Apr 2026 02:55:54 +0000 Subject: [PATCH] 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). --- src/components/TopMenuSection.test.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/components/TopMenuSection.test.ts b/src/components/TopMenuSection.test.ts index 4a943adc2f..7dfcedde2f 100644 --- a/src/components/TopMenuSection.test.ts +++ b/src/components/TopMenuSection.test.ts @@ -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 () => {