Skip to content

Commit

Permalink
test: add CliKintoneTest-109,110 (#610)
Browse files Browse the repository at this point in the history
  • Loading branch information
tuanphamcybozu authored Dec 6, 2023
1 parent 3489c47 commit 1d0b183
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
25 changes: 25 additions & 0 deletions features/export.feature
Original file line number Diff line number Diff line change
Expand Up @@ -387,3 +387,28 @@ Feature: cli-kintone export command
| * | \d+ | Alice | 10 |
| * | \d+ | Bob | 20 |
| * | \d+ | Jenny | 30 |

Scenario: CliKintoneTest-109 Should return the record contents when exporting the record with correct --guest-space-id specified
Given The app "app_in_guest_space" has no records
And The app "app_in_guest_space" has some records as below:
| Text | Number |
| Alice | 10 |
| Bob | 20 |
| Jenny | 30 |
And Load app ID of the app "app_in_guest_space" as env var: "APP_ID"
And Load guest space ID of the app "app_in_guest_space" as env var: "GUEST_SPACE_ID"
And Load app token of the app "app_in_guest_space" with exact permissions "view" as env var: "API_TOKEN"
When I run the command with args "record export --base-url $$TEST_KINTONE_BASE_URL --app $APP_ID --api-token $API_TOKEN --guest-space-id $GUEST_SPACE_ID"
Then I should get the exit code is zero
And The output message should match with the data below:
| Record_number | Text | Number |
| \d+ | Alice | 10 |
| \d+ | Bob | 20 |
| \d+ | Jenny | 30 |

Scenario: CliKintoneTest-110 Should return the error message when exporting the record with incorrect --guest-space-id
Given Load app ID of the app "app_in_guest_space" as env var: "APP_ID"
And Load app token of the app "app_in_guest_space" with exact permissions "view" as env var: "API_TOKEN"
When I run the command with args "record export --base-url $$TEST_KINTONE_BASE_URL --app $APP_ID --api-token $API_TOKEN --guest-space-id 9999999999999999999"
Then I should get the exit code is non-zero
And The output error message should match with the pattern: "\[403] \[CB_NO02] No privilege to proceed"
5 changes: 4 additions & 1 deletion features/step_definitions/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,10 @@ Given(
const apiToken = this.getAPITokenByAppAndPermissions(appKey, ["add"]);
const csvObject = this.replacePlaceholdersInRawDataTables(table.raw());
const tempFilePath = await this.generateCsvFile(csvObject);
const command = `record import --file-path ${tempFilePath} --app ${appCredential.appId} --base-url $$TEST_KINTONE_BASE_URL --api-token ${apiToken}`;
let command = `record import --file-path ${tempFilePath} --app ${appCredential.appId} --base-url $$TEST_KINTONE_BASE_URL --api-token ${apiToken}`;
if (appCredential.guestSpaceId && appCredential.guestSpaceId.length > 0) {
command += ` --guest-space-id ${appCredential.guestSpaceId}`;
}
this.execCliKintoneSync(command);
if (this.response.status !== 0) {
throw new Error(`Importing CSV failed. Error: \n${this.response.stderr}`);
Expand Down

0 comments on commit 1d0b183

Please sign in to comment.