Skip to content

Commit

Permalink
test(Integration): extends csv import test data
Browse files Browse the repository at this point in the history
Signed-off-by: Arthur Schiwon <[email protected]>
  • Loading branch information
blizzz committed Nov 8, 2024
1 parent 4832c02 commit 0a6b3c7
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 16 deletions.
34 changes: 18 additions & 16 deletions tests/integration/features/APIv1.feature
Original file line number Diff line number Diff line change
Expand Up @@ -188,30 +188,32 @@ Feature: APIv1
Then user "participant1" deletes table with keyword "Rows check"


@api1
@api1 @import
Scenario: Import csv table
Given file "/import.csv" exists for user "participant1" with following data
| Col1 | Col2 | Col3 | num | emoji | special |
| Val1 | Val2 | Val3 | 1 | 💙 | Ä |
| great | news | here | 99 | ⚠️ | Ö |
| Col1 | Col2 | Col3 | num | emoji | special | date | truth |
| Val1 | Val2 | Val3 | 1 | 💙 | Ä | 2024-02-24 | false |
| great | news | here | 99 | ⚠️ | Ö | 2016-06-01 | true |
Given table "Import test" with emoji "👨🏻‍💻" exists for user "participant1" as "base1"
When user imports file "/import.csv" into last created table
Then import results have the following data
| found_columns_count | 6 |
| created_columns_count | 6 |
| found_columns_count | 8 |
| created_columns_count | 8 |
| inserted_rows_count | 2 |
| errors_count | 0 |
Then table has at least following columns
| Col1 |
| Col2 |
| Col3 |
| num |
| emoji |
| special |
Then table has at least following typed columns
| Col1 | text |
| Col2 | text |
| Col3 | text |
| num | number |
| emoji | text |
| special | text |
| date | datetime |
| truth | selection |
Then table contains at least following rows
| Col1 | Col2 | Col3 | num | emoji | special |
| Val1 | Val2 | Val3 | 1 | 💙 | Ä |
| great | news | here | 99 | ⚠️ | Ö |
| Col1 | Col2 | Col3 | num | emoji | special | date | truth |
| Val1 | Val2 | Val3 | 1 | 💙 | Ä | 2024-02-24 | false |
| great | news | here | 99 | ⚠️ | Ö | 2016-06-01 | true |

@api1
Scenario: Create, edit and delete views
Expand Down
30 changes: 30 additions & 0 deletions tests/integration/features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -1190,6 +1190,36 @@ public function tableColumns(?TableNode $body = null): void {
}
}

/**
* @Then table has at least following typed columns
*
* @param TableNode|null $body
*/
public function tableTypedColumns(?TableNode $body = null): void {
$this->sendRequest(
'GET',
'/apps/tables/api/1/tables/'.$this->tableId.'/columns'
);

$data = $this->getDataFromResponse($this->response);
Assert::assertEquals(200, $this->response->getStatusCode());

// check if no columns exists
if ($body === null) {
Assert::assertCount(0, $data);
return;
}

$colByTitle = [];
foreach ($data as $d) {
$colByTitle[$d['title']] = $d['type'];
}
foreach ($body->getRows() as $columnData) {
Assert::assertArrayHasKey($columnData[0], $colByTitle);
Assert::assertSame($columnData[1], $colByTitle[$columnData[0]], sprintf('Column "%s" has unexpected type "%s"', $columnData[0], $colByTitle[$columnData[0]]));
}
}

/**
* @Then user deletes last created column
*/
Expand Down

0 comments on commit 0a6b3c7

Please sign in to comment.