From f9346e556fefcdb04965edd8f34b09c4ded85e05 Mon Sep 17 00:00:00 2001 From: hung-nguyen Date: Fri, 3 May 2024 18:01:04 +0700 Subject: [PATCH 1/3] test: add test cases for JsSdkTest-2,3 --- packages/create-plugin/__e2e__/e2e.test.ts | 111 +++++++++++++++++++++ 1 file changed, 111 insertions(+) diff --git a/packages/create-plugin/__e2e__/e2e.test.ts b/packages/create-plugin/__e2e__/e2e.test.ts index a40fd4f4e8..132648f213 100644 --- a/packages/create-plugin/__e2e__/e2e.test.ts +++ b/packages/create-plugin/__e2e__/e2e.test.ts @@ -15,6 +15,7 @@ import { readPluginManifestJson, } from "./utils/verification"; import { getBoundMessage } from "../src/messages"; +import { generateRandomString } from "./utils/helper"; describe("create-plugin", function () { let workingDir: string; @@ -77,6 +78,116 @@ describe("create-plugin", function () { assertObjectIncludes(actualManifestJson, expectedManifestJson); }); + it("#JsSdkTest-2 Should able to create a plugin with plugin-in name contains 64 characters", async () => { + const m = getBoundMessage("en"); + const outputDir = "test2"; + const pluginName = generateRandomString(64); + const questionsInput: QuestionInput[] = [ + { + question: m("Q_NameEn"), + answer: pluginName, + }, + { + question: m("Q_DescriptionEn"), + answer: "64characters", + }, + { + question: m("Q_SupportJa"), + answer: ANSWER_NO, + }, + { + question: m("Q_SupportZh"), + answer: ANSWER_NO, + }, + { + question: m("Q_websiteUrlEn"), + answer: DEFAULT_ANSWER, + }, + { + question: m("Q_MobileSupport"), + answer: ANSWER_NO, + }, + { + question: m("Q_enablePluginUploader"), + answer: ANSWER_NO, + }, + ]; + + const response = await executeCommandWithInteractiveInput({ + command: CREATE_PLUGIN_COMMAND, + workingDir, + outputDir, + questionsInput, + }); + + assert(response.status === 0, "Failed to create plugin"); + + const pluginDir = path.resolve(workingDir, outputDir); + assert.ok(fs.existsSync(pluginDir), "plugin dir is not created."); + + const actualManifestJson = readPluginManifestJson(pluginDir); + const expectedManifestJson = { + name: { en: pluginName }, + description: { en: "64characters" }, + }; + assertObjectIncludes(actualManifestJson, expectedManifestJson); + }); + + it("#JsSdkTest-3 Should able to create a plugin with plugin-in description contains 200 characters", async () => { + const m = getBoundMessage("en"); + const outputDir = "test3"; + const pluginDescription = generateRandomString(200); + const questionsInput: QuestionInput[] = [ + { + question: m("Q_NameEn"), + answer: "200characters", + }, + { + question: m("Q_DescriptionEn"), + answer: pluginDescription, + }, + { + question: m("Q_SupportJa"), + answer: ANSWER_NO, + }, + { + question: m("Q_SupportZh"), + answer: ANSWER_NO, + }, + { + question: m("Q_websiteUrlEn"), + answer: DEFAULT_ANSWER, + }, + { + question: m("Q_MobileSupport"), + answer: ANSWER_NO, + }, + { + question: m("Q_enablePluginUploader"), + answer: ANSWER_NO, + }, + ]; + + const response = await executeCommandWithInteractiveInput({ + command: CREATE_PLUGIN_COMMAND, + workingDir, + outputDir, + questionsInput, + }); + + assert(response.status === 0, "Failed to create plugin"); + + const pluginDir = path.resolve(workingDir, outputDir); + assert.ok(fs.existsSync(pluginDir), "plugin dir is not created."); + + const actualManifestJson = readPluginManifestJson(pluginDir); + const expectedManifestJson = { + name: { en: "200characters" }, + description: { en: pluginDescription }, + }; + assertObjectIncludes(actualManifestJson, expectedManifestJson); + }); + afterEach(() => { const testName = expect.getState().currentTestName; if (!testName || !workingDir) { From 98bdb020187bc5a21117b84b7c45324d7490dd3d Mon Sep 17 00:00:00 2001 From: Tuan Pham Date: Mon, 6 May 2024 08:19:16 +0700 Subject: [PATCH 2/3] refactor: modify key name --- packages/create-plugin/__e2e__/e2e.test.ts | 14 +++++++------- packages/create-plugin/src/messages.ts | 8 ++++---- packages/create-plugin/src/qa.ts | 8 ++++---- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/packages/create-plugin/__e2e__/e2e.test.ts b/packages/create-plugin/__e2e__/e2e.test.ts index 132648f213..4c565dd54e 100644 --- a/packages/create-plugin/__e2e__/e2e.test.ts +++ b/packages/create-plugin/__e2e__/e2e.test.ts @@ -45,7 +45,7 @@ describe("create-plugin", function () { answer: DEFAULT_ANSWER, }, { - question: m("Q_websiteUrlEn"), + question: m("Q_WebsiteUrlEn"), answer: DEFAULT_ANSWER, }, { @@ -53,7 +53,7 @@ describe("create-plugin", function () { answer: ANSWER_NO, }, { - question: m("Q_enablePluginUploader"), + question: m("Q_EnablePluginUploader"), answer: ANSWER_NO, }, ]; @@ -100,7 +100,7 @@ describe("create-plugin", function () { answer: ANSWER_NO, }, { - question: m("Q_websiteUrlEn"), + question: m("Q_WebsiteUrlEn"), answer: DEFAULT_ANSWER, }, { @@ -108,7 +108,7 @@ describe("create-plugin", function () { answer: ANSWER_NO, }, { - question: m("Q_enablePluginUploader"), + question: m("Q_EnablePluginUploader"), answer: ANSWER_NO, }, ]; @@ -155,7 +155,7 @@ describe("create-plugin", function () { answer: ANSWER_NO, }, { - question: m("Q_websiteUrlEn"), + question: m("Q_WebsiteUrlEn"), answer: DEFAULT_ANSWER, }, { @@ -163,7 +163,7 @@ describe("create-plugin", function () { answer: ANSWER_NO, }, { - question: m("Q_enablePluginUploader"), + question: m("Q_EnablePluginUploader"), answer: ANSWER_NO, }, ]; @@ -188,7 +188,7 @@ describe("create-plugin", function () { assertObjectIncludes(actualManifestJson, expectedManifestJson); }); - afterEach(() => { + afterEach(() => {ư~ const testName = expect.getState().currentTestName; if (!testName || !workingDir) { return; diff --git a/packages/create-plugin/src/messages.ts b/packages/create-plugin/src/messages.ts index 20ea729c4e..3e6eaabe50 100644 --- a/packages/create-plugin/src/messages.ts +++ b/packages/create-plugin/src/messages.ts @@ -62,15 +62,15 @@ const messages = { en: "Plug-in description must be within 64chars", ja: "プラグインの中国語の説明を64文字以内で入力してください", }, - Q_websiteUrlEn: { + Q_WebsiteUrlEn: { en: "Input your home page url for English (Optional)", ja: "プラグインの英語のWebサイトURLを入力してください (省略可)", }, - Q_websiteUrlJa: { + Q_WebsiteUrlJa: { en: "Input your home page url for Japanese (Optional)", ja: "プラグインの日本語のWebサイトURLを入力してください (省略可)", }, - Q_websiteUrlZh: { + Q_WebsiteUrlZh: { en: "Input your home page url for Chinese (Optional)", ja: "プラグインの中国語のWebサイトURLを入力してください (省略可)", }, @@ -78,7 +78,7 @@ const messages = { en: "Does your plug-in support mobile views?", ja: "モバイルページをサポートしますか?", }, - Q_enablePluginUploader: { + Q_EnablePluginUploader: { en: "Would you like to use @kintone/plugin-uploader?", ja: "@kintone/plugin-uploaderを使いますか?", }, diff --git a/packages/create-plugin/src/qa.ts b/packages/create-plugin/src/qa.ts index 62fae2289b..39363b846a 100644 --- a/packages/create-plugin/src/qa.ts +++ b/packages/create-plugin/src/qa.ts @@ -90,19 +90,19 @@ export const buildQuestions = (outputDir: string, lang: Lang): Question[] => { { type: "input", name: "homepage_url.en", - message: m("Q_websiteUrlEn"), + message: m("Q_WebsiteUrlEn"), }, { type: "input", name: "homepage_url.ja", when: (answers) => answers.ja, - message: m("Q_websiteUrlJa"), + message: m("Q_WebsiteUrlJa"), }, { type: "input", name: "homepage_url.zh", when: (answers) => answers.zh, - message: m("Q_websiteUrlZh"), + message: m("Q_WebsiteUrlZh"), }, { type: "confirm", @@ -114,7 +114,7 @@ export const buildQuestions = (outputDir: string, lang: Lang): Question[] => { type: "confirm", name: "pluginUploader", default: true, - message: m("Q_enablePluginUploader"), + message: m("Q_EnablePluginUploader"), }, ]; }; From cc5fba56c92a1b5d53302a15f4601f203e31806a Mon Sep 17 00:00:00 2001 From: Tuan Pham Date: Mon, 6 May 2024 08:27:20 +0700 Subject: [PATCH 3/3] refactor: remove redundant code --- packages/create-plugin/__e2e__/e2e.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/create-plugin/__e2e__/e2e.test.ts b/packages/create-plugin/__e2e__/e2e.test.ts index 4c565dd54e..6f6f86e528 100644 --- a/packages/create-plugin/__e2e__/e2e.test.ts +++ b/packages/create-plugin/__e2e__/e2e.test.ts @@ -188,7 +188,7 @@ describe("create-plugin", function () { assertObjectIncludes(actualManifestJson, expectedManifestJson); }); - afterEach(() => {ư~ + afterEach(() => { const testName = expect.getState().currentTestName; if (!testName || !workingDir) { return;