Skip to content

Commit

Permalink
test: E2E test files rearrangement and update common test scenarios (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
hisasami authored Dec 18, 2024
1 parent e312831 commit e86a315
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 30 deletions.
37 changes: 19 additions & 18 deletions features/common.feature → features/record/common.feature
Original file line number Diff line number Diff line change
@@ -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) <command>"

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
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -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}",
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
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";
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));
Expand Down
Original file line number Diff line number Diff line change
@@ -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:",
Expand Down

0 comments on commit e86a315

Please sign in to comment.