#103 add tests for deadline
This commit is contained in:
parent
47131f1fb7
commit
0cd8003dd7
@ -49,7 +49,7 @@
|
||||
<div class="form-group">
|
||||
<label>Дедлайны показателей:</label>
|
||||
<input type="hidden" th:field="*{removedDeadlineIds}"/>
|
||||
<div class="row" th:each="deadline, rowStat : *{deadlines}">
|
||||
<div class="row" id="deadlines" th:each="deadline, rowStat : *{deadlines}">
|
||||
<input type="hidden" th:field="*{deadlines[__${rowStat.index}__].id}"/>
|
||||
<div class="col-6 div-deadline-date">
|
||||
<input type="date" class="form-control form-deadline-date" name="deadline"
|
||||
|
@ -117,4 +117,56 @@ public class IndexGrantTest extends TestTemplate {
|
||||
|
||||
Assert.assertEquals(oldCountPapers - 1, grantPage.deletePaper().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addDeadline() {
|
||||
Map.Entry<PageObject, List<String>> page = Iterables.get(navigationHolder.entrySet(), 0);
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
|
||||
GrantsPage grantsPage = (GrantsPage) getContext().initPage(page.getKey());
|
||||
GrantPage grantPage = (GrantPage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 1).getKey());
|
||||
|
||||
grantsPage.getFirstGrant();
|
||||
String grantId = grantPage.getId();
|
||||
Integer deadlineCount = grantPage.getDeadlineCount();
|
||||
|
||||
String description = "deadline test";
|
||||
String date = "09.09.2019";
|
||||
String dateValue = "2019-09-09";
|
||||
grantPage.addDeadline();
|
||||
grantPage.setDeadline(date, deadlineCount, description);
|
||||
grantPage.saveGrant();
|
||||
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + String.format("/grants/grant?id=%s", grantId));
|
||||
|
||||
Assert.assertTrue(grantPage.checkDeadline(description, dateValue));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deleteDeadline() {
|
||||
Map.Entry<PageObject, List<String>> page = Iterables.get(navigationHolder.entrySet(), 0);
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
|
||||
GrantsPage grantsPage = (GrantsPage) getContext().initPage(page.getKey());
|
||||
GrantPage grantPage = (GrantPage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 1).getKey());
|
||||
|
||||
grantsPage.getFirstGrant();
|
||||
String grantId = grantPage.getId();
|
||||
Integer deadlineCount = grantPage.getDeadlineCount();
|
||||
|
||||
String description = "deadline test";
|
||||
String date = "09.09.2019";
|
||||
String dateValue = "2019-09-09";
|
||||
grantPage.addDeadline();
|
||||
grantPage.setDeadline(date, deadlineCount, description);
|
||||
grantPage.saveGrant();
|
||||
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + String.format("/grants/grant?id=%s", grantId));
|
||||
deadlineCount = grantPage.getDeadlineCount();
|
||||
|
||||
grantPage.deleteDeadline();
|
||||
grantPage.saveGrant();
|
||||
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + String.format("/grants/grant?id=%s", grantId));
|
||||
Integer newDeadlineCount = grantPage.getDeadlineCount();
|
||||
Assert.assertEquals(deadlineCount - 1, (int) newDeadlineCount);
|
||||
}
|
||||
}
|
||||
|
@ -83,4 +83,30 @@ public class GrantPage extends PageObject {
|
||||
select.deselectByVisibleText(select.getFirstSelectedOption().getText());
|
||||
return select.getAllSelectedOptions();
|
||||
}
|
||||
|
||||
public List<WebElement> getDeadlineList() {
|
||||
return driver.findElements(By.id("deadlines"));
|
||||
}
|
||||
|
||||
public Integer getDeadlineCount() {
|
||||
return getDeadlineList().size();
|
||||
}
|
||||
|
||||
public void addDeadline() {
|
||||
driver.findElement(By.id("addDeadline")).click();
|
||||
}
|
||||
|
||||
public boolean checkDeadline(String description, String dateValue) {
|
||||
return getDeadlineList()
|
||||
.stream()
|
||||
.anyMatch(webElement -> {
|
||||
return webElement.findElement(By.className("div-deadline-description")).findElement(
|
||||
By.tagName("input")).getAttribute("value").equals(description)
|
||||
&& webElement.findElement(By.className("form-deadline-date")).getAttribute("value").equals(dateValue);
|
||||
});
|
||||
}
|
||||
|
||||
public void deleteDeadline() {
|
||||
driver.findElements(By.className("btn-delete-deadline")).get(0).click();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user