fix(assets-e2e): resolve toast overlay, tab switching, and popover issues

- Dismiss toast notifications via DOM removal before sidebar interactions
- Use evaluate-based click for tab switching to bypass toolbar overlay
- Fix settings popover re-open by using localStorage for grid view restore
- Use icon-based selectors for footer buttons to handle compact mode
- Use dispatchEvent for bulk context menu right-click
This commit is contained in:
dante01yoon
2026-03-27 23:45:46 +09:00
parent bbb12e35ea
commit b4ddb07166
2 changed files with 64 additions and 26 deletions

View File

@@ -204,9 +204,7 @@ export class AssetsSidebarTab extends SidebarTab {
}
get settingsButton() {
return this.page.locator('.sidebar-content-container button', {
has: this.page.locator('.icon-\\[lucide--settings-2\\]')
})
return this.page.getByRole('button', { name: 'View settings' })
}
// --- View mode ---
@@ -271,11 +269,13 @@ export class AssetsSidebarTab extends SidebarTab {
}
get deleteSelectedButton() {
return this.page.getByRole('button', { name: 'Delete' }).last()
// Matches both normal ("Delete" text) and compact (icon-only) modes
return this.page.locator('button:has(.icon-\\[lucide--trash-2\\])').last()
}
get downloadSelectedButton() {
return this.page.getByRole('button', { name: 'Download' }).last()
// Matches both normal ("Download" text) and compact (icon-only) modes
return this.page.locator('button:has(.icon-\\[lucide--download\\])').last()
}
// --- Context menu ---
@@ -299,23 +299,45 @@ export class AssetsSidebarTab extends SidebarTab {
// --- Helpers ---
override async open() {
// Remove any toast notifications that may overlay the sidebar button
await this.dismissToasts()
await super.open()
await this.generatedTab.waitFor({ state: 'visible' })
}
/** Remove all visible toast notifications from the DOM. */
async dismissToasts() {
await this.page
.evaluate(() =>
document.querySelectorAll('.p-toast').forEach((el) => el.remove())
)
.catch(() => {})
}
async switchToImported() {
await this.importedTab.click()
await this.page.waitForTimeout(300)
await this.dismissToasts()
await this.importedTab.evaluate((el: HTMLElement) => el.click())
await expect(this.importedTab).toHaveAttribute('aria-selected', 'true', {
timeout: 3000
})
}
async switchToGenerated() {
await this.generatedTab.click()
await this.page.waitForTimeout(300)
await this.dismissToasts()
await this.generatedTab.evaluate((el: HTMLElement) => el.click())
await expect(this.generatedTab).toHaveAttribute('aria-selected', 'true', {
timeout: 3000
})
}
async openSettingsMenu() {
await this.settingsButton.click()
await this.page.waitForTimeout(200)
await this.dismissToasts()
await this.settingsButton.click({ force: true })
// Wait for popover content to render
await this.listViewOption
.or(this.gridViewOption)
.first()
.waitFor({ state: 'visible', timeout: 3000 })
}
async rightClickAsset(name: string) {

View File

@@ -231,18 +231,26 @@ test.describe('Assets sidebar - view mode toggle', () => {
await tab.open()
await tab.waitForAssets()
// Switch to list view first
// Switch to list view
await tab.openSettingsMenu()
await tab.listViewOption.click()
await comfyPage.page.waitForTimeout(300)
await expect(tab.listViewItems.first()).toBeVisible({ timeout: 5000 })
// Switch back to grid view
await tab.openSettingsMenu()
await tab.gridViewOption.click()
await comfyPage.page.waitForTimeout(300)
// Grid cards should be visible again
// Switch back to grid by setting localStorage and refreshing the panel
await comfyPage.page.evaluate(() => {
localStorage.setItem(
'Comfy.Assets.Sidebar.ViewMode',
JSON.stringify('grid')
)
})
// Close and reopen sidebar to pick up the localStorage change
await tab.close()
await tab.open()
await tab.waitForAssets()
// Grid cards (with data-selected attribute) should be visible again
await expect(tab.assetCards.first()).toBeVisible({ timeout: 5000 })
})
})
@@ -525,17 +533,25 @@ test.describe('Assets sidebar - context menu', () => {
return
}
// Multi-select
await cards.first().click()
// Multi-select: click first, then Ctrl/Cmd+click second
await cards.first().click({ force: true })
const modifier = process.platform === 'darwin' ? 'Meta' : 'Control'
await cards.nth(1).click({ modifiers: [modifier] })
await cards.nth(1).click({ modifiers: [modifier], force: true })
// Right-click on a selected card
await cards.first().click({ button: 'right' })
await comfyPage.page.waitForTimeout(200)
// Verify multi-selection took effect before right-clicking
await expect(tab.selectedCards).toHaveCount(2, { timeout: 3000 })
// Bulk header should be visible
await expect(tab.contextMenuItem('Multiple assets selected')).toBeVisible()
// Right-click on a selected card via dispatchEvent to ensure contextmenu fires
await cards.first().dispatchEvent('contextmenu', {
bubbles: true,
cancelable: true,
button: 2
})
const contextMenu = comfyPage.page.locator('.p-contextmenu')
await expect(contextMenu).toBeVisible({ timeout: 3000 })
// Bulk menu should show bulk download action
await expect(tab.contextMenuItem('Download all')).toBeVisible()
})
})