2019-05-10 15:07:47 +04:00
|
|
|
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.assertj.core.api.Assertions;
|
|
|
|
import org.junit.Assert;
|
|
|
|
import org.junit.Test;
|
|
|
|
import org.junit.runner.RunWith;
|
|
|
|
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)
|
|
|
|
@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 testStartApplication() {
|
|
|
|
getContext().goTo(applicationProperties.getBaseUrl());
|
|
|
|
Assertions
|
|
|
|
.assertThat(getContext().getTitle())
|
|
|
|
.isEqualTo("NG-Tracker");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testCreateNewConference() {
|
|
|
|
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.getConferencesList()
|
|
|
|
.stream()
|
|
|
|
.anyMatch(webElement -> webElement.getText().equals(newConferenceName)));
|
|
|
|
}
|
2019-05-10 15:54:12 +04:00
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testChangeConferenceNameAndSave() {
|
|
|
|
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.getConferenceFirst();
|
|
|
|
String newConferenceName = "test " + (new Date()).getTime();
|
|
|
|
conferencePage.clearName();
|
|
|
|
conferencePage.setName(newConferenceName);
|
|
|
|
conferencePage.clickSaveBut();
|
|
|
|
|
|
|
|
Assert.assertTrue(conferencesPage.getConferencesList()
|
|
|
|
.stream()
|
|
|
|
.anyMatch(webElement -> webElement.getText().equals(newConferenceName)));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-10 15:07:47 +04:00
|
|
|
}
|