fix: bypass login in QA recordings with localStorage pre-seeding

The QA recordings were stuck on the user selection screen because CI
has no existing users. Fix by pre-seeding localStorage with userId,
userName, and TutorialCompleted before navigation, plus creating a
qa-ci user via API as a fallback.
This commit is contained in:
snomiao
2026-03-21 01:07:28 +00:00
parent 641aee03c0
commit 441263dc64
2 changed files with 56 additions and 29 deletions

View File

@@ -154,6 +154,22 @@ jobs:
done
echo "::error::Server timeout (main)"; exit 1
- name: Pre-seed settings (main)
if: needs.resolve-matrix.outputs.mode == 'focused'
shell: bash
run: |
# Create qa-ci user via API so login screen is bypassed
curl -sf -X POST http://127.0.0.1:8188/api/users \
-H 'Content-Type: application/json' \
-d '{"username":"qa-ci"}' || echo "User creation failed (may already exist)"
# Pre-seed settings to skip tutorial/template gallery
curl -sf -X POST http://127.0.0.1:8188/api/devtools/set_settings \
-H 'Content-Type: application/json' \
-d '{"Comfy.TutorialCompleted":true}' || \
curl -sf -X POST http://127.0.0.1:8188/api/settings \
-H 'Content-Type: application/json' \
-d '{"Comfy.TutorialCompleted":true}' || echo "Settings pre-seed skipped"
- name: Run BEFORE QA (main branch)
if: needs.resolve-matrix.outputs.mode == 'focused'
shell: bash
@@ -193,6 +209,19 @@ jobs:
done
echo "::error::Server timeout (PR)"; exit 1
- name: Pre-seed settings (PR)
shell: bash
run: |
curl -sf -X POST http://127.0.0.1:8188/api/users \
-H 'Content-Type: application/json' \
-d '{"username":"qa-ci"}' || echo "User creation failed (may already exist)"
curl -sf -X POST http://127.0.0.1:8188/api/devtools/set_settings \
-H 'Content-Type: application/json' \
-d '{"Comfy.TutorialCompleted":true}' || \
curl -sf -X POST http://127.0.0.1:8188/api/settings \
-H 'Content-Type: application/json' \
-d '{"Comfy.TutorialCompleted":true}' || echo "Settings pre-seed skipped"
- name: Run AFTER QA (PR branch)
shell: bash
env:

View File

@@ -315,46 +315,44 @@ async function executeSteps(
// ── Login flow ──
async function loginAsQaCi(page: Page) {
async function loginAsQaCi(page: Page, serverUrl: string) {
console.warn('Logging in as qa-ci...')
// Check if user selection screen is present
const dropdown = page
.locator('select, [role="combobox"], .p-select, .p-dropdown')
.first()
// Pre-seed localStorage to bypass login and template gallery
await page.evaluate(() => {
localStorage.setItem('Comfy.userId', 'qa-ci')
localStorage.setItem('Comfy.userName', 'qa-ci')
localStorage.setItem('Comfy.TutorialCompleted', 'true')
})
if (await dropdown.isVisible({ timeout: 5000 }).catch(() => false)) {
await dropdown.click()
await sleep(500)
// Reload so the router guard picks up the seeded user
await page.goto(serverUrl, {
waitUntil: 'domcontentloaded',
timeout: 30000
})
await sleep(3000)
try {
await page.locator('text=qa-ci').first().click({ timeout: 3000 })
} catch {
try {
await dropdown.selectOption({ label: 'qa-ci' })
} catch {
console.warn(
'Could not select qa-ci user, continuing without selection'
)
}
// If still on user-select (e.g. multi-user server with strict auth),
// create a new user via the text input
if (page.url().includes('user-select')) {
console.warn('Still on user-select, creating new user...')
const newUserInput = page
.locator('input[placeholder*="user"], input[type="text"]')
.first()
if (await newUserInput.isVisible().catch(() => false)) {
await newUserInput.fill('qa-ci')
await sleep(300)
}
await sleep(300)
// Close dropdown overlay if still open (blocks Next button)
await page.keyboard.press('Escape')
await sleep(300)
// Click Next button
const nextBtn = page.getByRole('button', { name: 'Next' })
if (await nextBtn.isVisible().catch(() => false)) {
await nextBtn.click({ timeout: 5000 })
await sleep(5000)
await sleep(3000)
}
}
// Close template gallery
// Close template gallery if it appeared
await page.keyboard.press('Escape')
await sleep(2000)
await sleep(1000)
// Dismiss error popup if present
const dismissBtn = page.locator('text=Dismiss').first()
@@ -395,7 +393,7 @@ async function main() {
})
await sleep(2000)
await loginAsQaCi(page)
await loginAsQaCi(page, opts.serverUrl)
console.warn('Editor ready — executing test steps')
await executeSteps(page, steps, opts.outputDir)