mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-19 22:09:37 +00:00
## Summary Address code review feedback from #10134 by renaming the component and improving implementation quality. ## Changes - Rename `ResultGallery` → `MediaLightbox` across all references - Replace `useEventListener(window, 'keydown')` with `@keydown` on dialog element - Remove change detector tests (`renders close button`, `prevents default on arrow keys`) - Remove redundant `toBeVisible()` before Playwright click (implicit wait) - Update keyboard tests to dispatch on dialog element instead of `window` - Sort button icon sizes (`icon-sm`, `icon`, `icon-lg`) - Wire zoom event to lightbox in `MediaAssetCard` story via `context.args` - Add standalone `MediaLightbox` Storybook story under `Platform/Assets/` Fixes #10134 ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-10235-refactor-Rename-ResultGallery-to-MediaLightbox-and-address-code-review-3276d73d365081299b42f682373a12f1) by [Unito](https://www.unito.io) --------- Co-authored-by: Alexander Brown <drjkl@comfy.org> Co-authored-by: Amp <amp@ampcode.com>
71 lines
2.3 KiB
TypeScript
71 lines
2.3 KiB
TypeScript
import { expect } from '@playwright/test'
|
|
|
|
import type { ComfyPage } from '../fixtures/ComfyPage'
|
|
import { comfyPageFixture as test } from '../fixtures/ComfyPage'
|
|
|
|
test.describe('MediaLightbox', { tag: ['@slow'] }, () => {
|
|
test.beforeEach(async ({ comfyPage }) => {
|
|
await comfyPage.settings.setSetting('Comfy.UseNewMenu', 'Top')
|
|
await comfyPage.settings.setSetting('Comfy.VueNodes.Enabled', true)
|
|
await comfyPage.setup()
|
|
})
|
|
|
|
async function runAndOpenGallery(comfyPage: ComfyPage) {
|
|
await comfyPage.workflow.loadWorkflow(
|
|
'widgets/save_image_and_animated_webp'
|
|
)
|
|
await comfyPage.vueNodes.waitForNodes()
|
|
await comfyPage.runButton.click()
|
|
|
|
// Wait for SaveImage node to produce output
|
|
const saveImageNode = comfyPage.vueNodes.getNodeByTitle('Save Image')
|
|
await expect(saveImageNode.locator('.image-preview img')).toBeVisible({
|
|
timeout: 30_000
|
|
})
|
|
|
|
// Open Assets sidebar tab and wait for it to load
|
|
await comfyPage.page.locator('.assets-tab-button').click()
|
|
await comfyPage.page
|
|
.locator('.sidebar-content-container')
|
|
.waitFor({ state: 'visible' })
|
|
|
|
// Wait for any asset card to appear (may contain img or video)
|
|
const assetCard = comfyPage.page
|
|
.locator('[role="button"]')
|
|
.filter({ has: comfyPage.page.locator('img, video') })
|
|
.first()
|
|
|
|
await expect(assetCard).toBeVisible({ timeout: 30_000 })
|
|
|
|
// Hover to reveal zoom button, then click it
|
|
await assetCard.hover()
|
|
await assetCard.getByLabel('Zoom in').click()
|
|
|
|
const gallery = comfyPage.page.getByRole('dialog')
|
|
await expect(gallery).toBeVisible()
|
|
|
|
return { gallery }
|
|
}
|
|
|
|
test('opens gallery and shows dialog with close button', async ({
|
|
comfyPage
|
|
}) => {
|
|
const { gallery } = await runAndOpenGallery(comfyPage)
|
|
await expect(gallery.getByLabel('Close')).toBeVisible()
|
|
})
|
|
|
|
test('closes gallery on Escape key', async ({ comfyPage }) => {
|
|
await runAndOpenGallery(comfyPage)
|
|
|
|
await comfyPage.page.keyboard.press('Escape')
|
|
await expect(comfyPage.page.getByRole('dialog')).not.toBeVisible()
|
|
})
|
|
|
|
test('closes gallery when clicking close button', async ({ comfyPage }) => {
|
|
const { gallery } = await runAndOpenGallery(comfyPage)
|
|
|
|
await gallery.getByLabel('Close').click()
|
|
await expect(comfyPage.page.getByRole('dialog')).not.toBeVisible()
|
|
})
|
|
})
|