Skip to content

Commit e884597

Browse files
authored
test(create-plugin): add test cases for JsSdkTest-10,11,12,13 (#2742)
1 parent 98b165e commit e884597

13 files changed

+557
-328
lines changed

Diff for: packages/create-plugin/__e2e__/e2e.test.ts

+102-326
Large diffs are not rendered by default.
+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
import type { TestPattern } from "../e2e.test";
2+
import { ANSWER_YES, CREATE_PLUGIN_COMMAND } from "../utils/constants";
3+
import { getBoundMessage } from "../../src/messages";
4+
5+
const m = getBoundMessage("en");
6+
7+
export const pattern: TestPattern = {
8+
description:
9+
"#JsSdkTest-4 Should able to create a plugin with specified output directory and all options successfully",
10+
input: {
11+
command: CREATE_PLUGIN_COMMAND,
12+
outputDir: "test4",
13+
questionsInput: [
14+
{
15+
question: m("Q_NameEn"),
16+
answer: "test4-name",
17+
},
18+
{
19+
question: m("Q_DescriptionEn"),
20+
answer: "test4-description",
21+
},
22+
{
23+
question: m("Q_SupportJa"),
24+
answer: ANSWER_YES,
25+
},
26+
{
27+
question: m("Q_NameJa"),
28+
answer: "私のプラグイン",
29+
},
30+
{
31+
question: m("Q_DescriptionJa"),
32+
answer: "私のプラグイン",
33+
},
34+
{
35+
question: m("Q_SupportZh"),
36+
answer: ANSWER_YES,
37+
},
38+
{
39+
question: m("Q_NameZh"),
40+
answer: "我的插件",
41+
},
42+
{
43+
question: m("Q_DescriptionZh"),
44+
answer: "我的插件",
45+
},
46+
{
47+
question: m("Q_WebsiteUrlEn"),
48+
answer: "https://github.com",
49+
},
50+
{
51+
question: m("Q_WebsiteUrlJa"),
52+
answer: "https://github.jp",
53+
},
54+
{
55+
question: m("Q_WebsiteUrlZh"),
56+
answer: "https://github.cn",
57+
},
58+
{
59+
question: m("Q_MobileSupport"),
60+
answer: ANSWER_YES,
61+
},
62+
{
63+
question: m("Q_EnablePluginUploader"),
64+
answer: ANSWER_YES,
65+
},
66+
],
67+
},
68+
expected: {
69+
success: {
70+
manifestJson: {
71+
name: {
72+
en: "test4-name",
73+
ja: "私のプラグイン",
74+
zh: "我的插件",
75+
},
76+
description: {
77+
en: "test4-description",
78+
ja: "私のプラグイン",
79+
zh: "我的插件",
80+
},
81+
homepage_url: {
82+
en: "https://github.com",
83+
ja: "https://github.jp",
84+
zh: "https://github.cn",
85+
},
86+
mobile: {
87+
js: ["js/mobile.js"],
88+
css: ["css/mobile.css"],
89+
},
90+
},
91+
},
92+
},
93+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
import type { TestPattern } from "../e2e.test";
2+
import { ANSWER_YES, CREATE_KINTONE_PLUGIN_COMMAND } from "../utils/constants";
3+
import { getBoundMessage } from "../../src/messages";
4+
5+
const m = getBoundMessage("en");
6+
7+
export const pattern: TestPattern = {
8+
description:
9+
"#JsSdkTest-14 Should able to create plugin with `create-kintone-plugin` command and all options",
10+
input: {
11+
command: CREATE_KINTONE_PLUGIN_COMMAND,
12+
outputDir: "test14",
13+
questionsInput: [
14+
{
15+
question: m("Q_NameEn"),
16+
answer: "test14-name",
17+
},
18+
{
19+
question: m("Q_DescriptionEn"),
20+
answer: "test14-description",
21+
},
22+
{
23+
question: m("Q_SupportJa"),
24+
answer: ANSWER_YES,
25+
},
26+
{
27+
question: m("Q_NameJa"),
28+
answer: "私のプラグイン",
29+
},
30+
{
31+
question: m("Q_DescriptionJa"),
32+
answer: "私のプラグイン",
33+
},
34+
{
35+
question: m("Q_SupportZh"),
36+
answer: ANSWER_YES,
37+
},
38+
{
39+
question: m("Q_NameZh"),
40+
answer: "我的插件",
41+
},
42+
{
43+
question: m("Q_DescriptionZh"),
44+
answer: "我的插件",
45+
},
46+
{
47+
question: m("Q_WebsiteUrlEn"),
48+
answer: "https://github.com",
49+
},
50+
{
51+
question: m("Q_WebsiteUrlJa"),
52+
answer: "https://github.jp",
53+
},
54+
{
55+
question: m("Q_WebsiteUrlZh"),
56+
answer: "https://github.cn",
57+
},
58+
{
59+
question: m("Q_MobileSupport"),
60+
answer: ANSWER_YES,
61+
},
62+
{
63+
question: m("Q_EnablePluginUploader"),
64+
answer: ANSWER_YES,
65+
},
66+
],
67+
},
68+
expected: {
69+
success: {
70+
manifestJson: {
71+
name: {
72+
en: "test14-name",
73+
ja: "私のプラグイン",
74+
zh: "我的插件",
75+
},
76+
description: {
77+
en: "test14-description",
78+
ja: "私のプラグイン",
79+
zh: "我的插件",
80+
},
81+
homepage_url: {
82+
en: "https://github.com",
83+
ja: "https://github.jp",
84+
zh: "https://github.cn",
85+
},
86+
mobile: {
87+
js: ["js/mobile.js"],
88+
css: ["css/mobile.css"],
89+
},
90+
},
91+
},
92+
},
93+
};
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import type { TestPattern } from "../e2e.test";
2+
import { CREATE_PLUGIN_COMMAND } from "../utils/constants";
3+
4+
export const pattern: TestPattern = {
5+
description:
6+
"#JsSdkTest-9 Should throw an error when the output directory is empty",
7+
input: {
8+
command: CREATE_PLUGIN_COMMAND,
9+
outputDir: "",
10+
questionsInput: [],
11+
},
12+
expected: {
13+
failure: { stderr: "Please specify the output directory" },
14+
},
15+
};
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import type { TestPattern } from "../e2e.test";
2+
import { CREATE_PLUGIN_COMMAND } from "../utils/constants";
3+
import fs from "fs";
4+
5+
const outputDir = "test10";
6+
export const pattern: TestPattern = {
7+
description:
8+
"#JsSdkTest-10 Should throw an error when the output directory is duplicated with the existent directory",
9+
prepareFn: (settings: { workingDir: string }) => {
10+
fs.mkdirSync(`${settings.workingDir}/${outputDir}`);
11+
},
12+
input: {
13+
command: CREATE_PLUGIN_COMMAND,
14+
outputDir: outputDir,
15+
questionsInput: [],
16+
},
17+
expected: {
18+
failure: {
19+
stderr: `Error: ${outputDir} already exists. Choose a different directory`,
20+
},
21+
},
22+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import type { TestPattern } from "../e2e.test";
2+
import {
3+
ANSWER_NO,
4+
CREATE_PLUGIN_COMMAND,
5+
DEFAULT_ANSWER,
6+
} from "../utils/constants";
7+
import { getBoundMessage } from "../../src/messages";
8+
import { generateRandomString } from "../utils/helper";
9+
10+
const m = getBoundMessage("en");
11+
const pluginDescription = generateRandomString(200);
12+
13+
export const pattern: TestPattern = {
14+
description:
15+
"#JsSdkTest-3 Should able to create a plugin with plugin-in description contains 200 characters",
16+
input: {
17+
command: CREATE_PLUGIN_COMMAND,
18+
outputDir: "test3",
19+
questionsInput: [
20+
{
21+
question: m("Q_NameEn"),
22+
answer: "200characters",
23+
},
24+
{
25+
question: m("Q_DescriptionEn"),
26+
answer: pluginDescription,
27+
},
28+
{
29+
question: m("Q_SupportJa"),
30+
answer: ANSWER_NO,
31+
},
32+
{
33+
question: m("Q_SupportZh"),
34+
answer: ANSWER_NO,
35+
},
36+
{
37+
question: m("Q_WebsiteUrlEn"),
38+
answer: DEFAULT_ANSWER,
39+
},
40+
{
41+
question: m("Q_MobileSupport"),
42+
answer: ANSWER_NO,
43+
},
44+
{
45+
question: m("Q_EnablePluginUploader"),
46+
answer: ANSWER_NO,
47+
},
48+
],
49+
},
50+
expected: {
51+
success: {
52+
manifestJson: {
53+
name: { en: "200characters" },
54+
description: { en: pluginDescription },
55+
},
56+
},
57+
},
58+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import type { TestPattern } from "../e2e.test";
2+
import { CREATE_PLUGIN_COMMAND } from "../utils/constants";
3+
import { generateRandomString } from "../utils/helper";
4+
import { getBoundMessage } from "../../src/messages";
5+
6+
const m = getBoundMessage("en");
7+
8+
export const pattern: TestPattern = {
9+
description:
10+
"#JsSdkTest-13 Should throw an error when creating plugin with plugin-in description contains 201 characters",
11+
input: {
12+
command: CREATE_PLUGIN_COMMAND,
13+
outputDir: "test13",
14+
questionsInput: [
15+
{
16+
question: m("Q_NameEn"),
17+
answer: "test13",
18+
},
19+
{
20+
question: m("Q_DescriptionEn"),
21+
answer: generateRandomString(201),
22+
},
23+
],
24+
},
25+
expected: {
26+
failure: { stdout: ">> Plug-in description must be 1-200chars" },
27+
},
28+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import type { TestPattern } from "../e2e.test";
2+
import {
3+
ANSWER_NO,
4+
CREATE_PLUGIN_COMMAND,
5+
DEFAULT_ANSWER,
6+
} from "../utils/constants";
7+
import { getBoundMessage } from "../../src/messages";
8+
import { generateRandomString } from "../utils/helper";
9+
10+
const m = getBoundMessage("en");
11+
const pluginName = generateRandomString(64);
12+
13+
export const pattern: TestPattern = {
14+
description:
15+
"#JsSdkTest-2 Should able to create a plugin with plugin-in name contains 64 characters",
16+
input: {
17+
command: CREATE_PLUGIN_COMMAND,
18+
outputDir: "test2",
19+
questionsInput: [
20+
{
21+
question: m("Q_NameEn"),
22+
answer: pluginName,
23+
},
24+
{
25+
question: m("Q_DescriptionEn"),
26+
answer: "64characters",
27+
},
28+
{
29+
question: m("Q_SupportJa"),
30+
answer: ANSWER_NO,
31+
},
32+
{
33+
question: m("Q_SupportZh"),
34+
answer: ANSWER_NO,
35+
},
36+
{
37+
question: m("Q_WebsiteUrlEn"),
38+
answer: DEFAULT_ANSWER,
39+
},
40+
{
41+
question: m("Q_MobileSupport"),
42+
answer: ANSWER_NO,
43+
},
44+
{
45+
question: m("Q_EnablePluginUploader"),
46+
answer: ANSWER_NO,
47+
},
48+
],
49+
},
50+
expected: {
51+
success: {
52+
manifestJson: {
53+
name: { en: pluginName },
54+
description: { en: "64characters" },
55+
},
56+
},
57+
},
58+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import type { TestPattern } from "../e2e.test";
2+
import { CREATE_PLUGIN_COMMAND } from "../utils/constants";
3+
import { generateRandomString } from "../utils/helper";
4+
import { getBoundMessage } from "../../src/messages";
5+
6+
const m = getBoundMessage("en");
7+
8+
export const pattern: TestPattern = {
9+
description:
10+
"#JsSdkTest-12 Should throw an error when creating plugin with plugin-in name contains 65 characters",
11+
input: {
12+
command: CREATE_PLUGIN_COMMAND,
13+
outputDir: "test12",
14+
questionsInput: [
15+
{
16+
question: m("Q_NameEn"),
17+
answer: generateRandomString(65),
18+
},
19+
],
20+
},
21+
expected: {
22+
failure: { stdout: ">> Plug-in name must be 1-64chars" },
23+
},
24+
};

0 commit comments

Comments
 (0)