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>
127 lines
3.8 KiB
TypeScript
127 lines
3.8 KiB
TypeScript
import { expect } from '@playwright/test'
|
|
|
|
import type { ComfyPage } from '@e2e/fixtures/ComfyPage'
|
|
import type { AppModeHelper } from '@e2e/fixtures/helpers/AppModeHelper'
|
|
import type { NodeReference } from '@e2e/fixtures/utils/litegraphUtils'
|
|
|
|
import { comfyExpect } from '@e2e/fixtures/ComfyPage'
|
|
import { fitToViewInstant } from '@e2e/helpers/fitToView'
|
|
|
|
interface BuilderSetupResult {
|
|
inputNodeTitle: string
|
|
widgetNames: string[]
|
|
}
|
|
|
|
/**
|
|
* Enter builder on the default workflow and select I/O.
|
|
*
|
|
* Loads the default workflow, optionally transforms it (e.g. convert a node
|
|
* to subgraph), then enters builder mode and selects inputs + outputs.
|
|
*
|
|
* @param comfyPage - The page fixture.
|
|
* @param prepareGraph - Optional callback to transform the graph before
|
|
* entering builder. Receives the KSampler node ref and returns the
|
|
* input node title and widget names to select.
|
|
* Defaults to KSampler with its first widget.
|
|
* Mutually exclusive with widgetNames.
|
|
* @param widgetNames - Widget names to select from the KSampler node.
|
|
* Only used when prepareGraph is not provided.
|
|
* Mutually exclusive with prepareGraph.
|
|
*/
|
|
export async function setupBuilder(
|
|
comfyPage: ComfyPage,
|
|
prepareGraph?: (ksampler: NodeReference) => Promise<BuilderSetupResult>,
|
|
widgetNames?: string[]
|
|
): Promise<void> {
|
|
const { appMode } = comfyPage
|
|
await comfyPage.workflow.loadWorkflow('default')
|
|
|
|
const ksampler = await comfyPage.nodeOps.getNodeRefById('3')
|
|
|
|
const { inputNodeTitle, widgetNames: inputWidgets } = prepareGraph
|
|
? await prepareGraph(ksampler)
|
|
: { inputNodeTitle: 'KSampler', widgetNames: widgetNames ?? ['seed'] }
|
|
|
|
await fitToViewInstant(comfyPage)
|
|
await appMode.enterBuilder()
|
|
await appMode.steps.goToInputs()
|
|
|
|
for (const name of inputWidgets) {
|
|
await appMode.select.selectInputWidget(inputNodeTitle, name)
|
|
}
|
|
|
|
await appMode.steps.goToOutputs()
|
|
await appMode.select.selectOutputNode('Save Image')
|
|
}
|
|
|
|
/**
|
|
* Convert the KSampler to a subgraph, then enter builder with I/O selected.
|
|
*/
|
|
export async function setupSubgraphBuilder(
|
|
comfyPage: ComfyPage
|
|
): Promise<void> {
|
|
await setupBuilder(comfyPage, async (ksampler) => {
|
|
await ksampler.click('title')
|
|
await ksampler.convertToSubgraph()
|
|
await comfyPage.nextFrame()
|
|
|
|
return {
|
|
inputNodeTitle: 'New Subgraph',
|
|
widgetNames: ['seed']
|
|
}
|
|
})
|
|
}
|
|
|
|
/**
|
|
* Open the save-as dialog, fill name + view type, click save,
|
|
* and wait for the success dialog.
|
|
*/
|
|
export async function builderSaveAs(
|
|
appMode: AppModeHelper,
|
|
workflowName: string,
|
|
viewType: 'App' | 'Node graph' = 'App'
|
|
) {
|
|
await appMode.footer.saveAsButton.click()
|
|
await comfyExpect(appMode.saveAs.nameInput).toBeVisible({ timeout: 5000 })
|
|
await appMode.saveAs.fillAndSave(workflowName, viewType)
|
|
await comfyExpect(appMode.saveAs.successMessage).toBeVisible({
|
|
timeout: 5000
|
|
})
|
|
}
|
|
|
|
/**
|
|
* Load a different workflow, then reopen the named one from the sidebar.
|
|
* Caller must ensure the page is in graph mode (not builder or app mode)
|
|
* before calling.
|
|
*/
|
|
export async function openWorkflowFromSidebar(
|
|
comfyPage: ComfyPage,
|
|
name: string
|
|
) {
|
|
await comfyPage.workflow.loadWorkflow('default')
|
|
await comfyPage.nextFrame()
|
|
const { workflowsTab } = comfyPage.menu
|
|
await workflowsTab.open()
|
|
await workflowsTab.getPersistedItem(name).dblclick()
|
|
await comfyPage.nextFrame()
|
|
|
|
await expect
|
|
.poll(() => comfyPage.workflow.getActiveWorkflowPath())
|
|
.toContain(name)
|
|
}
|
|
|
|
/** Save the workflow, reopen it, and enter app mode. */
|
|
export async function saveAndReopenInAppMode(
|
|
comfyPage: ComfyPage,
|
|
workflowName: string
|
|
) {
|
|
await comfyPage.menu.topbar.saveWorkflow(workflowName)
|
|
|
|
const { workflowsTab } = comfyPage.menu
|
|
await workflowsTab.open()
|
|
await workflowsTab.getPersistedItem(workflowName).dblclick()
|
|
await comfyPage.nextFrame()
|
|
|
|
await comfyPage.appMode.toggleAppMode()
|
|
}
|