Revert "Merge pull request #320 from actions/allanguigou/default-case" (#332)

This reverts commit 191a7b6a00, reversing
changes made to 448180bd7f.
This commit is contained in:
eric sciple
2026-02-26 09:50:07 -06:00
committed by GitHub
parent 92c5235a00
commit eb71b18f2b
5 changed files with 56 additions and 15 deletions
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import {data, DescriptionDictionary} from "@actions/expressions";
import {data, DescriptionDictionary, FeatureFlags} from "@actions/expressions";
import {CompletionItem, CompletionItemKind, MarkupContent} from "vscode-languageserver-types";
import {complete, getExpressionInput} from "./complete.js";
import {ContextProviderConfig} from "./context-providers/config.js";
@@ -69,7 +69,8 @@ describe("expressions", () => {
it("single region", async () => {
const input = "run-name: ${{ | }}";
const result = await complete(...getPositionFromCursor(input), {
contextProviderConfig
contextProviderConfig,
featureFlags: new FeatureFlags({allowCaseFunction: true})
});
expect(result.map(x => x.label)).toEqual([
@@ -112,7 +113,8 @@ describe("expressions", () => {
it("single region with existing input", async () => {
const input = "run-name: ${{ g| }}";
const result = await complete(...getPositionFromCursor(input), {
contextProviderConfig
contextProviderConfig,
featureFlags: new FeatureFlags({allowCaseFunction: true})
});
expect(result.map(x => x.label)).toEqual([
@@ -133,7 +135,8 @@ describe("expressions", () => {
it("single region with existing condition", async () => {
const input = "run-name: ${{ g| == 'test' }}";
const result = await complete(...getPositionFromCursor(input), {
contextProviderConfig
contextProviderConfig,
featureFlags: new FeatureFlags({allowCaseFunction: true})
});
expect(result.map(x => x.label)).toEqual([
@@ -154,7 +157,8 @@ describe("expressions", () => {
it("multiple regions with partial function", async () => {
const input = "run-name: Run a ${{ inputs.test }} one-line script ${{ from|('test') == inputs.name }}";
const result = await complete(...getPositionFromCursor(input), {
contextProviderConfig
contextProviderConfig,
featureFlags: new FeatureFlags({allowCaseFunction: true})
});
expect(result.map(x => x.label)).toEqual([
@@ -175,7 +179,8 @@ describe("expressions", () => {
it("multiple regions - first region", async () => {
const input = "run-name: test-${{ git| == 1 }}-${{ github.event }}";
const result = await complete(...getPositionFromCursor(input), {
contextProviderConfig
contextProviderConfig,
featureFlags: new FeatureFlags({allowCaseFunction: true})
});
expect(result.map(x => x.label)).toEqual([
@@ -196,7 +201,8 @@ describe("expressions", () => {
it("multiple regions", async () => {
const input = "run-name: test-${{ github }}-${{ | }}";
const result = await complete(...getPositionFromCursor(input), {
contextProviderConfig
contextProviderConfig,
featureFlags: new FeatureFlags({allowCaseFunction: true})
});
expect(result.map(x => x.label)).toEqual([
@@ -1175,7 +1181,8 @@ jobs:
`;
const result = await complete(...getPositionFromCursor(input), {
contextProviderConfig
contextProviderConfig,
featureFlags: new FeatureFlags({allowCaseFunction: true})
});
expect(result.map(x => x.label)).toEqual([
"env",
+18 -2
View File
@@ -6,6 +6,7 @@ import {getPositionFromCursor} from "./test-utils/cursor-position.js";
import {TestLogger} from "./test-utils/logger.js";
import {clearCache} from "./utils/workflow-cache.js";
import {ValueProviderConfig, ValueProviderKind} from "./value-providers/config.js";
import {FeatureFlags} from "@actions/expressions/features";
registerLogger(new TestLogger());
@@ -897,9 +898,11 @@ jobs:
});
describe("expression completions", () => {
it("includes case function", async () => {
it("include case function when enabled", async () => {
const input = "on: push\njobs:\n build:\n runs-on: ${{ c|";
const result = await complete(...getPositionFromCursor(input));
const result = await complete(...getPositionFromCursor(input), {
featureFlags: new FeatureFlags({allowCaseFunction: true})
});
expect(result).not.toBeUndefined();
// Expression completions starting with 'c': case, contains
@@ -907,5 +910,18 @@ jobs:
expect(labels).toContain("case");
expect(labels).toContain("contains");
});
it("exclude case function when disabled", async () => {
const input = "on: push\njobs:\n build:\n runs-on: ${{ c|";
const result = await complete(...getPositionFromCursor(input), {
featureFlags: new FeatureFlags({allowCaseFunction: false})
});
expect(result).not.toBeUndefined();
// Expression completions starting with 'c': contains
const labels = result.map(x => x.label);
expect(labels).not.toContain("case");
expect(labels).toContain("contains");
});
});
});