Skip to content

Commit

Permalink
Merge pull request #10209 from OfficeDev/aochengwang/testtool
Browse files Browse the repository at this point in the history
feat: test tool install schema for 1.3
  • Loading branch information
a1exwang authored Oct 27, 2023
2 parents 74d8ab2 + eb4b9e5 commit 831e41f
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 56 deletions.
5 changes: 1 addition & 4 deletions packages/fx-core/resource/yaml-schema/v1.3/yaml.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1221,10 +1221,7 @@
"type": "object",
"description": "Install Teams App Test Tool. This will output environment variables specified by `testToolPath` to current environment's .env file.",
"additionalProperties": false,
"required": [
"version",
"symlinkDir"
],
"required": ["version"],
"properties": {
"version": {
"oneOf": [
Expand Down
5 changes: 2 additions & 3 deletions packages/fx-core/src/component/configManager/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ import Ajv, { ValidateFunction } from "ajv";
import fs from "fs-extra";
import path from "path";
import { getResourceFolder } from "../../folder";
import { isTestToolEnabled } from "../../common/featureFlags";

type Version = string;
const supportedVersions = ["1.0.0", "1.1.0", "v1.2"];
const supportedVersions = ["1.0.0", "1.1.0", "v1.2", "v1.3"];

export class Validator {
impl: Map<Version, { validator: ValidateFunction }>;
Expand Down Expand Up @@ -36,7 +35,7 @@ export class Validator {
}

supportedVersions(): string[] {
return [...supportedVersions, ...(isTestToolEnabled() ? ["v1.3"] : [])];
return supportedVersions;
}

private latestSupportedVersion(): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ export class ToolsInstallDriverImpl {
}

if (args.testTool) {
await this.resolveTestTool(`${args.testTool.version}`, args.testTool.symlinkDir);
// Disable test tool until test tool npm package is published to prevent blocking users who accidentally add this action by intellisense.
// await this.resolveTestTool(`${args.testTool.version}`, args.testTool.symlinkDir);
}

return res;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ interface FuncArgs {

interface TestToolArgs {
version: string | number;
symlinkDir: string;
symlinkDir?: string;
}
10 changes: 2 additions & 8 deletions packages/fx-core/tests/component/configManager/validator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import chai from "chai";
import { describe, it } from "mocha";
import { Validator } from "../../../src/component/configManager/validator";
import * as sinon from "sinon";
import * as featureFlags from "../../../src/common/featureFlags";

describe("yaml validator", () => {
const validator = new Validator();
afterEach(() => {
Expand All @@ -26,11 +24,7 @@ describe("yaml validator", () => {
.expect(validator.supportedVersions())
.contains("1.0.0")
.and.contains("1.1.0")
.and.contains("v1.2");
});

it("should support v1.3 for test tool", () => {
sinon.stub(featureFlags, "isTestToolEnabled").resolves(true);
chai.expect(validator.supportedVersions()).contain("v1.3");
.and.contains("v1.2")
.and.contains("v1.3");
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -343,45 +343,45 @@ describe("Tools Install Driver test", () => {
}
});

it("Install test tool failed without error", async () => {
sandbox.stub(TestToolChecker.prototype, "resolve").resolves({
name: "Teams App Test Tool",
type: DepsType.TestTool,
isInstalled: false,
command: "teamsapptester",
details: {
isLinuxSupported: true,
supportedVersions: [],
installVersion: "0.1.0",
binFolders: ["./devTools/testTool"],
},
});
const res = await toolsInstallDriver.run(
{ testTool: { version: "~0.1.0", symlinkDir: "./devTools/testTool" } },
mockedDriverContext
);
chai.assert.isTrue(res.isErr());
});
it("Install test tool failed with error", async () => {
sandbox.stub(TestToolChecker.prototype, "resolve").resolves({
name: "Teams App Test Tool",
type: DepsType.TestTool,
isInstalled: false,
command: "teamsapptester",
details: {
isLinuxSupported: true,
supportedVersions: [],
installVersion: "0.1.0",
binFolders: ["./devTools/testTool"],
},
error: new DepsCheckerError("failed", "help link"),
});
const res = await toolsInstallDriver.run(
{ testTool: { version: "~0.1.0", symlinkDir: "./devTools/testTool" } },
mockedDriverContext
);
chai.assert.isTrue(res.isErr());
});
// it("Install test tool failed without error", async () => {
// sandbox.stub(TestToolChecker.prototype, "resolve").resolves({
// name: "Teams App Test Tool",
// type: DepsType.TestTool,
// isInstalled: false,
// command: "teamsapptester",
// details: {
// isLinuxSupported: true,
// supportedVersions: [],
// installVersion: "0.1.0",
// binFolders: ["./devTools/testTool"],
// },
// });
// const res = await toolsInstallDriver.run(
// { testTool: { version: "~0.1.0", symlinkDir: "./devTools/testTool" } },
// mockedDriverContext
// );
// chai.assert.isTrue(res.isErr());
// });
// it("Install test tool failed with error", async () => {
// sandbox.stub(TestToolChecker.prototype, "resolve").resolves({
// name: "Teams App Test Tool",
// type: DepsType.TestTool,
// isInstalled: false,
// command: "teamsapptester",
// details: {
// isLinuxSupported: true,
// supportedVersions: [],
// installVersion: "0.1.0",
// binFolders: ["./devTools/testTool"],
// },
// error: new DepsCheckerError("failed", "help link"),
// });
// const res = await toolsInstallDriver.run(
// { testTool: { version: "~0.1.0", symlinkDir: "./devTools/testTool" } },
// mockedDriverContext
// );
// chai.assert.isTrue(res.isErr());
// });
const cases: { name: string; args: unknown; expected: boolean }[] = [
{
name: "happy path",
Expand Down

0 comments on commit 831e41f

Please sign in to comment.