mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-19 22:09:37 +00:00
## Summary Complete the @e2e/ path alias migration started in #10735 by converting all 354 remaining relative imports and adding a lint rule to prevent backsliding. ## Changes - **What**: Migrate all relative imports in browser_tests/ to use `@e2e/` (intra-directory) and `@/` (src/ imports) path aliases. Add `no-restricted-imports` ESLint rule banning `./` and `../` imports in `browser_tests/**/*.ts`. Suppress pre-existing oxlint `no-eval` and `no-console` warnings exposed by touching those files. ## Review Focus - ESLint flat-config merging: the `@playwright/test` ban and relative-import ban are in two separate blocks to avoid last-match-wins collision with the `useI18n`/`useVirtualList` blocks higher in the config. - The `['./**', '../**']` glob patterns (not `['./*', '../*']`) are needed to catch multi-level relative paths like `../../../src/foo`. Follows up on #10735 ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-10958-test-migrate-browser_tests-to-e2e-path-alias-and-add-lint-rule-33c6d73d365081649d1be771eac986fd) by [Unito](https://www.unito.io) Co-authored-by: Amp <amp@ampcode.com>
262 lines
8.4 KiB
TypeScript
262 lines
8.4 KiB
TypeScript
import { expect } from '@playwright/test'
|
|
|
|
import { comfyPageFixture as test } from '@e2e/fixtures/ComfyPage'
|
|
|
|
test.beforeEach(async ({ comfyPage }) => {
|
|
await comfyPage.settings.setSetting('Comfy.UseNewMenu', 'Disabled')
|
|
})
|
|
|
|
test.describe('Background Image Upload', () => {
|
|
test.beforeEach(async ({ comfyPage }) => {
|
|
// Reset the background image setting before each test
|
|
await comfyPage.settings.setSetting('Comfy.Canvas.BackgroundImage', '')
|
|
})
|
|
|
|
test.afterEach(async ({ comfyPage }) => {
|
|
// Clean up background image setting after each test
|
|
await comfyPage.settings.setSetting('Comfy.Canvas.BackgroundImage', '')
|
|
})
|
|
|
|
test('should show background image upload component in settings', async ({
|
|
comfyPage
|
|
}) => {
|
|
// Open settings dialog
|
|
await comfyPage.page.keyboard.press('Control+,')
|
|
|
|
// Navigate to Appearance category
|
|
const appearanceOption = comfyPage.page.locator('text=Appearance')
|
|
await appearanceOption.click()
|
|
|
|
// Find the background image setting
|
|
const backgroundImageSetting = comfyPage.page.locator(
|
|
'#Comfy\\.Canvas\\.BackgroundImage'
|
|
)
|
|
await expect(backgroundImageSetting).toBeVisible()
|
|
|
|
// Verify the component has the expected elements using semantic selectors
|
|
const urlInput = backgroundImageSetting.getByRole('textbox')
|
|
await expect(urlInput).toBeVisible()
|
|
await expect(urlInput).toHaveAttribute('placeholder')
|
|
|
|
const uploadButton = backgroundImageSetting.getByRole('button', {
|
|
name: /upload/i
|
|
})
|
|
await expect(uploadButton).toBeVisible()
|
|
|
|
const clearButton = backgroundImageSetting.getByRole('button', {
|
|
name: /clear/i
|
|
})
|
|
await expect(clearButton).toBeVisible()
|
|
await expect(clearButton).toBeDisabled() // Should be disabled when no image
|
|
})
|
|
|
|
test('should upload image file and set as background', async ({
|
|
comfyPage
|
|
}) => {
|
|
// Open settings dialog
|
|
await comfyPage.page.keyboard.press('Control+,')
|
|
|
|
// Navigate to Appearance category
|
|
const appearanceOption = comfyPage.page.locator('text=Appearance')
|
|
await appearanceOption.click()
|
|
|
|
// Find the background image setting
|
|
const backgroundImageSetting = comfyPage.page.locator(
|
|
'#Comfy\\.Canvas\\.BackgroundImage'
|
|
)
|
|
// Click the upload button to trigger file input
|
|
const uploadButton = backgroundImageSetting.getByRole('button', {
|
|
name: /upload/i
|
|
})
|
|
|
|
// Set up file upload handler
|
|
const fileChooserPromise = comfyPage.page.waitForEvent('filechooser')
|
|
await uploadButton.click()
|
|
const fileChooser = await fileChooserPromise
|
|
|
|
// Upload the test image
|
|
await fileChooser.setFiles(comfyPage.assetPath('image32x32.webp'))
|
|
|
|
// Verify the URL input now has an API URL
|
|
const urlInput = backgroundImageSetting.getByRole('textbox')
|
|
await expect(urlInput).toHaveValue(/^\/api\/view\?.*subfolder=backgrounds/)
|
|
|
|
// Verify clear button is now enabled
|
|
const clearButton = backgroundImageSetting.getByRole('button', {
|
|
name: /clear/i
|
|
})
|
|
await expect(clearButton).toBeEnabled()
|
|
|
|
// Verify the setting value was actually set
|
|
const settingValue = await comfyPage.settings.getSetting(
|
|
'Comfy.Canvas.BackgroundImage'
|
|
)
|
|
expect(settingValue).toMatch(/^\/api\/view\?.*subfolder=backgrounds/)
|
|
})
|
|
|
|
test('should accept URL input for background image', async ({
|
|
comfyPage
|
|
}) => {
|
|
const testImageUrl = 'https://example.com/test-image.png'
|
|
|
|
// Open settings dialog
|
|
await comfyPage.page.keyboard.press('Control+,')
|
|
|
|
// Navigate to Appearance category
|
|
const appearanceOption = comfyPage.page.locator('text=Appearance')
|
|
await appearanceOption.click()
|
|
|
|
// Find the background image setting
|
|
const backgroundImageSetting = comfyPage.page.locator(
|
|
'#Comfy\\.Canvas\\.BackgroundImage'
|
|
)
|
|
// Enter URL in the input field
|
|
const urlInput = backgroundImageSetting.getByRole('textbox')
|
|
await urlInput.fill(testImageUrl)
|
|
|
|
// Trigger blur event to ensure the value is set
|
|
await urlInput.blur()
|
|
|
|
// Verify clear button is now enabled
|
|
const clearButton = backgroundImageSetting.getByRole('button', {
|
|
name: /clear/i
|
|
})
|
|
await expect(clearButton).toBeEnabled()
|
|
|
|
// Verify the setting value was updated
|
|
const settingValue = await comfyPage.settings.getSetting(
|
|
'Comfy.Canvas.BackgroundImage'
|
|
)
|
|
expect(settingValue).toBe(testImageUrl)
|
|
})
|
|
|
|
test('should clear background image when clear button is clicked', async ({
|
|
comfyPage
|
|
}) => {
|
|
const testImageUrl = 'https://example.com/test-image.png'
|
|
|
|
// First set a background image
|
|
await comfyPage.settings.setSetting(
|
|
'Comfy.Canvas.BackgroundImage',
|
|
testImageUrl
|
|
)
|
|
|
|
// Open settings dialog
|
|
await comfyPage.page.keyboard.press('Control+,')
|
|
|
|
// Navigate to Appearance category
|
|
const appearanceOption = comfyPage.page.locator('text=Appearance')
|
|
await appearanceOption.click()
|
|
|
|
// Find the background image setting
|
|
const backgroundImageSetting = comfyPage.page.locator(
|
|
'#Comfy\\.Canvas\\.BackgroundImage'
|
|
)
|
|
// Verify the input has the test URL
|
|
const urlInput = backgroundImageSetting.getByRole('textbox')
|
|
await expect(urlInput).toHaveValue(testImageUrl)
|
|
|
|
// Verify clear button is enabled
|
|
const clearButton = backgroundImageSetting.getByRole('button', {
|
|
name: /clear/i
|
|
})
|
|
await expect(clearButton).toBeEnabled()
|
|
|
|
// Click the clear button
|
|
await clearButton.click()
|
|
|
|
// Verify the input is now empty
|
|
await expect(urlInput).toHaveValue('')
|
|
|
|
// Verify clear button is now disabled
|
|
await expect(clearButton).toBeDisabled()
|
|
|
|
// Verify the setting value was cleared
|
|
const settingValue = await comfyPage.settings.getSetting(
|
|
'Comfy.Canvas.BackgroundImage'
|
|
)
|
|
expect(settingValue).toBe('')
|
|
})
|
|
|
|
test('should show tooltip on upload and clear buttons', async ({
|
|
comfyPage
|
|
}) => {
|
|
// Open settings dialog
|
|
await comfyPage.page.keyboard.press('Control+,')
|
|
|
|
// Navigate to Appearance category
|
|
const appearanceOption = comfyPage.page.locator('text=Appearance')
|
|
await appearanceOption.click()
|
|
|
|
// Find the background image setting
|
|
const backgroundImageSetting = comfyPage.page.locator(
|
|
'#Comfy\\.Canvas\\.BackgroundImage'
|
|
)
|
|
// Hover over upload button and verify tooltip appears
|
|
const uploadButton = backgroundImageSetting.getByRole('button', {
|
|
name: /upload/i
|
|
})
|
|
await uploadButton.hover()
|
|
|
|
const uploadTooltip = comfyPage.page.locator('.p-tooltip:visible')
|
|
await expect(uploadTooltip).toBeVisible()
|
|
|
|
// Move away to hide tooltip
|
|
await comfyPage.page.locator('body').hover()
|
|
|
|
// Set a background to enable clear button
|
|
const urlInput = backgroundImageSetting.getByRole('textbox')
|
|
await urlInput.fill('https://example.com/test.png')
|
|
await urlInput.blur()
|
|
|
|
// Hover over clear button and verify tooltip appears
|
|
const clearButton = backgroundImageSetting.getByRole('button', {
|
|
name: /clear/i
|
|
})
|
|
await clearButton.hover()
|
|
|
|
const clearTooltip = comfyPage.page.locator('.p-tooltip:visible')
|
|
await expect(clearTooltip).toBeVisible()
|
|
})
|
|
|
|
test('should maintain reactive updates between URL input and clear button state', async ({
|
|
comfyPage
|
|
}) => {
|
|
// Open settings dialog
|
|
await comfyPage.page.keyboard.press('Control+,')
|
|
|
|
// Navigate to Appearance category
|
|
const appearanceOption = comfyPage.page.locator('text=Appearance')
|
|
await appearanceOption.click()
|
|
|
|
// Find the background image setting
|
|
const backgroundImageSetting = comfyPage.page.locator(
|
|
'#Comfy\\.Canvas\\.BackgroundImage'
|
|
)
|
|
const urlInput = backgroundImageSetting.getByRole('textbox')
|
|
const clearButton = backgroundImageSetting.getByRole('button', {
|
|
name: /clear/i
|
|
})
|
|
|
|
// Initially clear button should be disabled
|
|
await expect(clearButton).toBeDisabled()
|
|
|
|
// Type some text - clear button should become enabled
|
|
await urlInput.fill('test')
|
|
await expect(clearButton).toBeEnabled()
|
|
|
|
// Clear the text manually - clear button should become disabled again
|
|
await urlInput.fill('')
|
|
await expect(clearButton).toBeDisabled()
|
|
|
|
// Add text again - clear button should become enabled
|
|
await urlInput.fill('https://example.com/image.png')
|
|
await expect(clearButton).toBeEnabled()
|
|
|
|
// Use clear button - should clear input and disable itself
|
|
await clearButton.click()
|
|
await expect(urlInput).toHaveValue('')
|
|
await expect(clearButton).toBeDisabled()
|
|
})
|
|
})
|