Skip to content

Commit 590ad09

Browse files
committed
[refactor] Rename task types in test files to avoid schema cache pollution
Root Cause: Test pollution from shared static schema cache. The Task class has a static _inputSchemaNode: Map<string, SchemaNode> that caches compiled schemas keyed by the task's type property. Two different test files defined task classes with the same static type values ("TaskA", "TaskB") but with different schemas: GraphAsTask.test.ts: TaskB expects inputB: { type: "string" } IteratorTask.test.ts: TaskB expects required: ["result"] When tests run in a different order on CI vs locally, the static cache from one test would pollute the other: IteratorTask.test.ts runs first and caches a schema for "TaskB" that requires result GraphAsTask.test.ts runs later and uses that cached schema, causing the validation error Fix: Added unique prefixes to the type names to avoid cache collisions: GraphAsTask.test.ts: "GraphAsTask_TaskA", "GraphAsTask_TaskB", "GraphAsTask_TaskC" IteratorTask.test.ts: "IteratorTask_TaskA", "IteratorTask_TaskB"
1 parent 714a4b6 commit 590ad09

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

packages/test/src/test/task-graph/IteratorTask.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1436,7 +1436,7 @@ describe("Workflow Integration - Template Graph Access", () => {
14361436
}
14371437

14381438
class TaskA extends Task<TaskInput, CompatibleOutput> {
1439-
public static type = "TaskA";
1439+
public static type = "IteratorTask_TaskA";
14401440
public static inputSchema(): DataPortSchema {
14411441
return {
14421442
type: "object",
@@ -1457,7 +1457,7 @@ describe("Workflow Integration - Template Graph Access", () => {
14571457
}
14581458

14591459
class TaskB extends Task<CompatibleInput, TaskOutput> {
1460-
public static type = "TaskB";
1460+
public static type = "IteratorTask_TaskB";
14611461
public static inputSchema(): DataPortSchema {
14621462
return {
14631463
type: "object",

packages/test/src/test/task/GraphAsTask.test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ import { DataPortSchema } from "@workglow/util";
33
import { describe, expect, it } from "vitest";
44

55
// Test tasks with specific input/output schemas
6+
// NOTE: These type names must be unique across all test files to avoid
7+
// static schema cache pollution in Task._inputSchemaNode
68
class TaskA extends Task {
7-
static type = "TaskA";
9+
static type = "GraphAsTask_TaskA";
810
static category = "Test";
911

1012
static inputSchema(): DataPortSchema {
@@ -45,7 +47,7 @@ class TaskA extends Task {
4547
}
4648

4749
class TaskB extends Task {
48-
static type = "TaskB";
50+
static type = "GraphAsTask_TaskB";
4951
static category = "Test";
5052

5153
static inputSchema(): DataPortSchema {
@@ -81,7 +83,7 @@ class TaskB extends Task {
8183
}
8284

8385
class TaskC extends Task {
84-
static type = "TaskC";
86+
static type = "GraphAsTask_TaskC";
8587
static category = "Test";
8688

8789
static inputSchema(): DataPortSchema {

0 commit comments

Comments
 (0)