Skip to content

Commit

Permalink
Adapt and add more validation tests
Browse files Browse the repository at this point in the history
  • Loading branch information
davelopez committed Jun 22, 2024
1 parent 9b1b53f commit 85d3719
Showing 1 changed file with 64 additions and 4 deletions.
68 changes: 64 additions & 4 deletions server/gx-workflow-ls-format2/tests/integration/validation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,51 @@ class: GalaxyWorkflow
expect(diagnostics[2].message).toBe("The 'outputs' field is required.");
});

it("should report error for invalid enum value", async () => {
it("should report error for invalid input type value", async () => {
const content = `
class: GalaxyWorkflow
inputs:
the_input:
type: unknown
type: 5
outputs:
steps:
`;
const diagnostics = await validateDocument(content);
expect(diagnostics).toHaveLength(1);
expect(diagnostics[0].message).toBe(
"The value is not a valid 'GalaxyType'. Allowed values are: integer, text, File, data, collection, null, boolean, int, long, float, double, string."
"Type mismatch for field 'type'. Expected 'GalaxyType | string' but found 'number'."
);
});

it("should report error for invalid enum value", async () => {
const content = `
class: GalaxyWorkflow
inputs:
outputs:
steps:
step:
type: unknown
`;
const diagnostics = await validateDocument(content);
expect(diagnostics).toHaveLength(1);
expect(diagnostics[0].message).toBe(
"The value is not a valid 'WorkflowStepType'. Allowed values are: tool, subworkflow, pause."
);
});

it("should not report error for valid enum value", async () => {
const content = `
class: GalaxyWorkflow
inputs:
outputs:
steps:
step:
type: tool
`;
const diagnostics = await validateDocument(content);
expect(diagnostics).toHaveLength(0);
});

it("should not report error for compatible primitive types", async () => {
const content = `
class: GalaxyWorkflow
Expand Down Expand Up @@ -108,7 +137,9 @@ steps:
`;
const diagnostics = await validateDocument(content);
expect(diagnostics).toHaveLength(1);
expect(diagnostics[0].message).toContain("Type mismatch for field 'top'. Expected 'float' but found 'string'.");
expect(diagnostics[0].message).toContain(
"Type mismatch for field 'top'. Expected 'float | int' but found 'string'."
);
});

it("should not report error for properties with Any type", async () => {
Expand All @@ -126,6 +157,35 @@ steps:
expect(diagnostics).toHaveLength(0);
});

it("should not report error when multiple types are allowed (string)", async () => {
const content = `
class: GalaxyWorkflow
inputs:
outputs:
steps:
step:
out: a string
`;
const diagnostics = await validateDocument(content);
expect(diagnostics).toHaveLength(0);
});

it("should not report error when multiple types are allowed (object)", async () => {
const content = `
class: GalaxyWorkflow
inputs:
outputs:
steps:
step:
out:
add_tags:
- tag1
- tag2
`;
const diagnostics = await validateDocument(content);
expect(diagnostics).toHaveLength(0);
});

describe("Custom Rules", () => {
let rule: ValidationRule;

Expand Down

0 comments on commit 85d3719

Please sign in to comment.