diff --git a/features/common.feature b/features/record/common.feature similarity index 73% rename from features/common.feature rename to features/record/common.feature index 2253507bbf..b0aa753f2e 100644 --- a/features/common.feature +++ b/features/record/common.feature @@ -1,89 +1,90 @@ -Feature: cli-kintone common test cases +@common +Feature: common - Scenario: CliKintoneTest-1 Should return the error message when specifying unknown option + Scenario: Unknown option When I run the command with args "record export --app 1 --base-url http://example.com --foo" Then I should get the exit code is non-zero And The output error message should match with the pattern: "Unknown argument: foo" - Scenario: CliKintoneTest-2 Should return the error message when specifying unknown subcommand + Scenario: Unknown subcommand When I run the command with args "foo" Then I should get the exit code is non-zero And The output error message should match with the pattern: "Unknown argument: foo" - Scenario: CliKintoneTest-3 Should return the cli-kintone version in correct format when using `cli-kintone --version` + Scenario: Get version When I run the command with args "--version" Then I should get the version formatted in "\d+.\d+.\d+" - Scenario: CliKintoneTest-4 Should return the help description by --help + Scenario: Get help When I run the command with args "--help" Then I should get the exit code is zero And The output message should match with the pattern: "cli-kintone-(macos|win\.exe|linux) " - Scenario: CliKintoneTest-5 Should return the error message when lacking of --base-url option + Scenario: Base URL is not specified When I run the command with args "record export --app 1" Then I should get the exit code is non-zero And The output error message should match with the pattern: "Missing required argument: base-url" - Scenario: CliKintoneTest-6 Should return the error message when the baseUrl is non-existent subdomain + Scenario: URL does not exist When I run the command with args "record export --base-url https://CED2-4782-BB99-1ED18B89E0DA.cybozu.com --app 1 --api-token abc" Then I should get the exit code is non-zero And The output error message should match with the pattern: "404: Not Found" - Scenario: CliKintoneTest-8 Should return the error message when the protocol of baseUrl is not HTTPS + Scenario: URL protocol is not HTTPS When I run the command with args "record export --base-url http://example.cybozu.com --app 1 --api-token abc" Then I should get the exit code is non-zero And The output error message should match with the pattern: "Error: The protocol of baseUrl must be \"https\"." - Scenario: CliKintoneTest-9 Should return the error message when the baseUrl is not URL format + Scenario: Invalid URL format When I run the command with args "record export --base-url foo --app 1 --api-token abc" Then I should get the exit code is non-zero And The output error message should match with the pattern: "ERROR: TypeError \[ERR_INVALID_URL]: Invalid URL" - Scenario: CliKintoneTest-10 Should return the error message when lacking of --app option + Scenario: No app option When I run the command with args "record export --base-url http://example.com" Then I should get the exit code is non-zero And The output error message should match with the pattern: "Missing required argument: app" - Scenario: CliKintoneTest-11 Should return the error message when lacking the value of --app option + Scenario: App is not specified When I run the command with args "record export --base-url http://example.com --app" Then I should get the exit code is non-zero And The output error message should match with the pattern: "Not enough arguments following: app" - Scenario: CliKintoneTest-12 Should return the error message when the app doesn't exist + Scenario: App does not exist Given Load username and password of user "user_for_common" as env vars: "USERNAME" and "PASSWORD" When I run the command with args "record export --base-url $$TEST_KINTONE_BASE_URL --app 1 --username $USERNAME --password $PASSWORD" Then I should get the exit code is non-zero And The output error message should match with the pattern: "\[404] \[GAIA_AP01] The app \(ID: 1\) not found. The app may have been deleted." - Scenario: CliKintoneTest-13 Should return the error message when missing the --guest-space-id option and the app is in a guest space. + Scenario: App in guest space is specified without guest space ID Given Load app ID of the app "app_in_guest_space" as env var: "APP_ID" And Load username and password of user "user_for_guest_space" as env vars: "USERNAME" and "PASSWORD" When I run the command with args "record export --base-url $$TEST_KINTONE_BASE_URL --app $APP_ID --username $USERNAME --password $PASSWORD" Then I should get the exit code is non-zero And The output error message should match with the pattern: "ERROR: Please specify --guest-space-id option to access an App in Guest Spaces." - Scenario: CliKintoneTest-14 Should return the error message when no authorized information + Scenario: No authorization information When I run the command with args "record export --base-url $$TEST_KINTONE_BASE_URL --app 1" Then I should get the exit code is non-zero And The output error message should match with the pattern: "\[401\] \[CB_AU01\] Please login." - Scenario: CliKintoneTest-15 Should return the error message when the API token is incorrect + Scenario: Incorrect API token When I run the command with args "record export --base-url $$TEST_KINTONE_BASE_URL --app 1 --api-token abc" Then I should get the exit code is non-zero And The output error message should match with the pattern: "\[400\] \[GAIA_IA02\] The specified API token does not match the API token generated via an app." - Scenario: CliKintoneTest-17 Should return the error message when the user information is incorrect + Scenario: Incorrect username When I run the command with args "record export --base-url $$TEST_KINTONE_BASE_URL --app 1 --username abc --password abc" Then I should get the exit code is non-zero And The output error message should match with the pattern: "\[401\] \[CB_WA01\] Password authentication failed." - Scenario: CliKintoneTest-18 Should return the error message when authorization information is incomplete (password) + Scenario: Password is not specified Given Load username and password of user "user_for_common" as env vars: "USERNAME" and "PASSWORD" When I run the command with args "record export --base-url $$TEST_KINTONE_BASE_URL --app 1 --username $USERNAME" Then I should get the exit code is non-zero And The output error message should match with the pattern: "\[401\] \[CB_WA01\] Password authentication failed." - Scenario: CliKintoneTest-19 Should return the error message when incorrect authorization information (password) + Scenario: Incorrect password Given Load username and password of user "user_for_common" as env vars: "USERNAME" and "PASSWORD" When I run the command with args "record export --base-url $$TEST_KINTONE_BASE_URL --app 1 --username $USERNAME --password abc" Then I should get the exit code is non-zero diff --git a/features/delete.feature b/features/record/delete.feature similarity index 100% rename from features/delete.feature rename to features/record/delete.feature diff --git a/features/export.feature b/features/record/export.feature similarity index 100% rename from features/export.feature rename to features/record/export.feature diff --git a/features/import.feature b/features/record/import.feature similarity index 100% rename from features/import.feature rename to features/record/import.feature diff --git a/features/step_definitions/common.ts b/features/step_definitions/record/common.ts similarity index 96% rename from features/step_definitions/common.ts rename to features/step_definitions/record/common.ts index 2e5c3e6b45..871ea05af3 100644 --- a/features/step_definitions/common.ts +++ b/features/step_definitions/record/common.ts @@ -1,9 +1,9 @@ import * as assert from "assert"; -import { Given, When, Then } from "../utils/world"; -import type { Permission } from "../utils/credentials"; -import { TOKEN_PERMISSIONS } from "../utils/credentials"; -import { generateCsvRow } from "../utils/helper"; -import { QueryBuilder } from "../utils/queryBuilder"; +import { Given, When, Then } from "../../utils/world"; +import type { Permission } from "../../utils/credentials"; +import { TOKEN_PERMISSIONS } from "../../utils/credentials"; +import { generateCsvRow } from "../../utils/helper"; +import { QueryBuilder } from "../../utils/queryBuilder"; Given( "Load environment variable {string} as {string}", diff --git a/features/step_definitions/delete.ts b/features/step_definitions/record/delete.ts similarity index 92% rename from features/step_definitions/delete.ts rename to features/step_definitions/record/delete.ts index 93c05e12b4..3521da19ae 100644 --- a/features/step_definitions/delete.ts +++ b/features/step_definitions/record/delete.ts @@ -1,5 +1,5 @@ import * as assert from "assert"; -import { Then } from "../utils/world"; +import { Then } from "../../utils/world"; Then("The app {string} should have no records", function (appKey) { const recordNumbers = this.getRecordNumbersByAppKey(appKey); diff --git a/features/step_definitions/export.ts b/features/step_definitions/record/export.ts similarity index 98% rename from features/step_definitions/export.ts rename to features/step_definitions/record/export.ts index 988f2eec3b..31099107a5 100644 --- a/features/step_definitions/export.ts +++ b/features/step_definitions/record/export.ts @@ -1,5 +1,5 @@ import * as assert from "assert"; -import { Given, Then } from "../utils/world"; +import { Given, Then } from "../../utils/world"; import fs from "fs"; import path from "path"; import iconv from "iconv-lite"; @@ -7,7 +7,7 @@ import { compareBuffers, generateCsvRow, validateRequireColumnsInTable, -} from "../utils/helper"; +} from "../../utils/helper"; Given("I have a directory {string}", function (directory: string) { fs.mkdirSync(path.join(this.workingDir, directory)); diff --git a/features/step_definitions/import.ts b/features/step_definitions/record/import.ts similarity index 95% rename from features/step_definitions/import.ts rename to features/step_definitions/record/import.ts index 271d5b9a1f..b556947e96 100644 --- a/features/step_definitions/import.ts +++ b/features/step_definitions/record/import.ts @@ -1,10 +1,10 @@ import * as assert from "assert"; -import { Given, Then } from "../utils/world"; +import { Given, Then } from "../../utils/world"; import fs from "fs"; -import type { SupportedEncoding } from "../utils/helper"; -import { SUPPORTED_ENCODING, generateCsvRow } from "../utils/helper"; +import type { SupportedEncoding } from "../../utils/helper"; +import { SUPPORTED_ENCODING, generateCsvRow } from "../../utils/helper"; import path from "path"; -import { QueryBuilder } from "../utils/queryBuilder"; +import { QueryBuilder } from "../../utils/queryBuilder"; Given( "The CSV file {string} with content as below:",