- Signed in as
+
+
+
+
Acebook
+
+
+
+
+
+
-
+
+
+ Welcome !
+
-
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
![an image]()
+
+
+
+
+
+
+
+
diff --git a/src/main/resources/templates/posts/show.html b/src/main/resources/templates/posts/show.html
new file mode 100644
index 000000000..d6f281080
--- /dev/null
+++ b/src/main/resources/templates/posts/show.html
@@ -0,0 +1,77 @@
+
+
+
+
+
+
+
+
Acebook
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Comments
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/resources/templates/users/friends.html b/src/main/resources/templates/users/friends.html
new file mode 100644
index 000000000..74d332923
--- /dev/null
+++ b/src/main/resources/templates/users/friends.html
@@ -0,0 +1,71 @@
+
+
+
+
+
+
+
Friends
+
+
+
+
+
+
Friends
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/resources/templates/users/new.html b/src/main/resources/templates/users/new.html
index 2d763f396..3556b66a2 100644
--- a/src/main/resources/templates/users/new.html
+++ b/src/main/resources/templates/users/new.html
@@ -1,14 +1,33 @@
-
-
+
+
+
Signup
+
+
-
diff --git a/src/main/resources/templates/users/show.html b/src/main/resources/templates/users/show.html
new file mode 100644
index 000000000..31131194f
--- /dev/null
+++ b/src/main/resources/templates/users/show.html
@@ -0,0 +1,122 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
![Profile Image]()
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/test/java/SignUpTest.java b/src/test/java/SignUpTest.java
index b0e16955b..42ba25f74 100644
--- a/src/test/java/SignUpTest.java
+++ b/src/test/java/SignUpTest.java
@@ -7,7 +7,10 @@
import org.junit.runner.RunWith;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.WebDriverWait;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -38,6 +41,25 @@ public void successfulSignUpRedirectsToSignIn() {
driver.findElement(By.id("password")).sendKeys("password");
driver.findElement(By.id("submit")).click();
String title = driver.getTitle();
- Assert.assertEquals("Please sign in", title);
+ Assert.assertEquals("Please log in", title);
+ }
+
+
+ @Test
+ public void signUpButtonLinksToSignUpPage() {
+ driver.get("http://localhost:8080/login");
+ driver.findElement(By.id("sign-up-btn")).click();
+ String title = driver.getTitle();
+ Assert.assertEquals("Signup", title);
+ }
+
+ @Test
+ public void testBlankUsernameStaysOnPage() {
+ driver.get("http://localhost:8080/users/new");
+ driver.findElement(By.id("username")).sendKeys(" ");
+ driver.findElement(By.id("password")).sendKeys("password");
+ driver.findElement(By.id("submit")).click();
+ String currentURL = driver.getCurrentUrl();
+ Assert.assertEquals("http://localhost:8080/users", currentURL);
}
}
diff --git a/src/test/java/com/makersacademy/acebook/model/PostTest.java b/src/test/java/com/makersacademy/acebook/model/PostTest.java
index 732aafc6e..59d8dfa39 100644
--- a/src/test/java/com/makersacademy/acebook/model/PostTest.java
+++ b/src/test/java/com/makersacademy/acebook/model/PostTest.java
@@ -5,13 +5,22 @@
import org.junit.Test;
+import java.sql.Timestamp;
+
public class PostTest {
- private Post post = new Post("hello");
+ Timestamp timestamp = Timestamp.valueOf("2007-09-23 10:10:10.0");;
+
+ private Post post = new Post("hello", timestamp, 1L, "empty");
@Test
public void postHasContent() {
assertThat(post.getContent(), containsString("hello"));
}
+ @Test
+ public void postHasU() {
+ assertThat(post.getContent(), containsString("hello"));
+ }
+
}
diff --git a/src/test/java/com/makersacademy/aceboook/controller/CommentControllerTest.java b/src/test/java/com/makersacademy/aceboook/controller/CommentControllerTest.java
new file mode 100644
index 000000000..ed8ecc610
--- /dev/null
+++ b/src/test/java/com/makersacademy/aceboook/controller/CommentControllerTest.java
@@ -0,0 +1,65 @@
+package com.makersacademy.aceboook.controller;
+
+import com.github.javafaker.Faker;
+import com.makersacademy.acebook.Application;
+import com.makersacademy.acebook.repository.CommentRepository;
+import com.makersacademy.acebook.repository.PostRepository;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import java.util.List;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@SpringBootTest(classes = Application.class)
+public class CommentControllerTest {
+
+
+ @Autowired
+ PostRepository postRepository;
+
+ @Autowired
+ CommentRepository commentRepository;
+
+ WebDriver driver;
+ Faker faker;
+
+ @Before
+ public void setup() {
+ System.setProperty("webdriver.chrome.driver", "/usr/local/bin/chromedriver");
+ driver = new ChromeDriver();
+ faker = new Faker();
+ }
+
+ @After
+ public void tearDown() {
+ driver.close();
+ }
+
+ @Test
+ public void testAddCommentReflectedInCommentsList() {
+ driver.get("http://localhost:8080/login");
+ driver.findElement(By.id("username")).sendKeys("test_user");
+ driver.findElement(By.id("password")).sendKeys("password22");
+ driver.findElement(By.id("submit")).click();
+ driver.findElement(By.id("comment")).click();
+ driver.findElement(By.id("addComment")).sendKeys("Here is my new comment!");
+ driver.findElement(By.id("submitComment")).click();
+
+ List
commentsList = driver.findElements(By.id("commentContent"));
+ String comment = commentsList.get(commentsList.size() -1).getText();
+
+ Assert.assertEquals("Here is my new comment!", comment);
+ }
+
+
+}
diff --git a/src/test/java/com/makersacademy/aceboook/controller/PostControllerTest.java b/src/test/java/com/makersacademy/aceboook/controller/PostControllerTest.java
new file mode 100644
index 000000000..da44dc267
--- /dev/null
+++ b/src/test/java/com/makersacademy/aceboook/controller/PostControllerTest.java
@@ -0,0 +1,96 @@
+package com.makersacademy.aceboook.controller;
+
+import com.github.javafaker.Faker;
+import com.makersacademy.acebook.Application;
+import com.makersacademy.acebook.model.Post;
+import com.makersacademy.acebook.repository.PostRepository;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.WebDriverWait;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import java.util.List;
+
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@SpringBootTest(classes = Application.class)
+public class PostControllerTest {
+
+
+ @Autowired
+ PostRepository postRepository;
+
+ WebDriver driver;
+ Faker faker;
+
+ @Before
+ public void setup() {
+ System.setProperty("webdriver.chrome.driver", "/usr/local/bin/chromedriver");
+ driver = new ChromeDriver();
+ faker = new Faker();
+ }
+
+ @After
+ public void tearDown() {
+ driver.close();
+ }
+
+ @Test
+ public void testNewPostIsAtTheTopOfList() {
+ driver.get("http://localhost:8080/login");
+ driver.findElement(By.id("username")).sendKeys("test_user");
+ driver.findElement(By.id("password")).sendKeys("password22");
+ driver.findElement(By.id("submit")).click();
+ driver.findElement(By.id("timeline-form-content")).sendKeys("New Post");
+ driver.findElement(By.id("submit-posts")).click();
+
+ List postList = driver.findElements(By.id("postContent"));
+ String newPost = postList.get(0).getText();
+
+ Assert.assertEquals("New Post", newPost);
+ }
+
+ @Test
+ public void testNewPostHasUserIdAssigned() {
+ driver.get("http://localhost:8080/login");
+ driver.findElement(By.id("username")).sendKeys("test_user");
+ driver.findElement(By.id("password")).sendKeys("password22");
+ driver.findElement(By.id("submit")).click();
+ WebDriverWait wait = new WebDriverWait(driver, 10);
+ wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("timeline-form-content")));
+ driver.findElement(By.id("timeline-form-content")).sendKeys("New Post");
+ driver.findElement(By.id("submit-posts")).click();
+ List posts = postRepository.findAllByOrderByTimestampDesc();
+ Post latestPost = posts.get(0);
+ Long userId = latestPost.getUserId();
+ Long expected = 4L;
+ Assert.assertEquals(expected, userId);
+ }
+
+ @Test
+ public void testCommentButtonNavigatesToPostPageFromPosts() {
+ driver.get("http://localhost:8080/login");
+ driver.findElement(By.id("username")).sendKeys("test_user");
+ driver.findElement(By.id("password")).sendKeys("password22");
+ driver.findElement(By.id("submit")).click();
+ driver.findElement(By.id("timeline-form-content")).sendKeys("Testing Comment Button");
+ driver.findElement(By.id("submit-posts")).click();
+ driver.findElement(By.id("comment")).click();
+ WebElement h3Element = driver.findElement(By.tagName("h3"));
+ String h3Text = h3Element.getText();
+ Assert.assertEquals("Testing Comment Button", h3Text);
+
+ }
+
+
+}
diff --git a/src/test/java/com/makersacademy/aceboook/controller/UsersControllerTest.java b/src/test/java/com/makersacademy/aceboook/controller/UsersControllerTest.java
new file mode 100644
index 000000000..b7f351105
--- /dev/null
+++ b/src/test/java/com/makersacademy/aceboook/controller/UsersControllerTest.java
@@ -0,0 +1,49 @@
+package com.makersacademy.aceboook.controller;
+
+import com.github.javafaker.Faker;
+import com.makersacademy.acebook.Application;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@SpringBootTest(classes = Application.class)
+public class UsersControllerTest {
+
+ WebDriver driver;
+ WebDriver page;
+ Faker faker;
+
+ @Before
+ public void setup() {
+ System.setProperty("webdriver.chrome.driver", "/usr/local/bin/chromedriver");
+ driver = new ChromeDriver();
+ faker = new Faker();
+ }
+
+ @After
+ public void tearDown() {
+ driver.close();
+ }
+
+ @Test
+ public void usersCanReadUsername() {
+ driver.get("http://localhost:8080/login");
+ driver.findElement(By.id("username")).sendKeys("test_user");
+ driver.findElement(By.id("password")).sendKeys("password22");
+ driver.findElement(By.id("submit")).click();
+ driver.get("http://localhost:8080/users/4");
+ WebElement pElement = driver.findElement(By.id("profileUsername"));
+ String pText = pElement.getText();
+ Assert.assertEquals("Test_User", pText);
+
+ }
+}