test: add Window type augmentation and standardize window access

- Add browser_tests/types/globals.d.ts with Window interface augmentation

- Add types for app, graph, LiteGraph, LGraphBadge and test globals

- Standardize window['prop'] to window.prop across 37 test files

- Update browser_tests/tsconfig.json to include new type definitions

Amp-Thread-ID: https://ampcode.com/threads/T-019c16b3-cc31-70ea-9727-a933cb0ee942
Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
Alexander Brown
2026-01-31 17:04:47 -08:00
parent fdbbddaf62
commit 6cd105fdf0
39 changed files with 251 additions and 223 deletions

View File

@@ -19,14 +19,14 @@ export class NodeOperationsHelper {
async getGraphNodesCount(): Promise<number> {
return await this.page.evaluate(() => {
return window['app']?.graph?.nodes?.length || 0
return window.app?.graph?.nodes?.length || 0
})
}
async getSelectedGraphNodesCount(): Promise<number> {
return await this.page.evaluate(() => {
return (
window['app']?.graph?.nodes?.filter(
window.app?.graph?.nodes?.filter(
(node: LGraphNode) => node.is_selected === true
).length || 0
)
@@ -35,19 +35,19 @@ export class NodeOperationsHelper {
async getNodes(): Promise<LGraphNode[]> {
return await this.page.evaluate(() => {
return window['app'].graph.nodes
return window.app.graph.nodes
})
}
async waitForGraphNodes(count: number): Promise<void> {
await this.page.waitForFunction((count) => {
return window['app']?.canvas.graph?.nodes?.length === count
return window.app?.canvas.graph?.nodes?.length === count
}, count)
}
async getFirstNodeRef(): Promise<NodeReference | null> {
const id = await this.page.evaluate(() => {
return window['app'].graph.nodes[0]?.id
return window.app.graph.nodes[0]?.id
})
if (!id) return null
return this.getNodeRefById(id)
@@ -66,7 +66,7 @@ export class NodeOperationsHelper {
await this.page.evaluate(
({ type, includeSubgraph }) => {
const graph = (
includeSubgraph ? window['app'].canvas.graph : window['app'].graph
includeSubgraph ? window.app.canvas.graph : window.app.graph
) as LGraph
const nodes = graph.nodes
return nodes
@@ -83,7 +83,7 @@ export class NodeOperationsHelper {
return Promise.all(
(
await this.page.evaluate((title) => {
return window['app'].graph.nodes
return window.app.graph.nodes
.filter((n: LGraphNode) => n.title === title)
.map((n: LGraphNode) => n.id)
}, title)