test: use polling pattern to wait for async terminal tab registration

Amp-Thread-ID: https://ampcode.com/threads/T-019c217a-e7e3-7209-a479-7f5e779fe7f9
This commit is contained in:
bymyself
2026-02-02 19:19:13 -08:00
parent 8245613641
commit a95f7f88c2

View File

@@ -147,9 +147,14 @@ test.describe('Bottom Panel Shortcuts', { tag: '@ui' }, () => {
test('should maintain panel state when switching to terminal', async ({
comfyPage
}) => {
const logsTab = comfyPage.page.getByRole('tab', { name: /Logs/i })
await logsTab.waitFor({ state: 'attached', timeout: 5000 })
// Terminal tabs load asynchronously via dynamic import - wait for registration
// Use expect().toPass() for auto-retry polling pattern
await expect(async () => {
const logsTab = comfyPage.page.getByRole('tab', { name: /Logs/i })
await expect(logsTab).toBeAttached()
}).toPass({ timeout: 10_000 })
// Open shortcuts panel
await comfyPage.page
.locator('button[aria-label*="Keyboard Shortcuts"]')
.click()
@@ -158,11 +163,15 @@ test.describe('Bottom Panel Shortcuts', { tag: '@ui' }, () => {
comfyPage.page.locator('[id*="tab_shortcuts-essentials"]')
).toBeVisible()
// Switch to terminal panel
await comfyPage.page
.locator('button[aria-label*="Toggle Bottom Panel"]')
.click()
await expect(logsTab).toBeVisible()
await expect(
comfyPage.page.getByRole('tab', { name: /Logs/i })
).toBeVisible()
// Switch back to shortcuts panel - should remember essentials was active
await comfyPage.page
.locator('button[aria-label*="Keyboard Shortcuts"]')
.click()