mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-13 01:06:18 +00:00
*PR Created by the Glary-Bot Agent* --- ## Summary - Eliminates the confusing dual-helpers structure where `browser_tests/helpers/` and `browser_tests/fixtures/helpers/` coexisted one tier apart with overlapping purposes - Routes each file to its natural home based on what it actually *is*: page objects → `components/`, standalone utils → `utils/`, domain helper classes stay in `helpers/` - Adds an ESLint guard (`no-restricted-imports`) to prevent re-creating `browser_tests/helpers/` ## File Moves | File | From | To | Reason | |---|---|---|---| | `actionbar.ts` | `helpers/` | `fixtures/components/Actionbar.ts` | Page object class imported by ComfyPage | | `templates.ts` | `helpers/` | `fixtures/components/Templates.ts` | Page object class imported by ComfyPage | | `boundsUtils.ts` | `fixtures/helpers/` | `fixtures/utils/` | Pure function, not a helper class | | `mimeTypeUtil.ts` | `fixtures/helpers/` | `fixtures/utils/` | Pure function, not a helper class | | `builderTestUtils.ts` | `helpers/` | `fixtures/utils/` | Shared test setup functions | | `clipboardSpy.ts` | `helpers/` | `fixtures/utils/` | Page injection utility | | `fitToView.ts` | `helpers/` | `fixtures/utils/` | Canvas utility function | | `manageGroupNode.ts` | `helpers/` | `fixtures/utils/` | Litegraph interaction helper | | `painter.ts` | `helpers/` | `fixtures/utils/` | Test helper functions | | `perfReporter.ts` | `helpers/` | `fixtures/utils/` | Test infrastructure | | `promotedWidgets.ts` | `helpers/` | `fixtures/utils/` | Query helpers for specs | ## What Changed Beyond File Moves - **28 import statements** updated across test specs, fixtures, and infra files - **AGENTS.md** — directory tree diagram and architectural separation descriptions updated - **README.md** — "Leverage Existing Fixtures and Helpers" section updated - **`.claude/skills/perf-fix-with-proof/SKILL.md`** — perfReporter path reference updated - **`eslint.config.ts`** — added `@e2e/helpers/*` restricted import pattern to both spec and non-spec browser_tests rules ## Verification - `pnpm typecheck` — clean - `pnpm typecheck:browser` — clean - `pnpm lint` — 0 errors, 0 warnings - `pnpm format:check` — all files formatted - `pnpm knip` — clean - Pre-commit hooks passed full pipeline (oxfmt, oxlint, eslint, typecheck, typecheck:browser) ## Config Audit No changes needed to: `tsconfig.json` (`@e2e/*` alias covers all subdirs), `playwright.config.ts`, `vite.config.mts`, `knip.config.ts`, `.oxlintrc.json`, `nx.json` ## Manual Verification Note This is a pure structural refactoring (file moves + import updates) with zero behavioral or visual changes. The typecheck and lint passes confirm all imports resolve correctly. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-11411-refactor-consolidate-browser_tests-helpers-into-fixtures-3476d73d3650816cb671ef7fa8433f66) by [Unito](https://www.unito.io) --------- Co-authored-by: glary-bot <glary-bot@comfy.org> Co-authored-by: Glary-Bot <glary-bot@users.noreply.github.com> Co-authored-by: DrJKL <DrJKL0424@gmail.com> Co-authored-by: Amp <amp@ampcode.com>
125 lines
3.8 KiB
TypeScript
125 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/fixtures/utils/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()
|
|
await appMode.saveAs.fillAndSave(workflowName, viewType)
|
|
await comfyExpect(appMode.saveAs.successMessage).toBeVisible()
|
|
}
|
|
|
|
/**
|
|
* 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()
|
|
}
|