+
+
+
-
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
@@ -99,42 +120,52 @@
class="alert alert-danger">Incorrect title
-
diff --git a/src/main/resources/templates/projects/dashboard.html b/src/main/resources/templates/projects/dashboard.html
new file mode 100644
index 0000000..882c202
--- /dev/null
+++ b/src/main/resources/templates/projects/dashboard.html
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/resources/templates/projects/fragments/projectLineFragment.html b/src/main/resources/templates/projects/fragments/projectLineFragment.html
new file mode 100644
index 0000000..3605273
--- /dev/null
+++ b/src/main/resources/templates/projects/fragments/projectLineFragment.html
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/resources/templates/projects/fragments/projectNavigationFragment.html b/src/main/resources/templates/projects/fragments/projectNavigationFragment.html
new file mode 100644
index 0000000..75dfff6
--- /dev/null
+++ b/src/main/resources/templates/projects/fragments/projectNavigationFragment.html
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/resources/templates/projects/fragments/projectStatusFragment.html b/src/main/resources/templates/projects/fragments/projectStatusFragment.html
new file mode 100644
index 0000000..e5da374
--- /dev/null
+++ b/src/main/resources/templates/projects/fragments/projectStatusFragment.html
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/resources/templates/projects/project.html b/src/main/resources/templates/projects/project.html
new file mode 100644
index 0000000..3872cfe
--- /dev/null
+++ b/src/main/resources/templates/projects/project.html
@@ -0,0 +1,146 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Редактирование проекта
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/resources/templates/projects/projects.html b/src/main/resources/templates/projects/projects.html
new file mode 100644
index 0000000..fd19383
--- /dev/null
+++ b/src/main/resources/templates/projects/projects.html
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
diff --git a/src/main/resources/templates/students/dashboard.html b/src/main/resources/templates/students/dashboard.html
index 94ea121..c0c2f0e 100644
--- a/src/main/resources/templates/students/dashboard.html
+++ b/src/main/resources/templates/students/dashboard.html
@@ -16,7 +16,7 @@
diff --git a/src/main/resources/templates/students/fragments/taskDashboardFragment.html b/src/main/resources/templates/students/fragments/taskDashboardFragment.html
index 0daea58..3779ef8 100644
--- a/src/main/resources/templates/students/fragments/taskDashboardFragment.html
+++ b/src/main/resources/templates/students/fragments/taskDashboardFragment.html
@@ -7,14 +7,14 @@
-
-
+
+
-
-
-
title
-
type
+
title
+
status
+
+
diff --git a/src/main/resources/templates/students/fragments/taskLineFragment.html b/src/main/resources/templates/students/fragments/taskLineFragment.html
index 79ad5d7..baad17e 100644
--- a/src/main/resources/templates/students/fragments/taskLineFragment.html
+++ b/src/main/resources/templates/students/fragments/taskLineFragment.html
@@ -4,15 +4,15 @@
-
+
-
-
- Первая хадач
- Курсовая работа
+
+
+
+
-
-
+
diff --git a/src/main/resources/templates/students/fragments/taskNavigationFragment.html b/src/main/resources/templates/students/fragments/taskNavigationFragment.html
index 717930d..cf32140 100644
--- a/src/main/resources/templates/students/fragments/taskNavigationFragment.html
+++ b/src/main/resources/templates/students/fragments/taskNavigationFragment.html
@@ -15,8 +15,8 @@
diff --git a/src/main/resources/templates/students/fragments/taskStatusFragment.html b/src/main/resources/templates/students/fragments/taskStatusFragment.html
index 8f3d800..77fd529 100644
--- a/src/main/resources/templates/students/fragments/taskStatusFragment.html
+++ b/src/main/resources/templates/students/fragments/taskStatusFragment.html
@@ -5,18 +5,14 @@
-
-
-
-
-
-
-
-
-
+
+
+
+
+
-
+
@@ -25,12 +21,6 @@
-
-
-
-
-
-
diff --git a/src/main/resources/templates/students/task.html b/src/main/resources/templates/students/task.html
index 533c8f6..968c7a0 100644
--- a/src/main/resources/templates/students/task.html
+++ b/src/main/resources/templates/students/task.html
@@ -1,9 +1,10 @@
+ layout:decorator="default" xmlns:th="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/html">
-
+
@@ -11,6 +12,7 @@
+
@@ -21,61 +23,87 @@
-
+
-
\ No newline at end of file
diff --git a/src/main/resources/templates/students/tasks.html b/src/main/resources/templates/students/tasks.html
index 076f7ba..b1177d8 100644
--- a/src/main/resources/templates/students/tasks.html
+++ b/src/main/resources/templates/students/tasks.html
@@ -20,8 +20,8 @@
@@ -37,21 +37,10 @@
-
diff --git a/src/test/java/IndexPageTest.java b/src/test/java/IndexPageTest.java
new file mode 100644
index 0000000..1817240
--- /dev/null
+++ b/src/test/java/IndexPageTest.java
@@ -0,0 +1,52 @@
+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
> 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));
+ });
+ }
+}
diff --git a/src/test/java/context/ChromeContext.java b/src/test/java/context/ChromeContext.java
new file mode 100644
index 0000000..899d51d
--- /dev/null
+++ b/src/test/java/context/ChromeContext.java
@@ -0,0 +1,27 @@
+package context;
+
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.openqa.selenium.chrome.ChromeOptions;
+
+public class ChromeContext extends Context {
+ private final static String WINDOWS_DRIVER = "chromedriver.exe";
+ private final static String LINUX_DRIVER = "chromedriver";
+ private final static String DRIVER_TYPE = "webdriver.chrome.driver";
+
+ @Override
+ protected void createDriver() {
+ final ChromeOptions chromeOptions = new ChromeOptions();
+ chromeOptions.addArguments("--headless");
+ driver = new ChromeDriver(chromeOptions);
+ }
+
+ @Override
+ protected String getDriverExecutable(boolean isWindows) {
+ return isWindows ? WINDOWS_DRIVER : LINUX_DRIVER;
+ }
+
+ @Override
+ protected String getDriverType() {
+ return DRIVER_TYPE;
+ }
+}
diff --git a/src/test/java/context/Context.java b/src/test/java/context/Context.java
new file mode 100644
index 0000000..b32c08e
--- /dev/null
+++ b/src/test/java/context/Context.java
@@ -0,0 +1,67 @@
+package context;
+
+import core.PageObject;
+import org.openqa.selenium.Dimension;
+import org.openqa.selenium.WebDriver;
+
+import java.util.concurrent.TimeUnit;
+
+//import org.openqa.selenium.support.PageFactory;
+
+public abstract class Context {
+ private final static String DRIVER_LOCATION = "drivers/%s";
+
+ protected WebDriver driver;
+
+ protected WebDriver getDriver() {
+ if (driver != null) {
+ return driver;
+ }
+ throw new IllegalStateException("WebDriver is not initialized");
+ }
+
+ public void start() {
+ System.setProperty(getDriverType(), getDriverExecutablePath());
+
+ createDriver();
+ // это плохая инструкция для автотестов, т.к. лучше задавать для конкретного элемента или кейса
+ getDriver().manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
+ }
+
+ public void close() {
+ if (driver != null) {
+ driver.quit();
+ }
+ }
+
+ public void goTo(String url) {
+ getDriver().get(url);
+ }
+
+ public String getTitle() {
+ return getDriver().getTitle();
+ }
+
+ public T initPage(T pageObject) {
+ return (T) pageObject.setDriver(getDriver());
+ }
+
+ protected abstract void createDriver();
+
+ protected abstract String getDriverType();
+
+ protected abstract String getDriverExecutable(boolean windows);
+
+ private String getDriverExecutablePath() {
+ return Context.class.getClassLoader().getResource(
+ String.format(DRIVER_LOCATION, getDriverExecutable(isWindows()))).getFile();
+ }
+
+ private boolean isWindows() {
+ return System.getProperty("os.name").toLowerCase().contains("windows");
+ }
+
+ public void setSize(Dimension dimension) {
+ driver.manage().window().setSize(dimension);
+ }
+}
diff --git a/src/test/java/context/FirefoxContext.java b/src/test/java/context/FirefoxContext.java
new file mode 100644
index 0000000..1d5c163
--- /dev/null
+++ b/src/test/java/context/FirefoxContext.java
@@ -0,0 +1,24 @@
+package context;
+
+import org.openqa.selenium.firefox.FirefoxDriver;
+
+public class FirefoxContext extends Context {
+ private final static String WINDOWS_DRIVER = "geckodriver.exe";
+ private final static String LINUX_DRIVER = "geckodriver";
+ private final static String DRIVER_TYPE = "webdriver.gecko.driver";
+
+ @Override
+ protected void createDriver() {
+ driver = new FirefoxDriver();
+ }
+
+ @Override
+ protected String getDriverExecutable(boolean isWindows) {
+ return isWindows ? WINDOWS_DRIVER : LINUX_DRIVER;
+ }
+
+ @Override
+ protected String getDriverType() {
+ return DRIVER_TYPE;
+ }
+}
diff --git a/src/test/java/core/PageObject.java b/src/test/java/core/PageObject.java
new file mode 100644
index 0000000..d1fae83
--- /dev/null
+++ b/src/test/java/core/PageObject.java
@@ -0,0 +1,14 @@
+package core;
+
+import org.openqa.selenium.WebDriver;
+
+public abstract class PageObject {
+ protected WebDriver driver;
+
+ public abstract String getSubTitle();
+
+ public PageObject setDriver(WebDriver driver) {
+ this.driver = driver;
+ return this;
+ }
+}
diff --git a/src/test/java/core/TestTemplate.java b/src/test/java/core/TestTemplate.java
new file mode 100644
index 0000000..a72a8c9
--- /dev/null
+++ b/src/test/java/core/TestTemplate.java
@@ -0,0 +1,29 @@
+package core;
+
+import context.ChromeContext;
+import context.Context;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.openqa.selenium.Dimension;
+
+public abstract class TestTemplate {
+ private static Context context;
+
+ public static Context getContext() {
+ return context;
+ }
+
+ @BeforeClass
+ public static void setup() {
+ context = new ChromeContext();
+ context.start();
+ context.setSize(new Dimension(1600, 900));
+ }
+
+ @AfterClass
+ public static void quit() {
+ if (context != null) {
+ context.close();
+ }
+ }
+}
diff --git a/src/test/java/paper/PaperPage.java b/src/test/java/paper/PaperPage.java
new file mode 100644
index 0000000..9c3c357
--- /dev/null
+++ b/src/test/java/paper/PaperPage.java
@@ -0,0 +1,11 @@
+package paper;
+
+import core.PageObject;
+import org.openqa.selenium.By;
+
+public class PaperPage extends PageObject {
+
+ public String getSubTitle() {
+ return driver.findElement(By.tagName("h2")).getText();
+ }
+}
diff --git a/src/test/java/paper/PapersDashboardPage.java b/src/test/java/paper/PapersDashboardPage.java
new file mode 100644
index 0000000..51d7cb8
--- /dev/null
+++ b/src/test/java/paper/PapersDashboardPage.java
@@ -0,0 +1,11 @@
+package paper;
+
+import core.PageObject;
+import org.openqa.selenium.By;
+
+public class PapersDashboardPage extends PageObject {
+
+ public String getSubTitle() {
+ return driver.findElement(By.tagName("h2")).getText();
+ }
+}
diff --git a/src/test/java/paper/PapersPage.java b/src/test/java/paper/PapersPage.java
new file mode 100644
index 0000000..f191d9b
--- /dev/null
+++ b/src/test/java/paper/PapersPage.java
@@ -0,0 +1,11 @@
+package paper;
+
+import core.PageObject;
+import org.openqa.selenium.By;
+
+public class PapersPage extends PageObject {
+
+ public String getSubTitle() {
+ return driver.findElement(By.tagName("h2")).getText();
+ }
+}