Skip to content
Snippets Groups Projects
Commit 4aa6b96e authored by Robert Goldmann's avatar Robert Goldmann
Browse files

#533 - added integration tests

parent f4f4fca7
No related branches found
No related tags found
No related merge requests found
Pipeline #4070 failed
...@@ -4,7 +4,7 @@ import de.deadlocker8.budgetmaster.Main; ...@@ -4,7 +4,7 @@ import de.deadlocker8.budgetmaster.Main;
import de.deadlocker8.budgetmaster.authentication.UserService; import de.deadlocker8.budgetmaster.authentication.UserService;
import de.deadlocker8.budgetmaster.integration.helpers.IntegrationTestHelper; import de.deadlocker8.budgetmaster.integration.helpers.IntegrationTestHelper;
import de.deadlocker8.budgetmaster.integration.helpers.SeleniumTest; import de.deadlocker8.budgetmaster.integration.helpers.SeleniumTest;
import de.deadlocker8.budgetmaster.integration.helpers.TransactionTestHelper; import de.thecodelabs.utils.util.Localization;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
...@@ -13,6 +13,7 @@ import org.junit.rules.TestWatcher; ...@@ -13,6 +13,7 @@ import org.junit.rules.TestWatcher;
import org.junit.runner.Description; import org.junit.runner.Description;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.openqa.selenium.By; import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.firefox.FirefoxDriver;
...@@ -25,9 +26,7 @@ import org.springframework.test.annotation.DirtiesContext; ...@@ -25,9 +26,7 @@ import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
import java.io.File; import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date;
import java.util.List; import java.util.List;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
...@@ -130,4 +129,179 @@ public class NewTransactionFromTemplateTest ...@@ -130,4 +129,179 @@ public class NewTransactionFromTemplateTest
// assert // assert
assertThat(driver.findElement(By.className("buttonIncome")).getAttribute("class")).contains("budgetmaster-green"); assertThat(driver.findElement(By.className("buttonIncome")).getAttribute("class")).contains("budgetmaster-green");
} }
@Test
public void test_selectTemplateHotkeys_initialSelect()
{
driver.get(helper.getUrl() + "/templates");
WebDriverWait wait = new WebDriverWait(driver, 5);
wait.until(ExpectedConditions.textToBePresentInElementLocated(By.cssSelector(".headline"), "Templates"));
final List<WebElement> templateItemHeaders = driver.findElements(By.cssSelector(".template-item .collapsible-header"));
// assert
assertThat(templateItemHeaders).hasSize(2);
assertThat(templateItemHeaders.get(0).getAttribute("class")).contains("template-selected");
assertThat(templateItemHeaders.get(1).getAttribute("class")).doesNotContain("template-selected");
}
@Test
public void test_selectTemplateHotkeys_keyDown()
{
driver.get(helper.getUrl() + "/templates");
WebDriverWait wait = new WebDriverWait(driver, 5);
wait.until(ExpectedConditions.textToBePresentInElementLocated(By.cssSelector(".headline"), "Templates"));
final List<WebElement> templateItemHeaders = driver.findElements(By.cssSelector(".template-item .collapsible-header"));
assertThat(templateItemHeaders.get(0).getAttribute("class")).contains("template-selected");
assertThat(templateItemHeaders.get(1).getAttribute("class")).doesNotContain("template-selected");
driver.findElement(By.id("searchTemplate")).sendKeys(Keys.ARROW_DOWN);
assertThat(templateItemHeaders.get(0).getAttribute("class")).doesNotContain("template-selected");
assertThat(templateItemHeaders.get(1).getAttribute("class")).contains("template-selected");
}
@Test
public void test_selectTemplateHotkeys_keyDown_goBackToTopFromLastItem()
{
driver.get(helper.getUrl() + "/templates");
WebDriverWait wait = new WebDriverWait(driver, 5);
wait.until(ExpectedConditions.textToBePresentInElementLocated(By.cssSelector(".headline"), "Templates"));
final List<WebElement> templateItemHeaders = driver.findElements(By.cssSelector(".template-item .collapsible-header"));
assertThat(templateItemHeaders.get(0).getAttribute("class")).contains("template-selected");
assertThat(templateItemHeaders.get(1).getAttribute("class")).doesNotContain("template-selected");
driver.findElement(By.id("searchTemplate")).sendKeys(Keys.ARROW_DOWN);
driver.findElement(By.id("searchTemplate")).sendKeys(Keys.ARROW_DOWN);
assertThat(templateItemHeaders.get(0).getAttribute("class")).contains("template-selected");
assertThat(templateItemHeaders.get(1).getAttribute("class")).doesNotContain("template-selected");
}
@Test
public void test_selectTemplateHotkeys_keyUp_goBackToBottomFromFirstItem()
{
driver.get(helper.getUrl() + "/templates");
WebDriverWait wait = new WebDriverWait(driver, 5);
wait.until(ExpectedConditions.textToBePresentInElementLocated(By.cssSelector(".headline"), "Templates"));
final List<WebElement> templateItemHeaders = driver.findElements(By.cssSelector(".template-item .collapsible-header"));
assertThat(templateItemHeaders.get(0).getAttribute("class")).contains("template-selected");
assertThat(templateItemHeaders.get(1).getAttribute("class")).doesNotContain("template-selected");
driver.findElement(By.id("searchTemplate")).sendKeys(Keys.ARROW_UP);
assertThat(templateItemHeaders.get(0).getAttribute("class")).doesNotContain("template-selected");
assertThat(templateItemHeaders.get(1).getAttribute("class")).contains("template-selected");
}
@Test
public void test_selectTemplateHotkeys_keyUp()
{
driver.get(helper.getUrl() + "/templates");
WebDriverWait wait = new WebDriverWait(driver, 5);
wait.until(ExpectedConditions.textToBePresentInElementLocated(By.cssSelector(".headline"), "Templates"));
final List<WebElement> templateItemHeaders = driver.findElements(By.cssSelector(".template-item .collapsible-header"));
assertThat(templateItemHeaders.get(0).getAttribute("class")).contains("template-selected");
assertThat(templateItemHeaders.get(1).getAttribute("class")).doesNotContain("template-selected");
driver.findElement(By.id("searchTemplate")).sendKeys(Keys.ARROW_UP);
driver.findElement(By.id("searchTemplate")).sendKeys(Keys.ARROW_UP);
assertThat(templateItemHeaders.get(0).getAttribute("class")).contains("template-selected");
assertThat(templateItemHeaders.get(1).getAttribute("class")).doesNotContain("template-selected");
}
@Test
public void test_selectTemplateHotkeys_confirmSelection()
{
driver.get(helper.getUrl() + "/templates");
WebDriverWait wait = new WebDriverWait(driver, 5);
wait.until(ExpectedConditions.textToBePresentInElementLocated(By.cssSelector(".headline"), "Templates"));
final List<WebElement> templateItemHeaders = driver.findElements(By.cssSelector(".template-item .collapsible-header"));
assertThat(templateItemHeaders.get(0).getAttribute("class")).contains("template-selected");
assertThat(templateItemHeaders.get(1).getAttribute("class")).doesNotContain("template-selected");
driver.findElement(By.id("searchTemplate")).sendKeys(Keys.ENTER);
wait = new WebDriverWait(driver, 5);
wait.until(ExpectedConditions.textToBePresentInElementLocated(By.cssSelector(".headline"), "New Transaction"));
}
@Test
public void test_selectTemplateHotkeys_searchContainsSelection()
{
driver.get(helper.getUrl() + "/templates");
WebDriverWait wait = new WebDriverWait(driver, 5);
wait.until(ExpectedConditions.textToBePresentInElementLocated(By.cssSelector(".headline"), "Templates"));
driver.findElement(By.id("searchTemplate")).sendKeys(Keys.ARROW_DOWN);
List<WebElement> templateItemHeaders = driver.findElements(By.cssSelector(".template-item .collapsible-header"));
assertThat(templateItemHeaders.get(0).getAttribute("class")).doesNotContain("template-selected");
assertThat(templateItemHeaders.get(1).getAttribute("class")).contains("template-selected");
driver.findElement(By.id("searchTemplate")).sendKeys("emp");
// assert
templateItemHeaders = driver.findElements(By.cssSelector(".template-item .collapsible-header"));
assertThat(templateItemHeaders).hasSize(2);
assertThat(templateItemHeaders.get(0).getAttribute("class")).doesNotContain("template-selected");
assertThat(templateItemHeaders.get(1).getAttribute("class")).contains("template-selected");
}
@Test
public void test_selectTemplateHotkeys_searchNotContainsSelection()
{
driver.get(helper.getUrl() + "/templates");
WebDriverWait wait = new WebDriverWait(driver, 5);
wait.until(ExpectedConditions.textToBePresentInElementLocated(By.cssSelector(".headline"), "Templates"));
driver.findElement(By.id("searchTemplate")).sendKeys(Keys.ARROW_DOWN);
List<WebElement> templateItemHeaders = driver.findElements(By.cssSelector(".template-item .collapsible-header"));
assertThat(templateItemHeaders.get(0).getAttribute("class")).doesNotContain("template-selected");
assertThat(templateItemHeaders.get(1).getAttribute("class")).contains("template-selected");
driver.findElement(By.id("searchTemplate")).sendKeys("Income");
// assert
templateItemHeaders = driver.findElements(By.cssSelector(".template-item:not(.hidden) .collapsible-header"));
assertThat(templateItemHeaders).hasSize(1);
assertThat(templateItemHeaders.get(0).getAttribute("class")).contains("template-selected");
}
@Test
public void test_selectTemplateHotkeys_dontBlockEnterInGlobalSearch()
{
driver.get(helper.getUrl() + "/templates");
WebDriverWait wait = new WebDriverWait(driver, 5);
wait.until(ExpectedConditions.textToBePresentInElementLocated(By.cssSelector(".headline"), "Templates"));
WebElement inputSearch = driver.findElement(By.id("search"));
inputSearch.sendKeys("e");
inputSearch.sendKeys(Keys.ENTER);
wait = new WebDriverWait(driver, 5);
String expected = Localization.getString("menu.search.results", 24);
wait.until(ExpectedConditions.textToBePresentInElementLocated(By.cssSelector(".headline"), expected));
}
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment