From b2a82a572972b95a71405a71082723c1e594aca8 Mon Sep 17 00:00:00 2001 From: bymyself Date: Sat, 25 Oct 2025 12:50:32 -0700 Subject: [PATCH] [don't port to main] fix: Skip cloud auth guard and mock /api/features for Playwright tests Cloud builds (rh-test) have two initialization blockers for Playwright tests: 1. Firebase auth guard in router waits 16s for auth initialization - Tests timeout at 15s, causing all tests to fail - Fix: Skip entire auth guard when DISTRIBUTION !== 'cloud' - Safe because guard is 100% cloud-specific (Firebase, cloud login, etc.) 2. main.ts calls loadRemoteConfig() which fetches /api/features - Only triggered when isCloud=true, but still blocks if endpoint missing - Fix: Mock /api/features in ComfyPage setup, try real backend first Both issues only affect cloud builds. Playwright builds with DISTRIBUTION='localhost' so these fixes make tests pass while keeping cloud functionality intact. --- browser_tests/fixtures/ComfyPage.ts | 27 +++++++++++++++++++++++++++ src/router.ts | 4 ++++ 2 files changed, 31 insertions(+) diff --git a/browser_tests/fixtures/ComfyPage.ts b/browser_tests/fixtures/ComfyPage.ts index d46b31a98a..1c145a3080 100644 --- a/browser_tests/fixtures/ComfyPage.ts +++ b/browser_tests/fixtures/ComfyPage.ts @@ -285,6 +285,33 @@ export class ComfyPage { } = {}) { await this.goto() + // Mock remote config endpoint for cloud builds + // Cloud builds (rh-test) call /api/features on startup, which blocks initialization + // if the endpoint doesn't exist or times out. Try real backend first, fallback to empty config. + await this.page.route('**/api/features', async (route) => { + try { + // Try to get response from real backend + const response = await route.fetch() + if (response.ok()) { + await route.fulfill({ response }) + } else { + // Backend doesn't have endpoint, return empty config + await route.fulfill({ + status: 200, + contentType: 'application/json', + body: JSON.stringify({}) + }) + } + } catch { + // Network error, return empty config + await route.fulfill({ + status: 200, + contentType: 'application/json', + body: JSON.stringify({}) + }) + } + }) + // Mock release endpoint to prevent changelog popups if (mockReleases) { await this.page.route('**/releases**', async (route) => { diff --git a/src/router.ts b/src/router.ts index 0b94e4a175..dac8395d9a 100644 --- a/src/router.ts +++ b/src/router.ts @@ -5,6 +5,7 @@ import { } from 'vue-router' import type { RouteLocationNormalized } from 'vue-router' +import { isCloud } from '@/platform/distribution/types' import { useDialogService } from '@/services/dialogService' import { useFirebaseAuthStore } from '@/stores/firebaseAuthStore' import { useUserStore } from '@/stores/userStore' @@ -104,6 +105,9 @@ const router = createRouter({ // Global authentication guard router.beforeEach(async (to, _from, next) => { + // Skip cloud-specific auth guard for non-cloud builds (e.g., Playwright tests) + if (!isCloud) return next() + const authStore = useFirebaseAuthStore() // Wait for Firebase auth to initialize with timeout