diff --git a/lib/commands/new/helper.js b/lib/commands/new/helper.js index 3d628e5d..750bff7b 100644 --- a/lib/commands/new/helper.js +++ b/lib/commands/new/helper.js @@ -8,8 +8,6 @@ const ResourcesConfig = require('@src/model/resources-config'); const CONSTANTS = require('@src/utils/constants'); const stringUtils = require('@src/utils/string-utils'); -const ui = require('./ui'); - module.exports = { downloadTemplateFromGit, loadSkillProjectModel, @@ -83,7 +81,7 @@ function updateSkillProjectWithUserSettings(skillName, projectPath, profile) { */ function initializeDeployDelegate(deployerType, projectFolderPath, profile, doDebug, callback) { // no need to bootstrap if it's self-hosted - if (deployerType === ui.SKIP_DEPLOY_DELEGATE_SELECTION) { + if (!deployerType) { return callback(); } // no need to bootstrap as the project is already configured with deployerType diff --git a/lib/commands/new/ui.js b/lib/commands/new/ui.js index 74cbdd14..08a61355 100644 --- a/lib/commands/new/ui.js +++ b/lib/commands/new/ui.js @@ -116,6 +116,9 @@ function getDeploymentType(deployType, callback) { pageSize: 30, filter: input => input.replace(/\n.*/g, '') }]).then((answer) => { + if (answer.deployDelegate === SKIP_DEPLOY_DELEGATE_SELECTION) { + return callback(); + } callback(null, R.find(R.propEq('OPTION_NAME', answer.deployDelegate))(R.values(deployType)).NAME); }).catch((error) => { callback(error); diff --git a/lib/commands/new/wizard-helper.js b/lib/commands/new/wizard-helper.js index 3d6c93a8..22c55945 100644 --- a/lib/commands/new/wizard-helper.js +++ b/lib/commands/new/wizard-helper.js @@ -114,7 +114,7 @@ function _getTemplateInfo(cmd, userInput, callback) { */ function _newWithOfficialTemplate(language, deploymentType, doDebug, callback) { let templateIndexUrl; - if (deploymentType === ui.SKIP_DEPLOY_DELEGATE_SELECTION) { + if (!deploymentType) { templateIndexUrl = CONSTANTS.TEMPLATES.LANGUAGE_MAP[language].TEMPLATE_INDEX; } else { templateIndexUrl = DeployDelegate.builtin[deploymentType].templates.language_map[language]; diff --git a/test/unit/commands/new/helper-test.js b/test/unit/commands/new/helper-test.js index 477b6e2f..17e04088 100644 --- a/test/unit/commands/new/helper-test.js +++ b/test/unit/commands/new/helper-test.js @@ -22,7 +22,6 @@ describe('Commands new test - helper test', () => { const TEST_TEMPLATE_URL = 'value'; const TEST_SKILL_FOLDER_NAME = 'skillFolderName'; const TEST_SKILL_NAME = 'skillName'; - const TEST_SKIP_DEPLOY_DELEGATE = 'self-hosted and manage your own hosting'; const TEST_USER_INPUT = { skillName: 'testName', projectFolderName: 'projectName', @@ -44,7 +43,7 @@ describe('Commands new test - helper test', () => { it('| ui select deploy delegate pass and selection is opt-out, expect quit process', (done) => { // setup // call - helper.initializeDeployDelegate(TEST_SKIP_DEPLOY_DELEGATE, TEST_INFRA_PATH, TEST_PROFILE, TEST_DO_DEBUG, (err, res) => { + helper.initializeDeployDelegate(null, TEST_INFRA_PATH, TEST_PROFILE, TEST_DO_DEBUG, (err, res) => { // verify expect(res).equal(undefined); expect(err).equal(undefined); diff --git a/test/unit/commands/new/ui-test.js b/test/unit/commands/new/ui-test.js index 3b33a186..fff4105a 100644 --- a/test/unit/commands/new/ui-test.js +++ b/test/unit/commands/new/ui-test.js @@ -390,6 +390,24 @@ describe('Commands new - UI test', () => { }); }); + it('| self-hosted confirmation entered by user is retrieved correctly', (done) => { + // setup + inquirer.prompt.resolves({ deployDelegate: ui.SKIP_DEPLOY_DELEGATE_SELECTION }); + // call + ui.getDeploymentType(TEST_DEPLOYMENT_MAP, (err, response) => { + // verify + validateInquirerConfig(inquirer.prompt.args[0][0][0], { + message: 'Choose a method to host your skill\'s backend resources: ', + type: 'list', + choices: TEST_DEPLOYMENT_CHOICES_WITH_SEP + }); + expect(inquirer.prompt.args[0][0][0].filter('a \n \n b')).equal('a '); + expect(err).equal(undefined); + expect(response).equal(undefined); + done(); + }); + }); + it('| get confirmation meets inquirer throws exception', (done) => { // setup inquirer.prompt.rejects(new Error(TEST_ERROR)); diff --git a/test/unit/commands/new/wizard-helper-test.js b/test/unit/commands/new/wizard-helper-test.js index ab6b66b8..785256ec 100644 --- a/test/unit/commands/new/wizard-helper-test.js +++ b/test/unit/commands/new/wizard-helper-test.js @@ -205,7 +205,7 @@ We currently only support ".git" url for user's custom template.`; body: TEST_TEMPLATE_MAP }; ui.selectSkillCodeLanguage.callsArgWith(0, null, TEST_LANGUAGE_RESPONSE); - ui.getDeploymentType.callsArgWith(1, null, TEST_DEPLOYMENT_MANUAL_TYPE); + ui.getDeploymentType.callsArgWith(1, null); httpClient.request.callsArgWith(3, null, TEST_HTTP_RESPONSE); ui.getTargetTemplateName.callsArgWith(1, null, TEST_TEMPLATE_NAME); ui.getSkillName.callsArgWith(1, TEST_ERROR);