[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.
This commit is contained in:
bymyself
2025-10-25 12:50:32 -07:00
parent 718655ae65
commit b2a82a5729
2 changed files with 31 additions and 0 deletions

View File

@@ -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) => {

View File

@@ -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