mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-05 05:32:02 +00:00
refactor: extract assetPath as standalone pure function (#10651)
## Summary Extract `assetPath` from a `ComfyPage` method to a standalone pure function, removing unnecessary coupling to the page object. ## Changes - **What**: Moved `assetPath` to `browser_tests/fixtures/utils/paths.ts`. `DragDropHelper` and `WorkflowHelper` import it directly instead of receiving it via `ComfyPage`. `ComfyPage.assetPath` kept as thin delegate for backward compat. ## Review Focus Structural-only refactor — no behavioral changes. The function was already pure (no `this`/`page` usage). ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-10651-refactor-extract-assetPath-as-standalone-pure-function-3316d73d365081c0b0e0ce6dde57ef8e) by [Unito](https://www.unito.io)
This commit is contained in:
@@ -7,6 +7,7 @@ import type {
|
||||
} from '../../../src/platform/workflow/validation/schemas/workflowSchema'
|
||||
import type { WorkspaceStore } from '../../types/globals'
|
||||
import type { ComfyPage } from '../ComfyPage'
|
||||
import { assetPath } from '../utils/paths'
|
||||
|
||||
type FolderStructure = {
|
||||
[key: string]: FolderStructure | string
|
||||
@@ -20,7 +21,7 @@ export class WorkflowHelper {
|
||||
|
||||
for (const [key, value] of Object.entries(structure)) {
|
||||
if (typeof value === 'string') {
|
||||
const filePath = this.comfyPage.assetPath(value)
|
||||
const filePath = assetPath(value)
|
||||
result[key] = readFileSync(filePath, 'utf-8')
|
||||
} else {
|
||||
result[key] = this.convertLeafToContent(value)
|
||||
@@ -59,7 +60,7 @@ export class WorkflowHelper {
|
||||
|
||||
async loadWorkflow(workflowName: string) {
|
||||
await this.comfyPage.workflowUploadInput.setInputFiles(
|
||||
this.comfyPage.assetPath(`${workflowName}.json`)
|
||||
assetPath(`${workflowName}.json`)
|
||||
)
|
||||
await this.comfyPage.nextFrame()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user