Support steps context completion and validation

This commit is contained in:
Josh Gross
2022-12-05 16:50:39 -05:00
parent 40453c79cb
commit 009f4e83bf
7 changed files with 320 additions and 14 deletions
@@ -240,4 +240,78 @@ jobs:
expect(result.map(x => x.label)).toEqual(["another-name", "name"]);
});
describe("steps context", () => {
it("includes defined step IDs", async () => {
const input = `
on: push
jobs:
one:
runs-on: ubuntu-latest
steps:
- id: a
run: echo hello a
- id: b
run: echo hello b
- id: c
run: echo "hello \${{ steps.|
`;
const result = await complete(...getPositionFromCursor(input), undefined, contextProviderConfig);
expect(result.map(x => x.label)).toEqual(["a", "b"]);
});
it("step.<step_id>", async () => {
const input = `
on: push
jobs:
one:
runs-on: ubuntu-latest
steps:
- id: a
run: echo hello a
- run: echo "hello \${{ steps.a.|
`;
const result = await complete(...getPositionFromCursor(input), undefined, contextProviderConfig);
expect(result.map(x => x.label)).toEqual(["conclusion", "outcome", "outputs"]);
});
it("ignores IDs from later steps", async () => {
const input = `
on: push
jobs:
one:
runs-on: ubuntu-latest
steps:
- id: a
run: echo hello a
- id: b
run: echo "hello \${{ steps.|
- id: c
run: echo hello c
`;
const result = await complete(...getPositionFromCursor(input), undefined, contextProviderConfig);
expect(result.map(x => x.label)).toEqual(["a"]);
});
});
// The workflow parser doesn't currently generate IDs, so we can't test this yet
it.failing("Ignores generated IDs", async () => {
const input = `
on: push
jobs:
one:
runs-on: ubuntu-latest
steps:
- run: echo hello a
- id: b
run: echo hello b
- run: echo "hello \${{ steps.|
`;
const result = await complete(...getPositionFromCursor(input), undefined, contextProviderConfig);
expect(result.map(x => x.label)).toEqual(["b"]);
});
});