From 9a34c6b6cc47b3b0eb1daa96c34c1ed0c90dc3b6 Mon Sep 17 00:00:00 2001 From: Valery Yatsynovich Date: Fri, 21 Jun 2024 14:04:16 +0300 Subject: [PATCH] [tests] Extend test coverage of Excel features (#5145) --- .../{ExcelSteps.story => Excel.story} | 49 ++++++++++++++++--- .../story/integration/TableTransformers.story | 37 -------------- .../main/resources/story/system/Excel.story | 45 +++++++++++++++++ 3 files changed, 88 insertions(+), 43 deletions(-) rename vividus-tests/src/main/resources/story/integration/{ExcelSteps.story => Excel.story} (51%) create mode 100644 vividus-tests/src/main/resources/story/system/Excel.story diff --git a/vividus-tests/src/main/resources/story/integration/ExcelSteps.story b/vividus-tests/src/main/resources/story/integration/Excel.story similarity index 51% rename from vividus-tests/src/main/resources/story/integration/ExcelSteps.story rename to vividus-tests/src/main/resources/story/integration/Excel.story index f550f703f1..950267ad36 100644 --- a/vividus-tests/src/main/resources/story/integration/ExcelSteps.story +++ b/vividus-tests/src/main/resources/story/integration/Excel.story @@ -5,9 +5,9 @@ Lifecycle: Before: Scope: STORY When I execute HTTP GET request for resource with URL `https://github.com/vividus-framework/vividus/blob/master/vividus-plugin-excel/src/test/resources/TestTemplate.xlsx?raw=true` -Then response code is = `200` +Then response code is equal to `200` -Scenario: Step verification 'Then `$excelDocument` contains excel sheet with index `$index` and records:$records' +Scenario: Validate step 'Then `$excelDocument` contains excel sheet with index `$index` and records:$records' Then `${response-as-bytes}` contains excel sheet with index `0` and records: {valueSeparator=!} |cellsRange|valueRegex | @@ -15,7 +15,7 @@ Then `${response-as-bytes}` contains excel sheet with index `0` and records: !B3 !Price ! !C1:C5 ! ! -Scenario: Validate variable initialization with binary data and step verification 'Then `$excelDocument` contains excel sheet with name `$name` and records:$records' +Scenario: Validate variable initialization with binary data and step 'Then `$excelDocument` contains excel sheet with name `$name` and records:$records' Given I initialize scenario variable `excel` with value `${response-as-bytes}` Then `${excel}` contains excel sheet with name `Mapping` and records: {valueSeparator=!} @@ -24,14 +24,14 @@ Then `${excel}` contains excel sheet with name `Mapping` and records: !B3 !Price ! !C1:C5 ! ! -Scenario: Verification cell formatting preserving +Scenario: Validate cell formatting is preserved Given I initialize scenario variable `excel` with value `${response-as-bytes}` Then `${excel}` contains excel sheet with name `AsString` and records: |cellsRange |valueRegex | |A1 |TRUE | |B3 |3 | -Scenario: Verification of step 'When I create temporary excel file with content:$content and put path to $scopes variable `$variableName`' and transformer FROM_EXCEL +Scenario: Validate step 'When I create temporary excel file with content:$content and put path to $scopes variable `$variableName`' and transformer FROM_EXCEL Meta: @requirementId 1028, 2953 @feature table-transformers @@ -47,7 +47,7 @@ When I initialize scenario variable `excel-data` with values: Then `${excel-data}` is equal to table: {transformer=FROM_EXCEL, path=$\{path\}, sheet=Sheet0, range=A1:B2} -Scenario: Steps verification 'When I create temporary excel file containing sheet with name `$sheetName` and content:$content and put its path to $scopes variable `$variableName`' and 'When I add sheet with name `$sheetName` and content $content to excel file at path `$path`' +Scenario: Validate steps 'When I create temporary excel file containing sheet with name `$sheetName` and content:$content and put its path to $scopes variable `$variableName`' and 'When I add sheet with name `$sheetName` and content $content to excel file at path `$path`' Meta: @requirementId 2953 When I create temporary excel file containing sheet with name `my-sheet-name` and content: @@ -74,3 +74,40 @@ Then `${excel-data}` is equal to table: {transformer=FROM_EXCEL, path=$\{path\}, sheet=my-sheet-name, range=A1:B2} Then `${added-sheet-excel-data}` is equal to table: {transformer=FROM_EXCEL, path=$\{path\}, sheet=added-sheet, range=A1:B4} + +Scenario: Validate FROM_EXCEL transformer +Meta: + @issueId 647 +Then `` is equal to `line 1 line 2 line 3` +Examples: +{transformer=FROM_EXCEL, path=/data/excel.xlsx, sheet=Sheet1, addresses=A1, column=joined, \{lineBreakReplacement|VERBATIM\}= } + +Scenario: Check loading excel table with different data types using FROM_EXCEL transformer +Meta: + @issueId 2908 +When I initialize scenario variable `expectedTable` with values: +|StringValue|NumericValue|BooleanValue|FormulaValue|FormulaErrorValue| +|City |17 |FALSE |289 |#VALUE! | +Then `${expectedTable}` is equal to table: +{transformer=FROM_EXCEL, path=/data/excel.xlsx, sheet=DifferentTypes, range=A1:E2} + +Scenario: Check FROM_EXCEL transformer with multiple ranges (separate ranges for header and data) +Meta: + @issueId 5084 +When I initialize scenario variable `expectedTable` with values: +|StringValue |NumericValue |BooleanValue |FormulaValue | +|Timezone |21 |FALSE |441 | +|City |17 |FALSE |289 | +|Country |19 |TRUE |361 | +Then `${expectedTable}` is equal to table: +{transformer=FROM_EXCEL, path=/data/excel.xlsx, sheet=DifferentTypes, range=A1:D1;A4:D4;A2:D3;} + +Scenario: Check FROM_EXCEL transformer with multiple ranges (separate ranges for header with data and additional data) +Meta: + @issueId 5084 +When I initialize scenario variable `expectedTable` with values: +|NumericValue |BooleanValue |FormulaValue | +|17 |FALSE |289 | +|19 |TRUE |361 | +Then `${expectedTable}` is equal to table: +{transformer=FROM_EXCEL, path=/data/excel.xlsx, sheet=DifferentTypes, range=B1:D2;B3:D3} diff --git a/vividus-tests/src/main/resources/story/integration/TableTransformers.story b/vividus-tests/src/main/resources/story/integration/TableTransformers.story index 7c1f862471..66e4df5ff5 100644 --- a/vividus-tests/src/main/resources/story/integration/TableTransformers.story +++ b/vividus-tests/src/main/resources/story/integration/TableTransformers.story @@ -146,43 +146,6 @@ Examples: |jhbdahjabw | |738162378613896 | -Scenario: Verify FROM_EXCEL transformer -Meta: - @issueId 647 -Then `` is equal to `line 1 line 2 line 3` -Examples: -{transformer=FROM_EXCEL, path=/data/excel.xlsx, sheet=Sheet1, addresses=A1, column=joined, \{lineBreakReplacement|VERBATIM\}= } - -Scenario: Check loading excel table with different data types using FROM_EXCEL transformer -Meta: - @issueId 2908 -When I initialize scenario variable `expectedTable` with values: -|StringValue|NumericValue|BooleanValue|FormulaValue|FormulaErrorValue| -|City |17 |FALSE |289 |#VALUE! | -Then `${expectedTable}` is equal to table: -{transformer=FROM_EXCEL, path=/data/excel.xlsx, sheet=DifferentTypes, range=A1:E2} - -Scenario: Check FROM_EXCEL transformer with multiply ranges (separate ranges for header and data) -Meta: - @issueId 5084 -When I initialize scenario variable `expectedTable` with values: -|StringValue |NumericValue |BooleanValue |FormulaValue | -|Timezone |21 |FALSE |441 | -|City |17 |FALSE |289 | -|Country |19 |TRUE |361 | -Then `${expectedTable}` is equal to table: -{transformer=FROM_EXCEL, path=/data/excel.xlsx, sheet=DifferentTypes, range=A1:D1;A4:D4;A2:D3;} - -Scenario: Check FROM_EXCEL transformer with multiply ranges (separate ranges for header with data and additional data) -Meta: - @issueId 5084 -When I initialize scenario variable `expectedTable` with values: -|NumericValue |BooleanValue |FormulaValue | -|17 |FALSE |289 | -|19 |TRUE |361 | -Then `${expectedTable}` is equal to table: -{transformer=FROM_EXCEL, path=/data/excel.xlsx, sheet=DifferentTypes, range=B1:D2;B3:D3} - Scenario: Verify ExamplesTable property value with space Meta: @issueId 767 diff --git a/vividus-tests/src/main/resources/story/system/Excel.story b/vividus-tests/src/main/resources/story/system/Excel.story new file mode 100644 index 0000000000..c0e4e68c89 --- /dev/null +++ b/vividus-tests/src/main/resources/story/system/Excel.story @@ -0,0 +1,45 @@ +Meta: + @epic vividus-plugin-excel + +Lifecycle: +Before: +Scope: STORY +When I execute HTTP GET request for resource with URL `https://github.com/vividus-framework/vividus/blob/master/vividus-plugin-excel/src/test/resources/TestTemplate.xlsx?raw=true` +Then response code is equal to `200` + +Scenario: Validate cell formatting is not preserved +Given I initialize scenario variable `excel` with value `${response-as-bytes}` +Then `${excel}` contains excel sheet with name `AsString` and records: +|cellsRange |valueRegex | +|A1 |true | +|B3 |3\.0 | + +Scenario: Check loading excel table with different data types using FROM_EXCEL transformer - without preserving cell formatting +Meta: + @issueId 2908 +When I initialize scenario variable `expectedTable` with values: +|StringValue|NumericValue|BooleanValue|FormulaValue|FormulaErrorValue| +|City |17.0 |false |289.0 | | +Then `${expectedTable}` is equal to table: +{transformer=FROM_EXCEL, path=/data/excel.xlsx, sheet=DifferentTypes, range=A1:E2} + +Scenario: Check FROM_EXCEL transformer with multiple ranges (separate ranges for header and data) - without preserving cell formatting +Meta: + @issueId 5084 +When I initialize scenario variable `expectedTable` with values: +|StringValue |NumericValue |BooleanValue |FormulaValue | +|Timezone |21.0 |false |441.0 | +|City |17.0 |false |289.0 | +|Country |19.0 |true |361.0 | +Then `${expectedTable}` is equal to table: +{transformer=FROM_EXCEL, path=/data/excel.xlsx, sheet=DifferentTypes, range=A1:D1;A4:D4;A2:D3;} + +Scenario: Check FROM_EXCEL transformer with multiple ranges (separate ranges for header with data and additional data) - without preserving cell formatting +Meta: + @issueId 5084 +When I initialize scenario variable `expectedTable` with values: +|NumericValue |BooleanValue |FormulaValue | +|17.0 |false |289.0 | +|19.0 |true |361.0 | +Then `${expectedTable}` is equal to table: +{transformer=FROM_EXCEL, path=/data/excel.xlsx, sheet=DifferentTypes, range=B1:D2;B3:D3}