-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(create-plugin): add test cases for JsSdkTest-10,11,12,13 (#2742)
- Loading branch information
Showing
13 changed files
with
557 additions
and
328 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import type { TestPattern } from "../e2e.test"; | ||
import { ANSWER_YES, CREATE_PLUGIN_COMMAND } from "../utils/constants"; | ||
import { getBoundMessage } from "../../src/messages"; | ||
|
||
const m = getBoundMessage("en"); | ||
|
||
export const pattern: TestPattern = { | ||
description: | ||
"#JsSdkTest-4 Should able to create a plugin with specified output directory and all options successfully", | ||
input: { | ||
command: CREATE_PLUGIN_COMMAND, | ||
outputDir: "test4", | ||
questionsInput: [ | ||
{ | ||
question: m("Q_NameEn"), | ||
answer: "test4-name", | ||
}, | ||
{ | ||
question: m("Q_DescriptionEn"), | ||
answer: "test4-description", | ||
}, | ||
{ | ||
question: m("Q_SupportJa"), | ||
answer: ANSWER_YES, | ||
}, | ||
{ | ||
question: m("Q_NameJa"), | ||
answer: "私のプラグイン", | ||
}, | ||
{ | ||
question: m("Q_DescriptionJa"), | ||
answer: "私のプラグイン", | ||
}, | ||
{ | ||
question: m("Q_SupportZh"), | ||
answer: ANSWER_YES, | ||
}, | ||
{ | ||
question: m("Q_NameZh"), | ||
answer: "我的插件", | ||
}, | ||
{ | ||
question: m("Q_DescriptionZh"), | ||
answer: "我的插件", | ||
}, | ||
{ | ||
question: m("Q_WebsiteUrlEn"), | ||
answer: "https://github.com", | ||
}, | ||
{ | ||
question: m("Q_WebsiteUrlJa"), | ||
answer: "https://github.jp", | ||
}, | ||
{ | ||
question: m("Q_WebsiteUrlZh"), | ||
answer: "https://github.cn", | ||
}, | ||
{ | ||
question: m("Q_MobileSupport"), | ||
answer: ANSWER_YES, | ||
}, | ||
{ | ||
question: m("Q_EnablePluginUploader"), | ||
answer: ANSWER_YES, | ||
}, | ||
], | ||
}, | ||
expected: { | ||
success: { | ||
manifestJson: { | ||
name: { | ||
en: "test4-name", | ||
ja: "私のプラグイン", | ||
zh: "我的插件", | ||
}, | ||
description: { | ||
en: "test4-description", | ||
ja: "私のプラグイン", | ||
zh: "我的插件", | ||
}, | ||
homepage_url: { | ||
en: "https://github.com", | ||
ja: "https://github.jp", | ||
zh: "https://github.cn", | ||
}, | ||
mobile: { | ||
js: ["js/mobile.js"], | ||
css: ["css/mobile.css"], | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; |
93 changes: 93 additions & 0 deletions
93
packages/create-plugin/__e2e__/fixtures/createKintonePluginCommand.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import type { TestPattern } from "../e2e.test"; | ||
import { ANSWER_YES, CREATE_KINTONE_PLUGIN_COMMAND } from "../utils/constants"; | ||
import { getBoundMessage } from "../../src/messages"; | ||
|
||
const m = getBoundMessage("en"); | ||
|
||
export const pattern: TestPattern = { | ||
description: | ||
"#JsSdkTest-14 Should able to create plugin with `create-kintone-plugin` command and all options", | ||
input: { | ||
command: CREATE_KINTONE_PLUGIN_COMMAND, | ||
outputDir: "test14", | ||
questionsInput: [ | ||
{ | ||
question: m("Q_NameEn"), | ||
answer: "test14-name", | ||
}, | ||
{ | ||
question: m("Q_DescriptionEn"), | ||
answer: "test14-description", | ||
}, | ||
{ | ||
question: m("Q_SupportJa"), | ||
answer: ANSWER_YES, | ||
}, | ||
{ | ||
question: m("Q_NameJa"), | ||
answer: "私のプラグイン", | ||
}, | ||
{ | ||
question: m("Q_DescriptionJa"), | ||
answer: "私のプラグイン", | ||
}, | ||
{ | ||
question: m("Q_SupportZh"), | ||
answer: ANSWER_YES, | ||
}, | ||
{ | ||
question: m("Q_NameZh"), | ||
answer: "我的插件", | ||
}, | ||
{ | ||
question: m("Q_DescriptionZh"), | ||
answer: "我的插件", | ||
}, | ||
{ | ||
question: m("Q_WebsiteUrlEn"), | ||
answer: "https://github.com", | ||
}, | ||
{ | ||
question: m("Q_WebsiteUrlJa"), | ||
answer: "https://github.jp", | ||
}, | ||
{ | ||
question: m("Q_WebsiteUrlZh"), | ||
answer: "https://github.cn", | ||
}, | ||
{ | ||
question: m("Q_MobileSupport"), | ||
answer: ANSWER_YES, | ||
}, | ||
{ | ||
question: m("Q_EnablePluginUploader"), | ||
answer: ANSWER_YES, | ||
}, | ||
], | ||
}, | ||
expected: { | ||
success: { | ||
manifestJson: { | ||
name: { | ||
en: "test14-name", | ||
ja: "私のプラグイン", | ||
zh: "我的插件", | ||
}, | ||
description: { | ||
en: "test14-description", | ||
ja: "私のプラグイン", | ||
zh: "我的插件", | ||
}, | ||
homepage_url: { | ||
en: "https://github.com", | ||
ja: "https://github.jp", | ||
zh: "https://github.cn", | ||
}, | ||
mobile: { | ||
js: ["js/mobile.js"], | ||
css: ["css/mobile.css"], | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import type { TestPattern } from "../e2e.test"; | ||
import { CREATE_PLUGIN_COMMAND } from "../utils/constants"; | ||
|
||
export const pattern: TestPattern = { | ||
description: | ||
"#JsSdkTest-9 Should throw an error when the output directory is empty", | ||
input: { | ||
command: CREATE_PLUGIN_COMMAND, | ||
outputDir: "", | ||
questionsInput: [], | ||
}, | ||
expected: { | ||
failure: { stderr: "Please specify the output directory" }, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import type { TestPattern } from "../e2e.test"; | ||
import { CREATE_PLUGIN_COMMAND } from "../utils/constants"; | ||
import fs from "fs"; | ||
|
||
const outputDir = "test10"; | ||
export const pattern: TestPattern = { | ||
description: | ||
"#JsSdkTest-10 Should throw an error when the output directory is duplicated with the existent directory", | ||
prepareFn: (settings: { workingDir: string }) => { | ||
fs.mkdirSync(`${settings.workingDir}/${outputDir}`); | ||
}, | ||
input: { | ||
command: CREATE_PLUGIN_COMMAND, | ||
outputDir: outputDir, | ||
questionsInput: [], | ||
}, | ||
expected: { | ||
failure: { | ||
stderr: `Error: ${outputDir} already exists. Choose a different directory`, | ||
}, | ||
}, | ||
}; |
58 changes: 58 additions & 0 deletions
58
packages/create-plugin/__e2e__/fixtures/pluginDescriptionContain200Chars.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import type { TestPattern } from "../e2e.test"; | ||
import { | ||
ANSWER_NO, | ||
CREATE_PLUGIN_COMMAND, | ||
DEFAULT_ANSWER, | ||
} from "../utils/constants"; | ||
import { getBoundMessage } from "../../src/messages"; | ||
import { generateRandomString } from "../utils/helper"; | ||
|
||
const m = getBoundMessage("en"); | ||
const pluginDescription = generateRandomString(200); | ||
|
||
export const pattern: TestPattern = { | ||
description: | ||
"#JsSdkTest-3 Should able to create a plugin with plugin-in description contains 200 characters", | ||
input: { | ||
command: CREATE_PLUGIN_COMMAND, | ||
outputDir: "test3", | ||
questionsInput: [ | ||
{ | ||
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, | ||
}, | ||
], | ||
}, | ||
expected: { | ||
success: { | ||
manifestJson: { | ||
name: { en: "200characters" }, | ||
description: { en: pluginDescription }, | ||
}, | ||
}, | ||
}, | ||
}; |
28 changes: 28 additions & 0 deletions
28
packages/create-plugin/__e2e__/fixtures/pluginDescriptionContain201Chars.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import type { TestPattern } from "../e2e.test"; | ||
import { CREATE_PLUGIN_COMMAND } from "../utils/constants"; | ||
import { generateRandomString } from "../utils/helper"; | ||
import { getBoundMessage } from "../../src/messages"; | ||
|
||
const m = getBoundMessage("en"); | ||
|
||
export const pattern: TestPattern = { | ||
description: | ||
"#JsSdkTest-13 Should throw an error when creating plugin with plugin-in description contains 201 characters", | ||
input: { | ||
command: CREATE_PLUGIN_COMMAND, | ||
outputDir: "test13", | ||
questionsInput: [ | ||
{ | ||
question: m("Q_NameEn"), | ||
answer: "test13", | ||
}, | ||
{ | ||
question: m("Q_DescriptionEn"), | ||
answer: generateRandomString(201), | ||
}, | ||
], | ||
}, | ||
expected: { | ||
failure: { stdout: ">> Plug-in description must be 1-200chars" }, | ||
}, | ||
}; |
58 changes: 58 additions & 0 deletions
58
packages/create-plugin/__e2e__/fixtures/pluginNameContain64Chars.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import type { TestPattern } from "../e2e.test"; | ||
import { | ||
ANSWER_NO, | ||
CREATE_PLUGIN_COMMAND, | ||
DEFAULT_ANSWER, | ||
} from "../utils/constants"; | ||
import { getBoundMessage } from "../../src/messages"; | ||
import { generateRandomString } from "../utils/helper"; | ||
|
||
const m = getBoundMessage("en"); | ||
const pluginName = generateRandomString(64); | ||
|
||
export const pattern: TestPattern = { | ||
description: | ||
"#JsSdkTest-2 Should able to create a plugin with plugin-in name contains 64 characters", | ||
input: { | ||
command: CREATE_PLUGIN_COMMAND, | ||
outputDir: "test2", | ||
questionsInput: [ | ||
{ | ||
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, | ||
}, | ||
], | ||
}, | ||
expected: { | ||
success: { | ||
manifestJson: { | ||
name: { en: pluginName }, | ||
description: { en: "64characters" }, | ||
}, | ||
}, | ||
}, | ||
}; |
24 changes: 24 additions & 0 deletions
24
packages/create-plugin/__e2e__/fixtures/pluginNameContain65Chars.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import type { TestPattern } from "../e2e.test"; | ||
import { CREATE_PLUGIN_COMMAND } from "../utils/constants"; | ||
import { generateRandomString } from "../utils/helper"; | ||
import { getBoundMessage } from "../../src/messages"; | ||
|
||
const m = getBoundMessage("en"); | ||
|
||
export const pattern: TestPattern = { | ||
description: | ||
"#JsSdkTest-12 Should throw an error when creating plugin with plugin-in name contains 65 characters", | ||
input: { | ||
command: CREATE_PLUGIN_COMMAND, | ||
outputDir: "test12", | ||
questionsInput: [ | ||
{ | ||
question: m("Q_NameEn"), | ||
answer: generateRandomString(65), | ||
}, | ||
], | ||
}, | ||
expected: { | ||
failure: { stdout: ">> Plug-in name must be 1-64chars" }, | ||
}, | ||
}; |
Oops, something went wrong.