- Signed in as
+
+
+
+
Acebook
+
+
+
+
+
-
+
-
-
+
diff --git a/src/main/resources/templates/posts/show.html b/src/main/resources/templates/posts/show.html
new file mode 100644
index 000000000..4a0f5d711
--- /dev/null
+++ b/src/main/resources/templates/posts/show.html
@@ -0,0 +1,67 @@
+
+
+
+
+
+
+
+
Acebook
+
+
+
+
+
+
![]()
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
\ 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..9f6315a98
--- /dev/null
+++ b/src/main/resources/templates/users/friends.html
@@ -0,0 +1,69 @@
+
+
+
+
+
+
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..a25bea50c 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..538075256
--- /dev/null
+++ b/src/main/resources/templates/users/show.html
@@ -0,0 +1,101 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
![Profile Image]()
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/test/java/SignUpTest.java b/src/test/java/SignUpTest.java
index b0e16955b..fec9926fa 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,41 @@ 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 testBlankUsernameReturnsError() {
+ 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();
+ // Explicitly wait for the error message to be visible
+ WebDriverWait wait = new WebDriverWait(driver, 10);
+ WebElement usernameError = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("usernameError")));
+ String errorString = usernameError.getText();
+ Assert.assertEquals("Please enter a username", errorString);
+ }
+
+ @Test
+ public void testBlankPasswordReturnsError() {
+ driver.get("http://localhost:8080/users/new");
+ driver.findElement(By.id("username")).sendKeys("username_1");
+ driver.findElement(By.id("password")).sendKeys(" ");
+ driver.findElement(By.id("submit")).click();
+ // Explicitly wait for the error message to be visible
+ WebDriverWait wait = new WebDriverWait(driver, 10);
+ WebElement passwordError = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("passwordError")));
+ String errorString = passwordError.getText();
+ Assert.assertEquals("Please enter a password", errorString);
}
}
diff --git a/src/test/java/com/makersacademy/acebook/model/PostTest.java b/src/test/java/com/makersacademy/acebook/model/PostTest.java
index 732aafc6e..be918f1d3 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);
@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..aa512eebf
--- /dev/null
+++ b/src/test/java/com/makersacademy/aceboook/controller/PostControllerTest.java
@@ -0,0 +1,98 @@
+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("content")).sendKeys("New Post");
+ driver.findElement(By.id("submit")).click();
+
+ WebElement ul = driver.findElement(By.tagName("ul"));
+ List postList = ul.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("content")));
+ driver.findElement(By.id("content")).sendKeys("New Post");
+ driver.findElement(By.id("submit")).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("content")).sendKeys("Testing Comment Button");
+ driver.findElement(By.id("submit")).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..0f8b6cd87
--- /dev/null
+++ b/src/test/java/com/makersacademy/aceboook/controller/UsersControllerTest.java
@@ -0,0 +1,55 @@
+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("localhost:8080/users/3");
+ WebElement pElement = driver.findElement(By.tagName("p"));
+ String pText = pElement.getText();
+ Assert.assertEquals("zak ", pText);
+
+ }
+
+// @Test
+// public void successfulSignUpRedirectsToSignIn() {
+// driver.get("http://localhost:8080/users/new");
+// driver.findElement(By.id("username")).sendKeys(faker.name().firstName());
+// driver.findElement(By.id("password")).sendKeys("password");
+// driver.findElement(By.id("submit")).click();
+// String title = driver.getTitle();
+// Assert.assertEquals("Please sign in", title);
+// }
+}