231 lines
10 KiB
Java
231 lines
10 KiB
Java
import com.google.common.collect.ImmutableMap;
|
|
import com.google.common.collect.Iterables;
|
|
import conference.ConferencePage;
|
|
import conference.ConferencesDashboardPage;
|
|
import conference.ConferencesPage;
|
|
import core.PageObject;
|
|
import core.TestTemplate;
|
|
import org.junit.Assert;
|
|
import org.junit.FixMethodOrder;
|
|
import org.junit.Test;
|
|
import org.junit.runner.RunWith;
|
|
import org.junit.runners.MethodSorters;
|
|
import org.openqa.selenium.By;
|
|
import org.openqa.selenium.WebElement;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
import org.springframework.test.context.junit4.SpringRunner;
|
|
import ru.ulstu.NgTrackerApplication;
|
|
import ru.ulstu.configuration.ApplicationProperties;
|
|
|
|
import java.util.Arrays;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
@RunWith(SpringRunner.class)
|
|
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
|
@SpringBootTest(classes = NgTrackerApplication.class, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
|
|
public class IndexConferenceTest extends TestTemplate {
|
|
private final Map<PageObject, List<String>> navigationHolder = ImmutableMap.of(
|
|
new ConferencesPage(), Arrays.asList("КОНФЕРЕНЦИИ", "/conferences/conferences"),
|
|
new ConferencePage(), Arrays.asList("РЕДАКТИРОВАНИЕ КОНФЕРЕНЦИИ", "/conferences/conference?id=0"),
|
|
new ConferencesDashboardPage(), Arrays.asList("АКТУАЛЬНЫЕ КОНФЕРЕНЦИИ", "/conferences/dashboard")
|
|
);
|
|
|
|
@Autowired
|
|
private ApplicationProperties applicationProperties;
|
|
|
|
@Test
|
|
public void testACreateNewConference() {
|
|
Map.Entry<PageObject, List<String>> page = Iterables.get(navigationHolder.entrySet(), 1);
|
|
|
|
getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
|
|
ConferencePage conferencePage = (ConferencePage) getContext().initPage(page.getKey());
|
|
ConferencesPage conferencesPage = (ConferencesPage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 0).getKey());
|
|
|
|
String newConferenceName = "test " + (new Date()).getTime();
|
|
conferencePage.setName(newConferenceName);
|
|
conferencePage.clickSaveBut();
|
|
|
|
Assert.assertTrue(conferencesPage.checkNameInList(newConferenceName));
|
|
}
|
|
|
|
@Test
|
|
public void testBChangeConferenceNameAndSave() {
|
|
Map.Entry<PageObject, List<String>> page = Iterables.get(navigationHolder.entrySet(), 0);
|
|
|
|
getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
|
|
ConferencesPage conferencesPage = (ConferencesPage) getContext().initPage(page.getKey());
|
|
ConferencePage conferencePage = (ConferencePage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 1).getKey());
|
|
|
|
conferencesPage.getFirstConference();
|
|
String newConferenceName = "test " + (new Date()).getTime();
|
|
conferencePage.clearName();
|
|
conferencePage.setName(newConferenceName);
|
|
conferencePage.clickSaveBut();
|
|
|
|
Assert.assertTrue(conferencesPage.checkNameInList(newConferenceName));
|
|
}
|
|
|
|
@Test
|
|
public void testCAddDeadlineAndSave() {
|
|
Map.Entry<PageObject, List<String>> page = Iterables.get(navigationHolder.entrySet(), 0);
|
|
|
|
getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
|
|
ConferencesPage conferencesPage = (ConferencesPage) getContext().initPage(page.getKey());
|
|
ConferencePage conferencePage = (ConferencePage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 1).getKey());
|
|
|
|
conferencesPage.getFirstConference();
|
|
String conferenceId = conferencePage.getId();
|
|
Integer deadlineCount = conferencePage.getDeadlineCount();
|
|
|
|
String description = "test";
|
|
String date = "09.09.2019";
|
|
String dateValue = "2019-09-09";
|
|
conferencePage.clickAddDeadlineBut();
|
|
conferencePage.setDeadlineDescription(description, deadlineCount);
|
|
conferencePage.setDeadlineDate(date, deadlineCount);
|
|
conferencePage.clickSaveBut();
|
|
|
|
getContext().goTo(applicationProperties.getBaseUrl() + String.format("/conferences/conference?id=%s", conferenceId));
|
|
|
|
Assert.assertTrue(conferencePage.checkDeadline(description, dateValue));
|
|
}
|
|
|
|
@Test
|
|
public void testDTakePartAndSave() {
|
|
Map.Entry<PageObject, List<String>> page = Iterables.get(navigationHolder.entrySet(), 0);
|
|
|
|
getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
|
|
ConferencesPage conferencesPage = (ConferencesPage) getContext().initPage(page.getKey());
|
|
ConferencePage conferencePage = (ConferencePage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 1).getKey());
|
|
|
|
conferencesPage.getFirstConference();
|
|
String conferenceId = conferencePage.getId();
|
|
Integer membersCount = conferencePage.getMemberCount();
|
|
|
|
conferencePage.clickTakePartBut();
|
|
conferencePage.clickSaveBut();
|
|
|
|
getContext().goTo(applicationProperties.getBaseUrl() + String.format("/conferences/conference?id=%s", conferenceId));
|
|
|
|
Assert.assertTrue(membersCount + 1 == conferencePage.getMemberCount()
|
|
&& conferencePage.isTakePartButDisabledValueTrue());
|
|
}
|
|
|
|
@Test
|
|
public void testEDeleteDeadlineAndSave() {
|
|
Map.Entry<PageObject, List<String>> page = Iterables.get(navigationHolder.entrySet(), 0);
|
|
|
|
getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
|
|
ConferencesPage conferencesPage = (ConferencesPage) getContext().initPage(page.getKey());
|
|
ConferencePage conferencePage = (ConferencePage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 1).getKey());
|
|
|
|
conferencesPage.getFirstConference();
|
|
String conferenceId = conferencePage.getId();
|
|
Integer deadlineCount = conferencePage.getDeadlineCount();
|
|
|
|
conferencePage.clickDeleteDeadlineBut();
|
|
conferencePage.clickSaveBut();
|
|
|
|
getContext().goTo(applicationProperties.getBaseUrl() + String.format("/conferences/conference?id=%s", conferenceId));
|
|
|
|
Assert.assertEquals(deadlineCount - 1, (int) conferencePage.getDeadlineCount());
|
|
}
|
|
|
|
@Test
|
|
public void testFAttachArticle() {
|
|
Map.Entry<PageObject, List<String>> page = Iterables.get(navigationHolder.entrySet(), 0);
|
|
|
|
getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
|
|
ConferencesPage conferencesPage = (ConferencesPage) getContext().initPage(page.getKey());
|
|
ConferencePage conferencePage = (ConferencePage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 1).getKey());
|
|
|
|
conferencesPage.getFirstConference();
|
|
String conferenceId = conferencePage.getId();
|
|
Integer paperCount = conferencePage.getArticlesCount();
|
|
|
|
conferencePage.showAllowToAttachArticles();
|
|
WebElement paper = conferencePage.selectArticle();
|
|
String paperName = paper.findElement(By.className("text")).getText();
|
|
conferencePage.clickSaveBut();
|
|
|
|
getContext().goTo(applicationProperties.getBaseUrl() + String.format("/conferences/conference?id=%s", conferenceId));
|
|
|
|
Assert.assertTrue(paperCount + 1 == conferencePage.getArticlesCount()
|
|
&& conferencePage.checkArticle(paperName));
|
|
}
|
|
|
|
@Test
|
|
public void testGAddArticle() {
|
|
Map.Entry<PageObject, List<String>> page = Iterables.get(navigationHolder.entrySet(), 0);
|
|
|
|
getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
|
|
ConferencesPage conferencesPage = (ConferencesPage) getContext().initPage(page.getKey());
|
|
ConferencePage conferencePage = (ConferencePage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 1).getKey());
|
|
|
|
conferencesPage.getFirstConference();
|
|
String conferenceId = conferencePage.getId();
|
|
Integer paperCount = conferencePage.getArticlesCount();
|
|
|
|
conferencePage.clickAddPaperBut();
|
|
List<WebElement> webElements = conferencePage.getArticles();
|
|
String paperName = webElements.get(webElements.size() - 1).findElements(By.tagName("input")).get(1).getAttribute("value");
|
|
conferencePage.clickSaveBut();
|
|
|
|
getContext().goTo(applicationProperties.getBaseUrl() + String.format("/conferences/conference?id=%s", conferenceId));
|
|
|
|
Assert.assertTrue(paperCount + 1 == conferencePage.getArticlesCount()
|
|
&& conferencePage.checkArticle(paperName));
|
|
}
|
|
|
|
@Test
|
|
public void testHUndockArticle() {
|
|
Map.Entry<PageObject, List<String>> page = Iterables.get(navigationHolder.entrySet(), 0);
|
|
|
|
getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
|
|
ConferencesPage conferencesPage = (ConferencesPage) getContext().initPage(page.getKey());
|
|
ConferencePage conferencePage = (ConferencePage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 1).getKey());
|
|
|
|
conferencesPage.getFirstConference();
|
|
String conferenceId = conferencePage.getId();
|
|
Integer paperCount = conferencePage.getArticlesCount();
|
|
|
|
conferencePage.clickUndockArticleBut();
|
|
conferencePage.clickSaveBut();
|
|
|
|
getContext().goTo(applicationProperties.getBaseUrl() + String.format("/conferences/conference?id=%s", conferenceId));
|
|
|
|
Assert.assertEquals(paperCount - 1, (int) conferencePage.getArticlesCount());
|
|
}
|
|
|
|
@Test
|
|
public void testISortAndFilterConferenceList() {
|
|
Map.Entry<PageObject, List<String>> page = Iterables.get(navigationHolder.entrySet(), 0);
|
|
|
|
getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
|
|
ConferencesPage conferencesPage = (ConferencesPage) getContext().initPage(page.getKey());
|
|
|
|
conferencesPage.selectMember();
|
|
conferencesPage.selectYear();
|
|
|
|
Assert.assertEquals(1, conferencesPage.getConferencesList().size());
|
|
}
|
|
|
|
@Test
|
|
public void testJDeleteConf() throws InterruptedException {
|
|
Map.Entry<PageObject, List<String>> page = Iterables.get(navigationHolder.entrySet(), 0);
|
|
|
|
getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
|
|
ConferencesPage conferencesPage = (ConferencesPage) getContext().initPage(page.getKey());
|
|
|
|
Integer size = conferencesPage.getConferencesList().size();
|
|
conferencesPage.deleteFirst();
|
|
Thread.sleep(3000);
|
|
conferencesPage.clickConfirm();
|
|
|
|
Assert.assertEquals(size - 1, conferencesPage.getConferencesList().size());
|
|
}
|
|
}
|