|
| 1 | +import {FeatureFlags} from "@actions/expressions"; |
1 | 2 | import {isString} from "@actions/workflow-parser"; |
2 | 3 | import {DescriptionProvider, hover, HoverConfig} from "./hover.js"; |
3 | 4 | import {getPositionFromCursor} from "./test-utils/cursor-position.js"; |
@@ -203,3 +204,79 @@ jobs: |
203 | 204 | ); |
204 | 205 | }); |
205 | 206 | }); |
| 207 | + |
| 208 | +describe("hover for background step keywords", () => { |
| 209 | + const bgConfig: HoverConfig = {featureFlags: new FeatureFlags({allowBackgroundSteps: true})}; |
| 210 | + |
| 211 | + it("on background key", async () => { |
| 212 | + const input = `on: push |
| 213 | +jobs: |
| 214 | + build: |
| 215 | + runs-on: ubuntu-latest |
| 216 | + steps: |
| 217 | + - id: server |
| 218 | + run: echo hi |
| 219 | + ba|ckground: true`; |
| 220 | + const result = await hover(...getPositionFromCursor(input), bgConfig); |
| 221 | + expect(result).not.toBeNull(); |
| 222 | + expect(result?.contents).toContain("runs this step in the background"); |
| 223 | + }); |
| 224 | + |
| 225 | + it("on wait key", async () => { |
| 226 | + const input = `on: push |
| 227 | +jobs: |
| 228 | + build: |
| 229 | + runs-on: ubuntu-latest |
| 230 | + steps: |
| 231 | + - id: server |
| 232 | + run: echo hi |
| 233 | + background: true |
| 234 | + - wa|it: server`; |
| 235 | + const result = await hover(...getPositionFromCursor(input), bgConfig); |
| 236 | + expect(result).not.toBeNull(); |
| 237 | + expect(result?.contents).toContain("background steps to wait for"); |
| 238 | + }); |
| 239 | + |
| 240 | + it("on wait-all key", async () => { |
| 241 | + const input = `on: push |
| 242 | +jobs: |
| 243 | + build: |
| 244 | + runs-on: ubuntu-latest |
| 245 | + steps: |
| 246 | + - id: server |
| 247 | + run: echo hi |
| 248 | + background: true |
| 249 | + - wa|it-all:`; |
| 250 | + const result = await hover(...getPositionFromCursor(input), bgConfig); |
| 251 | + expect(result).not.toBeNull(); |
| 252 | + expect(result?.contents).toContain("Wait for all prior background steps"); |
| 253 | + }); |
| 254 | + |
| 255 | + it("on cancel key", async () => { |
| 256 | + const input = `on: push |
| 257 | +jobs: |
| 258 | + build: |
| 259 | + runs-on: ubuntu-latest |
| 260 | + steps: |
| 261 | + - id: server |
| 262 | + run: echo hi |
| 263 | + background: true |
| 264 | + - ca|ncel: server`; |
| 265 | + const result = await hover(...getPositionFromCursor(input), bgConfig); |
| 266 | + expect(result).not.toBeNull(); |
| 267 | + expect(result?.contents).toContain("background step to cancel"); |
| 268 | + }); |
| 269 | + |
| 270 | + it("no hover for background keywords when feature flag is off", async () => { |
| 271 | + const input = `on: push |
| 272 | +jobs: |
| 273 | + build: |
| 274 | + runs-on: ubuntu-latest |
| 275 | + steps: |
| 276 | + - id: server |
| 277 | + run: echo hi |
| 278 | + ba|ckground: true`; |
| 279 | + const result = await hover(...getPositionFromCursor(input)); |
| 280 | + expect(result).toBeNull(); |
| 281 | + }); |
| 282 | +}); |
0 commit comments