Skip to content

Commit

Permalink
test(create-plugin): add test cases for JsSdkTest-10,11,12,13 (#2742)
Browse files Browse the repository at this point in the history
  • Loading branch information
hung-cybo authored May 7, 2024
1 parent 98b165e commit e884597
Show file tree
Hide file tree
Showing 13 changed files with 557 additions and 328 deletions.
428 changes: 102 additions & 326 deletions packages/create-plugin/__e2e__/e2e.test.ts

Large diffs are not rendered by default.

93 changes: 93 additions & 0 deletions packages/create-plugin/__e2e__/fixtures/allOptions.ts
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"],
},
},
},
},
};
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"],
},
},
},
},
};
15 changes: 15 additions & 0 deletions packages/create-plugin/__e2e__/fixtures/emptyOutputDir.ts
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" },
},
};
22 changes: 22 additions & 0 deletions packages/create-plugin/__e2e__/fixtures/existOutputDir.ts
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`,
},
},
};
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 },
},
},
},
};
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" },
},
};
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" },
},
},
},
};
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" },
},
};
Loading

0 comments on commit e884597

Please sign in to comment.