From 8355cc1f172da014fb905a914ab0cdfadf984d14 Mon Sep 17 00:00:00 2001 From: Robert Goldmann <deadlocker@gmx.de> Date: Sat, 21 Jan 2023 16:58:51 +0100 Subject: [PATCH] #724 - assert parse errors --- .../transactions/transactionImport.ftl | 4 +-- .../integration/selenium/CsvImportTest.java | 26 +++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/BudgetMasterServer/src/main/resources/templates/transactions/transactionImport.ftl b/BudgetMasterServer/src/main/resources/templates/transactions/transactionImport.ftl index f08232c7a..882c0b1fc 100644 --- a/BudgetMasterServer/src/main/resources/templates/transactions/transactionImport.ftl +++ b/BudgetMasterServer/src/main/resources/templates/transactions/transactionImport.ftl @@ -46,7 +46,7 @@ <#if csvTransactions??> <@renderCsvTransactions/> - <@showColumnSettingsErrors/> + <@showColumnSettingsErrors /> <#elseif csvRows?? > <div class="container"> <div class="section center-align"> @@ -294,7 +294,7 @@ <#macro showColumnSettingsErrors> <#if errorsColumnSettings?has_content> - <div class="container"> + <div class="container" id="parseErrors"> <div class="row"> <div class="col s12"> <ul class="collapsible"> diff --git a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/CsvImportTest.java b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/CsvImportTest.java index 2f54769b0..4b3fdd37d 100644 --- a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/CsvImportTest.java +++ b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/CsvImportTest.java @@ -252,6 +252,32 @@ class CsvImportTest extends SeleniumTestBase assertRow(row3, "blue", "2023-01-03", "No category", "Lorem", "Lorem", "50.00 €"); } + @Test + void test_upload_valid_parseErrors() + { + driver.get(helper.getUrl() + "/transactionImport"); + WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(5)); + wait.until(ExpectedConditions.textToBePresentInElementLocated(By.cssSelector(".headline"), "Import from bank CSV")); + + final String csvPath = new File(getClass().getClassLoader().getResource("csv/three_entries.csv").getFile()).getAbsolutePath(); + + // skip zero lines, so first line will lead to parse error because it is the row containing the column names + uploadCsv(csvPath, ";", "UTF-8", "0"); + wait = new WebDriverWait(driver, Duration.ofSeconds(5)); + wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("button-cancel-csv-import"))); + + assertThat(driver.findElement(By.id("csv-file-name")).getText()).isEqualTo("three_entries.csv"); + + fillColumnSettings(1, "dd.MM.yyyy", 2, 3, 2); + + wait = new WebDriverWait(driver, Duration.ofSeconds(5)); + wait.until(ExpectedConditions.invisibilityOfElementLocated(By.id("button-confirm-csv-column-settings"))); + + assertThat(driver.findElements(By.className("transaction-import-row"))).hasSize(3); + + assertThat(driver.findElements(By.cssSelector("#parseErrors table tr"))).hasSize(1); + } + @Test void test_cancel() { -- GitLab