diff --git a/.oxlintrc.json b/.oxlintrc.json index a0769d8f4..5dfa8ddf8 100644 --- a/.oxlintrc.json +++ b/.oxlintrc.json @@ -110,6 +110,12 @@ "rules": { "no-console": "allow" } + }, + { + "files": ["browser_tests/**/*.ts"], + "rules": { + "typescript/no-explicit-any": "error" + } } ] } diff --git a/browser_tests/fixtures/ComfyPage.ts b/browser_tests/fixtures/ComfyPage.ts index b817b14f8..e8a78fb98 100644 --- a/browser_tests/fixtures/ComfyPage.ts +++ b/browser_tests/fixtures/ComfyPage.ts @@ -260,7 +260,7 @@ export class ComfyPage { return await resp.json() } - async setupSettings(settings: Record) { + async setupSettings(settings: Record) { const resp = await this.request.post( `${this.url}/api/devtools/set_settings`, { diff --git a/browser_tests/fixtures/helpers/WorkflowHelper.ts b/browser_tests/fixtures/helpers/WorkflowHelper.ts index 7f08aeb94..a501cb5a2 100644 --- a/browser_tests/fixtures/helpers/WorkflowHelper.ts +++ b/browser_tests/fixtures/helpers/WorkflowHelper.ts @@ -1,5 +1,9 @@ import { readFileSync } from 'fs' +import type { + ComfyApiWorkflow, + ComfyWorkflowJSON +} from '../../../src/platform/workflow/validation/schemas/workflowSchema' import type { WorkspaceStore } from '../../types/globals' import type { ComfyPage } from '../ComfyPage' @@ -107,7 +111,13 @@ export class WorkflowHelper { }) } - async getExportedWorkflow(options?: { api?: boolean }): Promise { + async getExportedWorkflow(options: { api: true }): Promise + async getExportedWorkflow(options?: { + api?: false + }): Promise + async getExportedWorkflow(options?: { + api?: boolean + }): Promise { const api = options?.api ?? false return this.comfyPage.page.evaluate(async (api) => { return (await window.app!.graphToPrompt())[api ? 'output' : 'workflow'] diff --git a/browser_tests/fixtures/ws.ts b/browser_tests/fixtures/ws.ts index 92a5ef89a..02e68bdb7 100644 --- a/browser_tests/fixtures/ws.ts +++ b/browser_tests/fixtures/ws.ts @@ -1,7 +1,7 @@ import { test as base } from '@playwright/test' export const webSocketFixture = base.extend<{ - ws: { trigger(data: any, url?: string): Promise } + ws: { trigger(data: unknown, url?: string): Promise } }>({ ws: [ async ({ page }, use) => { diff --git a/browser_tests/tests/colorPalette.spec.ts b/browser_tests/tests/colorPalette.spec.ts index de8a4282b..5ec6453c0 100644 --- a/browser_tests/tests/colorPalette.spec.ts +++ b/browser_tests/tests/colorPalette.spec.ts @@ -178,8 +178,8 @@ test.describe('Color Palette', { tag: ['@screenshot', '@settings'] }, () => { }) test('Can add custom color palette', async ({ comfyPage }) => { - await comfyPage.page.evaluate((p) => { - ;( + await comfyPage.page.evaluate(async (p) => { + await ( window.app!.extensionManager as WorkspaceStore ).colorPalette.addCustomColorPalette(p) }, customColorPalettes.obsidian_dark) diff --git a/browser_tests/tests/sidebar/workflows.spec.ts b/browser_tests/tests/sidebar/workflows.spec.ts index bd56a1b50..1f409bb40 100644 --- a/browser_tests/tests/sidebar/workflows.spec.ts +++ b/browser_tests/tests/sidebar/workflows.spec.ts @@ -145,11 +145,11 @@ test.describe('Workflows sidebar', () => { }) expect(exportedWorkflow).toBeDefined() for (const node of exportedWorkflow.nodes) { - for (const slot of node.inputs) { + for (const slot of node.inputs ?? []) { expect(slot.localized_name).toBeUndefined() expect(slot.label).toBeUndefined() } - for (const slot of node.outputs) { + for (const slot of node.outputs ?? []) { expect(slot.localized_name).toBeUndefined() expect(slot.label).toBeUndefined() } diff --git a/browser_tests/tests/vueNodes/widgets/widgetReactivity.spec.ts b/browser_tests/tests/vueNodes/widgets/widgetReactivity.spec.ts index 95d608623..8a3548614 100644 --- a/browser_tests/tests/vueNodes/widgets/widgetReactivity.spec.ts +++ b/browser_tests/tests/vueNodes/widgets/widgetReactivity.spec.ts @@ -2,6 +2,7 @@ import { comfyExpect as expect, comfyPageFixture as test } from '../../../fixtures/ComfyPage' +import type { TestGraphAccess } from '../../../types/globals' test.describe('Vue Widget Reactivity', () => { test.beforeEach(async ({ comfyPage }) => { @@ -13,21 +14,21 @@ test.describe('Vue Widget Reactivity', () => { 'css=[data-testid="node-body-4"] > .lg-node-widgets > div' ) await comfyPage.page.evaluate(() => { - const graph = window.graph as { _nodes_by_id: Record } + const graph = window.graph as TestGraphAccess const node = graph._nodes_by_id['4'] - node.widgets.push(node.widgets[0]) + node.widgets!.push(node.widgets![0]) }) await expect(loadCheckpointNode).toHaveCount(2) await comfyPage.page.evaluate(() => { - const graph = window.graph as { _nodes_by_id: Record } + const graph = window.graph as TestGraphAccess const node = graph._nodes_by_id['4'] - node.widgets[2] = node.widgets[0] + node.widgets![2] = node.widgets![0] }) await expect(loadCheckpointNode).toHaveCount(3) await comfyPage.page.evaluate(() => { - const graph = window.graph as { _nodes_by_id: Record } + const graph = window.graph as TestGraphAccess const node = graph._nodes_by_id['4'] - node.widgets.splice(0, 0, node.widgets[0]) + node.widgets!.splice(0, 0, node.widgets![0]) }) await expect(loadCheckpointNode).toHaveCount(4) }) @@ -36,21 +37,21 @@ test.describe('Vue Widget Reactivity', () => { 'css=[data-testid="node-body-3"] > .lg-node-widgets > div' ) await comfyPage.page.evaluate(() => { - const graph = window.graph as { _nodes_by_id: Record } + const graph = window.graph as TestGraphAccess const node = graph._nodes_by_id['3'] - node.widgets.pop() + node.widgets!.pop() }) await expect(loadCheckpointNode).toHaveCount(5) await comfyPage.page.evaluate(() => { - const graph = window.graph as { _nodes_by_id: Record } + const graph = window.graph as TestGraphAccess const node = graph._nodes_by_id['3'] - node.widgets.length-- + node.widgets!.length-- }) await expect(loadCheckpointNode).toHaveCount(4) await comfyPage.page.evaluate(() => { - const graph = window.graph as { _nodes_by_id: Record } + const graph = window.graph as TestGraphAccess const node = graph._nodes_by_id['3'] - node.widgets.splice(0, 1) + node.widgets!.splice(0, 1) }) await expect(loadCheckpointNode).toHaveCount(3) }) diff --git a/browser_tests/types/globals.d.ts b/browser_tests/types/globals.d.ts index 90e7493e7..f9ce30a0b 100644 --- a/browser_tests/types/globals.d.ts +++ b/browser_tests/types/globals.d.ts @@ -1,8 +1,17 @@ import type { LGraph } from '@/lib/litegraph/src/LGraph' +import type { LGraphNode } from '@/lib/litegraph/src/LGraphNode' import type { LiteGraphGlobal } from '@/lib/litegraph/src/LiteGraphGlobal' import type { ComfyApp } from '@/scripts/app' import type { useWorkspaceStore } from '@/stores/workspaceStore' +/** + * Helper type for accessing nodes by ID in browser tests. + * Provides typed access to graph internals without requiring `any`. + */ +export interface TestGraphAccess { + _nodes_by_id: Record +} + interface AppReadiness { featureFlagsReceived: boolean apiInitialized: boolean