mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-03 14:54:37 +00:00
Adds Playwright tests for cloud environment with Firebase auth. Changes: - Refactor ComfyPage to abstract base class - Add LocalhostComfyPage (existing devtools implementation) - Add CloudComfyPage (cloud settings API, Firebase auth) - Add cloud fixture with auth state persistence - Add globalSetupCloud for Firebase login - Add playwright.cloud.config with 5x timeout - Add basic cloud tests (load app, canvas interaction, settings) - Update .gitignore for auth state files - Update tsconfig to include playwright.cloud.config Architecture: - ComfyPage abstract with 3 backend-specific methods - LocalhostComfyPage uses /api/devtools + multi-user - CloudComfyPage uses /api/settings + Firebase localStorage - No code duplication (95% shared) Setup: - Requires CLOUD_TEST_EMAIL and CLOUD_TEST_PASSWORD env vars - globalSetup logs in once, saves auth to browser_tests/.auth/ - Tests reuse saved auth state (no login per test)
67 lines
1.9 KiB
TypeScript
67 lines
1.9 KiB
TypeScript
import { chromium } from '@playwright/test'
|
|
import type { FullConfig } from '@playwright/test'
|
|
import dotenv from 'dotenv'
|
|
import * as fs from 'fs'
|
|
import * as path from 'path'
|
|
|
|
dotenv.config()
|
|
|
|
/**
|
|
* Global setup for cloud tests.
|
|
* Authenticates with Firebase and saves auth state for test reuse.
|
|
*/
|
|
export default async function globalSetupCloud(config: FullConfig) {
|
|
const CLOUD_TEST_EMAIL = process.env.CLOUD_TEST_EMAIL
|
|
const CLOUD_TEST_PASSWORD = process.env.CLOUD_TEST_PASSWORD
|
|
|
|
if (!CLOUD_TEST_EMAIL || !CLOUD_TEST_PASSWORD) {
|
|
throw new Error(
|
|
'CLOUD_TEST_EMAIL and CLOUD_TEST_PASSWORD must be set in environment variables'
|
|
)
|
|
}
|
|
|
|
const browser = await chromium.launch()
|
|
const context = await browser.newContext()
|
|
const page = await context.newPage()
|
|
|
|
try {
|
|
// Navigate to cloud login page
|
|
await page.goto('https://stagingcloud.comfy.org/cloud/login', {
|
|
waitUntil: 'networkidle',
|
|
timeout: 30000
|
|
})
|
|
|
|
// Fill in email and password
|
|
await page.fill('input[type="email"]', CLOUD_TEST_EMAIL)
|
|
await page.fill('input[type="password"]', CLOUD_TEST_PASSWORD)
|
|
|
|
// Click login button
|
|
await page.click('button[type="submit"]')
|
|
|
|
// Wait for redirect to main app (adjust selector as needed)
|
|
await page.waitForURL('**/', { timeout: 30000 })
|
|
|
|
// Wait for app to be fully loaded
|
|
await page.waitForFunction(
|
|
() => window['app'] && window['app'].extensionManager,
|
|
{ timeout: 30000 }
|
|
)
|
|
|
|
// Ensure .auth directory exists
|
|
const authDir = path.join(__dirname, '.auth')
|
|
if (!fs.existsSync(authDir)) {
|
|
fs.mkdirSync(authDir, { recursive: true })
|
|
}
|
|
|
|
// Save authentication state (includes localStorage with Firebase tokens)
|
|
await context.storageState({
|
|
path: 'browser_tests/.auth/cloudUser.json'
|
|
})
|
|
} catch (error) {
|
|
console.error('❌ Failed to authenticate:', error)
|
|
throw error
|
|
} finally {
|
|
await browser.close()
|
|
}
|
|
}
|