refactor: remove any types from E2E test files (10 instances)

Fixed all 'as any' and ': any' instances in E2E tests:
- featureFlags.spec.ts: Used Record<string, unknown> for window properties (5 instances)
- linkInteraction.spec.ts: Used Record<string, unknown> for window.app access (2 instances)
- nodeHelp.spec.ts: Added proper ComfyPage and NodeReference types (2 instances)
- selectionToolboxSubmenus.spec.ts: Added ComfyPage type for function parameter (1 instance)

All test files (unit, component, and E2E) are now completely free of 'any' types.
This commit is contained in:
Johnpaul
2026-01-22 22:52:58 +01:00
parent f34b8aa39e
commit f6718adec9
4 changed files with 26 additions and 15 deletions

View File

@@ -274,7 +274,7 @@ test.describe('Feature Flags', () => {
// Set up monitoring before navigation
await newPage.addInitScript(() => {
// Track when various app components are ready
;(window as any).__appReadiness = {
;(window as unknown as Record<string, unknown>).__appReadiness = {
featureFlagsReceived: false,
apiInitialized: false,
appInitialized: false
@@ -286,7 +286,10 @@ test.describe('Feature Flags', () => {
window['app']?.api?.serverFeatureFlags?.supports_preview_metadata !==
undefined
) {
;(window as any).__appReadiness.featureFlagsReceived = true
;(window as unknown as Record<string, unknown>).__appReadiness = {
...(window as unknown as Record<string, unknown>).__appReadiness,
featureFlagsReceived: true
}
clearInterval(checkFeatureFlags)
}
}, 10)
@@ -294,7 +297,10 @@ test.describe('Feature Flags', () => {
// Monitor API initialization
const checkApi = setInterval(() => {
if (window['app']?.api) {
;(window as any).__appReadiness.apiInitialized = true
;(window as unknown as Record<string, unknown>).__appReadiness = {
...(window as unknown as Record<string, unknown>).__appReadiness,
apiInitialized: true
}
clearInterval(checkApi)
}
}, 10)
@@ -302,7 +308,10 @@ test.describe('Feature Flags', () => {
// Monitor app initialization
const checkApp = setInterval(() => {
if (window['app']?.graph) {
;(window as any).__appReadiness.appInitialized = true
;(window as unknown as Record<string, unknown>).__appReadiness = {
...(window as unknown as Record<string, unknown>).__appReadiness,
appInitialized: true
}
clearInterval(checkApp)
}
}, 10)
@@ -331,7 +340,7 @@ test.describe('Feature Flags', () => {
// Get readiness state
const readiness = await newPage.evaluate(() => {
return {
...(window as any).__appReadiness,
...(window as unknown as Record<string, unknown>).__appReadiness,
currentFlags: window['app'].api.serverFeatureFlags
}
})

View File

@@ -1,12 +1,11 @@
import {
comfyExpect as expect,
comfyPageFixture as test
} from '../fixtures/ComfyPage'
import { comfyExpect as expect, comfyPageFixture as test } from '../fixtures/ComfyPage';
import type { ComfyPage } from '../fixtures/ComfyPage';
import { fitToViewInstant } from '../helpers/fitToView'
import type { NodeReference } from '../fixtures/utils/litegraphUtils'
// TODO: there might be a better solution for this
// Helper function to pan canvas and select node
async function selectNodeWithPan(comfyPage: any, nodeRef: any) {
async function selectNodeWithPan(comfyPage: ComfyPage, nodeRef: NodeReference) {
const nodePos = await nodeRef.getPosition()
await comfyPage.page.evaluate((pos) => {
@@ -345,7 +344,9 @@ This is documentation for a custom node.
// Find and select a custom/group node
const nodeRefs = await comfyPage.page.evaluate(() => {
return window['app'].graph.nodes.map((n: any) => n.id)
return window['app'].graph.nodes.map(
(n: Record<string, unknown>) => n.id
)
})
if (nodeRefs.length > 0) {
const firstNode = await comfyPage.getNodeRefById(nodeRefs[0])

View File

@@ -1,6 +1,7 @@
import { expect } from '@playwright/test'
import { comfyPageFixture as test } from '../fixtures/ComfyPage'
import { comfyPageFixture as test } from '../fixtures/ComfyPage';
import type { ComfyPage } from '../fixtures/ComfyPage';
test.beforeEach(async ({ comfyPage }) => {
await comfyPage.setSetting('Comfy.UseNewMenu', 'Disabled')
@@ -15,7 +16,7 @@ test.describe('Selection Toolbox - More Options Submenus', () => {
await comfyPage.nextFrame()
})
const openMoreOptions = async (comfyPage: any) => {
const openMoreOptions = async (comfyPage: ComfyPage) => {
const ksamplerNodes = await comfyPage.getNodeRefsByTitle('KSampler')
if (ksamplerNodes.length === 0) {
throw new Error('No KSampler nodes found')

View File

@@ -419,7 +419,7 @@ test.describe('Vue Node Link Interaction', () => {
// This avoids relying on an exact path hit-test position.
await comfyPage.page.evaluate(
([targetNodeId, targetSlot, clientPoint]) => {
const app = (window as any)['app']
const app = (window as unknown as Record<string, unknown>)['app']
const graph = app?.canvas?.graph ?? app?.graph
if (!graph) throw new Error('Graph not available')
const node = graph.getNodeById(targetNodeId)
@@ -505,7 +505,7 @@ test.describe('Vue Node Link Interaction', () => {
// This avoids relying on an exact path hit-test position.
await comfyPage.page.evaluate(
([targetNodeId, targetSlot, clientPoint]) => {
const app = (window as any)['app']
const app = (window as unknown as Record<string, unknown>)['app']
const graph = app?.canvas?.graph ?? app?.graph
if (!graph) throw new Error('Graph not available')
const node = graph.getNodeById(targetNodeId)