|
2 | 2 | import {nullTrace} from "../test-utils/null-trace.js"; |
3 | 3 | import {parseWorkflow} from "../workflows/workflow-parser.js"; |
4 | 4 | import {convertWorkflowTemplate, ErrorPolicy} from "./convert.js"; |
5 | | -import {isExecutableStep} from "./type-guards.js"; |
6 | 5 |
|
7 | 6 | function serializeTemplate(template: unknown): unknown { |
8 | 7 | return JSON.parse(JSON.stringify(template)); |
@@ -494,13 +493,14 @@ jobs: |
494 | 493 | const job = template.jobs[0]; |
495 | 494 | expect(job.type).toBe("job"); |
496 | 495 | if (job.type === "job") { |
497 | | - expect(isExecutableStep(job.steps[0])).toBe(true); |
498 | | - expect(isExecutableStep(job.steps[1])).toBe(true); |
499 | | - expect(isExecutableStep(job.steps[2])).toBe(true); |
500 | | - if (isExecutableStep(job.steps[0]) && isExecutableStep(job.steps[1]) && isExecutableStep(job.steps[2])) { |
501 | | - expect(job.steps[0].if?.expression).toBe("Success()"); |
502 | | - expect(job.steps[1].if?.expression).toBe("FAILURE()"); |
503 | | - expect(job.steps[2].if?.expression).toBe("Cancelled() || Always()"); |
| 496 | + const [firstStep, secondStep, thirdStep] = job.steps; |
| 497 | + expect("if" in firstStep).toBe(true); |
| 498 | + expect("if" in secondStep).toBe(true); |
| 499 | + expect("if" in thirdStep).toBe(true); |
| 500 | + if ("if" in firstStep && "if" in secondStep && "if" in thirdStep) { |
| 501 | + expect(firstStep.if?.expression).toBe("Success()"); |
| 502 | + expect(secondStep.if?.expression).toBe("FAILURE()"); |
| 503 | + expect(thirdStep.if?.expression).toBe("Cancelled() || Always()"); |
504 | 504 | } |
505 | 505 | } |
506 | 506 | }); |
@@ -543,11 +543,12 @@ jobs: |
543 | 543 | expect(job2.if?.expression).toBe("success()"); |
544 | 544 |
|
545 | 545 | if (job2.type === "job") { |
546 | | - expect(isExecutableStep(job2.steps[0])).toBe(true); |
547 | | - expect(isExecutableStep(job2.steps[1])).toBe(true); |
548 | | - if (isExecutableStep(job2.steps[0]) && isExecutableStep(job2.steps[1])) { |
549 | | - expect(job2.steps[0].if?.expression).toBe("success()"); |
550 | | - expect(job2.steps[1].if?.expression).toBe("success()"); |
| 546 | + const [firstStep, secondStep] = job2.steps; |
| 547 | + expect("if" in firstStep).toBe(true); |
| 548 | + expect("if" in secondStep).toBe(true); |
| 549 | + if ("if" in firstStep && "if" in secondStep) { |
| 550 | + expect(firstStep.if?.expression).toBe("success()"); |
| 551 | + expect(secondStep.if?.expression).toBe("success()"); |
551 | 552 | } |
552 | 553 | } |
553 | 554 | }); |
@@ -582,13 +583,14 @@ jobs: |
582 | 583 | const job = template.jobs[0]; |
583 | 584 | expect(job.type).toBe("job"); |
584 | 585 | if (job.type === "job") { |
585 | | - expect(isExecutableStep(job.steps[0])).toBe(true); |
586 | | - expect(isExecutableStep(job.steps[1])).toBe(true); |
587 | | - expect(isExecutableStep(job.steps[2])).toBe(true); |
588 | | - if (isExecutableStep(job.steps[0]) && isExecutableStep(job.steps[1]) && isExecutableStep(job.steps[2])) { |
589 | | - expect(job.steps[0].if?.expression).toBe("success().outputs.result"); |
590 | | - expect(job.steps[1].if?.expression).toBe("failure().outputs.value"); |
591 | | - expect(job.steps[2].if?.expression).toBe("always() && steps.test.outcome"); |
| 586 | + const [firstStep, secondStep, thirdStep] = job.steps; |
| 587 | + expect("if" in firstStep).toBe(true); |
| 588 | + expect("if" in secondStep).toBe(true); |
| 589 | + expect("if" in thirdStep).toBe(true); |
| 590 | + if ("if" in firstStep && "if" in secondStep && "if" in thirdStep) { |
| 591 | + expect(firstStep.if?.expression).toBe("success().outputs.result"); |
| 592 | + expect(secondStep.if?.expression).toBe("failure().outputs.value"); |
| 593 | + expect(thirdStep.if?.expression).toBe("always() && steps.test.outcome"); |
592 | 594 | } |
593 | 595 | } |
594 | 596 | }); |
|
0 commit comments