UNPKG

teamsfx-extension

Version:

Create, debug, and deploy Teams apps with Teams Toolkit

150 lines 8.91 kB
"use strict"; // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const path = require("path"); const chai = require("chai"); const nodeUtils = require("../utils/node"); const dotnetUtils = require("../utils/dotnet"); const chaiAsPromised = require("chai-as-promised"); const dotnetChecker_1 = require("../../../../src/debug/depsChecker/dotnetChecker"); const checker_1 = require("../../../../src/debug/depsChecker/checker"); const testAdapter_1 = require("../adapters/testAdapter"); const testLogger_1 = require("../adapters/testLogger"); const testTelemetry_1 = require("../adapters/testTelemetry"); const common_1 = require("../utils/common"); const common_2 = require("../../../../src/debug/depsChecker/common"); const azureNodeChecker_1 = require("../../../../src/debug/depsChecker/azureNodeChecker"); const backendExtensionsInstall_1 = require("../../../../src/debug/depsChecker/backendExtensionsInstall"); chai.use(chaiAsPromised); const azureSupportedNodeVersions = ["10", "12", "14"]; const testCsprojFileName = "extensions.csproj"; const testOutputDirName = "bin"; function createTestChecker(hasTeamsfxBackend, clickCancel = false, dotnetCheckerEnabled = true, funcToolCheckerEnabled = true, nodeCheckerEnabled = true) { const testAdapter = new testAdapter_1.TestAdapter(hasTeamsfxBackend, clickCancel, dotnetCheckerEnabled, funcToolCheckerEnabled, nodeCheckerEnabled); const telemetry = new testTelemetry_1.TestTelemetry(); const nodeChecker = new azureNodeChecker_1.AzureNodeChecker(testAdapter, testLogger_1.logger, telemetry); const dotnetChecker = new dotnetChecker_1.DotnetChecker(testAdapter, testLogger_1.logger, telemetry); const depsChecker = new checker_1.DepsChecker(testLogger_1.logger, testAdapter, [dotnetChecker]); const backendExtensionsInstaller = new backendExtensionsInstall_1.BackendExtensionsInstaller(dotnetChecker, testLogger_1.logger); return [depsChecker, nodeChecker, dotnetChecker, backendExtensionsInstaller]; } suite("All checkers E2E test", () => __awaiter(void 0, void 0, void 0, function* () { let backendProjectDir; let backendOutputPath; let cleanupProjectDir; setup(function () { return __awaiter(this, void 0, void 0, function* () { [backendProjectDir, cleanupProjectDir] = yield dotnetUtils.createTmpBackendProjectDir(testCsprojFileName); backendOutputPath = path.resolve(backendProjectDir, testOutputDirName); yield dotnetUtils.cleanup(); }); }); test("All installed", function () { return __awaiter(this, void 0, void 0, function* () { const nodeVersion = yield nodeUtils.getNodeVersion(); if (!(nodeVersion != null && azureSupportedNodeVersions.includes(nodeVersion))) { this.skip(); } if (!(yield dotnetUtils.hasAnyDotnetVersions(dotnetUtils.dotnetCommand, dotnetUtils.dotnetSupportedVersions))) { this.skip(); } const [checker, _, dotnetChecker, backendExtensionsInstaller] = createTestChecker(true); const shouldContinue = yield checker.resolve(); chai.assert.isTrue(shouldContinue); const dotnetExecPath = yield dotnetChecker.getDotnetExecPath(); chai.assert.isNotNull(dotnetExecPath); chai.assert.isTrue(yield dotnetUtils.hasAnyDotnetVersions(dotnetExecPath, dotnetUtils.dotnetSupportedVersions)); chai.assert.isFalse(yield common_1.isNonEmptyDir(backendOutputPath)); yield backendExtensionsInstaller.install(backendProjectDir, testCsprojFileName, testOutputDirName); chai.assert.isTrue(yield common_1.isNonEmptyDir(backendOutputPath)); }); }); test("None installed", function () { return __awaiter(this, void 0, void 0, function* () { const nodeVersion = yield nodeUtils.getNodeVersion(); if (nodeVersion != null) { this.skip(); } if (yield dotnetUtils.hasAnyDotnetVersions(dotnetUtils.dotnetCommand, dotnetUtils.dotnetSupportedVersions)) { this.skip(); } const [checker, _, dotnetChecker, backendExtensionsInstaller] = createTestChecker(true); const shouldContinue = yield checker.resolve(); chai.assert.isTrue(shouldContinue); const dotnetExecPath = yield dotnetChecker.getDotnetExecPath(); if (common_2.isLinux()) { chai.assert.isNull(dotnetExecPath); chai.assert.isFalse(yield dotnetUtils.hasAnyDotnetVersions(dotnetExecPath, dotnetUtils.dotnetSupportedVersions)); } else { chai.assert.isNotNull(dotnetExecPath); chai.assert.isTrue(yield dotnetUtils.hasAnyDotnetVersions(dotnetExecPath, dotnetUtils.dotnetSupportedVersions)); chai.assert.isFalse(yield common_1.isNonEmptyDir(backendOutputPath)); yield backendExtensionsInstaller.install(backendProjectDir, testCsprojFileName, testOutputDirName); chai.assert.isTrue(yield common_1.isNonEmptyDir(backendOutputPath)); } }); }); test("Node.js is installed, but .NET SDK is not", function () { return __awaiter(this, void 0, void 0, function* () { const nodeVersion = yield nodeUtils.getNodeVersion(); if (!(nodeVersion != null && azureSupportedNodeVersions.includes(nodeVersion))) { this.skip(); } if (yield common_1.commandExistsInPath(dotnetUtils.dotnetCommand)) { this.skip(); } const [checker, _, dotnetChecker, backendExtensionsInstaller] = createTestChecker(true); const shouldContinue = yield checker.resolve(); chai.assert.isTrue(shouldContinue); const dotnetExecPath = yield dotnetUtils.getDotnetExecPathFromConfig(dotnetUtils.dotnetConfigPath); if (common_2.isLinux()) { chai.assert.isNull(dotnetExecPath); } else { chai.assert.isNotNull(dotnetExecPath); chai.assert.isTrue(yield dotnetUtils.hasAnyDotnetVersions(dotnetExecPath, dotnetUtils.dotnetSupportedVersions)); chai.assert.isFalse(yield common_1.isNonEmptyDir(backendOutputPath)); yield backendExtensionsInstaller.install(backendProjectDir, testCsprojFileName, testOutputDirName); chai.assert.isTrue(yield common_1.isNonEmptyDir(backendOutputPath)); } }); }); test("All disabled", function () { return __awaiter(this, void 0, void 0, function* () { const [checker, _, dotnetChecker, backendExtensionsInstaller] = createTestChecker(true, false, false, false, false); const shouldContinue = yield checker.resolve(); const dotnetExecPath = yield dotnetChecker.getDotnetExecPath(); chai.assert.isTrue(shouldContinue); chai.assert.isNotNull(dotnetExecPath); chai.assert.equal(dotnetExecPath, dotnetUtils.dotnetCommand); chai.assert.isFalse(yield common_1.isNonEmptyDir(backendOutputPath)); if (yield dotnetUtils.hasAnyDotnetVersions(dotnetUtils.dotnetCommand, dotnetUtils.dotnetSupportedVersions)) { yield backendExtensionsInstaller.install(backendProjectDir, testCsprojFileName, testOutputDirName); chai.assert.isTrue(yield common_1.isNonEmptyDir(backendOutputPath)); } else { // If dotnet command is not found, spawn will throw an ENOENT error yield chai.assert.isRejected(backendExtensionsInstaller.install(backendProjectDir, testCsprojFileName, testOutputDirName), /ENOENT/); chai.assert.isFalse(yield common_1.isNonEmptyDir(backendOutputPath)); } }); }); teardown(function () { return __awaiter(this, void 0, void 0, function* () { yield dotnetUtils.cleanup(); cleanupProjectDir(); }); }); })); //# sourceMappingURL=all.js.map