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

#540 - added integration test for new hotkey

parent f7a3f3ad
No related branches found
No related tags found
No related merge requests found
Pipeline #3712 failed
......@@ -13,10 +13,13 @@ import org.junit.rules.TestWatcher;
import org.junit.runner.Description;
import org.junit.runner.RunWith;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxOptions;
import org.openqa.selenium.interactions.Action;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.springframework.boot.test.context.SpringBootTest;
......@@ -25,9 +28,7 @@ import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringRunner;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
......@@ -143,4 +144,63 @@ public class HotkeyTest
assertThat(driver.findElement(By.id("search"))).isEqualTo(driver.switchTo().activeElement());
}
@Test
public void hotkey_saveTransaction()
{
// open transactions page
driver.get(helper.getUrl() + "/transactions/newTransaction/normal");
// fill mandatory inputs
driver.findElement(By.id("transaction-name")).sendKeys("My Transaction");
driver.findElement(By.id("transaction-amount")).sendKeys("15.00");
final WebElement body = driver.findElement(By.tagName("body"));
Action seriesOfActions = new Actions(driver)
.moveToElement(body)
.keyDown(body, Keys.CONTROL)
.sendKeys(body, Keys.ENTER)
.keyUp(body, Keys.CONTROL)
.build();
seriesOfActions.perform();
WebDriverWait wait = new WebDriverWait(driver, 5);
wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(".headline-date")));
// assert
assertThat(driver.getCurrentUrl()).endsWith("/transactions");
List<WebElement> transactionsRows = driver.findElements(By.cssSelector(".transaction-container .hide-on-med-and-down.transaction-row-top"));
assertThat(transactionsRows).hasSize(2);
}
@Test
public void hotkey_saveTransaction_focusOnCategorySelect()
{
// open transactions page
driver.get(helper.getUrl() + "/transactions/newTransaction/normal");
// fill mandatory inputs
driver.findElement(By.id("transaction-name")).sendKeys("My Transaction");
driver.findElement(By.id("transaction-amount")).sendKeys("15.00");
TransactionTestHelper.selectCategory(driver, "sdfdsf");
final WebElement categoryWrapper = driver.findElement(By.id("categoryWrapper"));
Action seriesOfActions = new Actions(driver)
.moveToElement(categoryWrapper)
.keyDown(categoryWrapper, Keys.CONTROL)
.sendKeys(categoryWrapper, Keys.ENTER)
.keyUp(categoryWrapper, Keys.CONTROL)
.build();
seriesOfActions.perform();
WebDriverWait wait = new WebDriverWait(driver, 5);
wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(".headline-date")));
// assert
assertThat(driver.getCurrentUrl()).endsWith("/transactions");
List<WebElement> transactionsRows = driver.findElements(By.cssSelector(".transaction-container .hide-on-med-and-down.transaction-row-top"));
assertThat(transactionsRows).hasSize(2);
}
}
\ No newline at end of file
......@@ -48,7 +48,7 @@ public class TransactionTestHelper
public static void selectCategory(WebDriver driver, String categoryName)
{
WebElement categorySelect = driver.findElement(By.cssSelector("#categoryWrapper"));
WebElement categorySelect = driver.findElement(By.id("categoryWrapper"));
categorySelect.findElement(By.className("select-dropdown")).click();
WebElement categoryToSelect = categorySelect.findElement(By.xpath("//ul/li/span[text()='" + categoryName + "']"));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment