ng-tracker/src/test/java/IndexPageTest.java
2019-04-17 17:20:20 +04:00

53 lines
2.0 KiB
Java

import com.google.common.collect.ImmutableMap;
import core.PageObject;
import core.TestTemplate;
import org.assertj.core.api.Assertions;
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 paper.PaperPage;
import paper.PapersDashboardPage;
import paper.PapersPage;
import ru.ulstu.NgTrackerApplication;
import ru.ulstu.configuration.ApplicationProperties;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = NgTrackerApplication.class, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
public class IndexPageTest extends TestTemplate {
private final Map<PageObject, List<String>> navigationHolder = ImmutableMap.of(
new PapersPage(), Arrays.asList("СТАТЬИ", "/papers/papers"),
new PaperPage(), Arrays.asList("РЕДАКТИРОВАНИЕ СТАТЬИ", "/papers/paper?id=0"),
new PapersDashboardPage(), Arrays.asList("СТАТЬИ", "/papers/dashboard")
);
@Autowired
private ApplicationProperties applicationProperties;
@Test
public void testStartApplication() {
getContext().goTo(applicationProperties.getBaseUrl());
Assertions
.assertThat(getContext().getTitle())
.isEqualTo("NG-Tracker");
}
@Test
public void testModulesNavigation() {
navigationHolder.entrySet()
.stream()
.forEach(navigationEntry -> {
getContext().goTo(applicationProperties.getBaseUrl() + navigationEntry.getValue().get(1));
PageObject pageObject = getContext().initPage(navigationEntry.getKey());
Assertions
.assertThat(pageObject.getSubTitle())
.isEqualToIgnoringCase(navigationEntry.getValue().get(0));
});
}
}