Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(create-plugin): add test cases for JsSdkTest-2,3 #2739

Merged
merged 3 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 113 additions & 2 deletions packages/create-plugin/__e2e__/e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -44,15 +45,15 @@ describe("create-plugin", function () {
answer: DEFAULT_ANSWER,
},
{
question: m("Q_websiteUrlEn"),
question: m("Q_WebsiteUrlEn"),
answer: DEFAULT_ANSWER,
},
{
question: m("Q_MobileSupport"),
answer: ANSWER_NO,
},
{
question: m("Q_enablePluginUploader"),
question: m("Q_EnablePluginUploader"),
answer: ANSWER_NO,
},
];
Expand All @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions packages/create-plugin/src/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,23 @@ 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を入力してください (省略可)",
},
Q_MobileSupport: {
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を使いますか?",
},
Expand Down
8 changes: 4 additions & 4 deletions packages/create-plugin/src/qa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"),
},
];
};