Skip to content

Tc/test making a post #143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 158 commits into
base: main
Choose a base branch
from
Open
Changes from 12 commits
Commits
Show all changes
158 commits
Select commit Hold shift + click to select a range
b08070a
added test to readme
pablisch May 9, 2023
d9cdd4a
Added button to signup screen
pablisch May 11, 2023
e970f48
Merge pull request #1 from ManuelaIacobovici/pablo
ManuelaIacobovici May 11, 2023
27865c8
TDD AddPost component and test passes
pablisch May 11, 2023
3d0f920
Display posts with newest post first
tomcarmichael May 11, 2023
acaf173
Merged with main
tomcarmichael May 11, 2023
2be9bbd
new posts creating and all tests passing
pablisch May 11, 2023
0e25a01
.then handling handleSubmit. Test passing
pablisch May 11, 2023
ddc6a66
post being created but posts not refreshing
pablisch May 11, 2023
c1556ff
clear commented code
pablisch May 11, 2023
b8e90a1
Co-authored-by: Daniel John <[email protected]>
carolrs May 11, 2023
4656570
removing videos
carolrs May 11, 2023
548905c
tidy white space
pablisch May 11, 2023
91ec34b
css for navbar
carolrs May 12, 2023
ef755da
edits from PR review 1
pablisch May 12, 2023
fab3412
Merge pull request #3 from ManuelaIacobovici/mlpj/new/create-post
pablisch May 12, 2023
d035d8e
Added username in signup, and tests pass
pablisch May 12, 2023
cc69384
completed add username
pablisch May 12, 2023
5e7a956
Merge pull request #5 from ManuelaIacobovici/tcpj/new/add-username
pablisch May 12, 2023
b28e756
AddPost.js | Enabled page refresh upon clicking 'Post'
djohn06 May 12, 2023
f42e9aa
Merge branch 'main' into NavBar
carolrs May 13, 2023
a20da22
changes requested
carolrs May 13, 2023
5eae4dd
changed as requested
carolrs May 13, 2023
bd9b000
test orderByDate passing
carolrs May 14, 2023
a530dfb
Merge pull request #4 from ManuelaIacobovici/NavBar
carolrs May 14, 2023
e06fcca
Merge pull request #6 from ManuelaIacobovici/DjMi/new/RerenderPosts
djohn06 May 15, 2023
25ad1da
validation for email
carolrs May 15, 2023
705a63a
Merged with main
tomcarmichael May 15, 2023
ff70014
Merge pull request #2 from ManuelaIacobovici/tcjr/new/posts_by_date_o…
tomcarmichael May 15, 2023
0248d7e
Publishing branch
djohn06 May 15, 2023
1234d64
Package.json
djohn06 May 15, 2023
9bd9e45
Merge branch 'main' into DjPj/new/AddComment
djohn06 May 15, 2023
d7debaa
added comments array into schema for users
pablisch May 15, 2023
85ecb39
Fixed breaking tests due to username: required being added to Users s…
tomcarmichael May 15, 2023
8cd5b86
Added patch route to routes
pablisch May 15, 2023
ab16663
Added post controller update
pablisch May 15, 2023
ec6acb6
partial implementation, displays timestamp and user Object ID
tomcarmichael May 15, 2023
0d254bf
nav logout button to work, deleted feed logout button
ManuelaIacobovici May 15, 2023
7acd85f
Co-authored-by: Daniel John <[email protected]>
ManuelaIacobovici May 15, 2023
ecc0854
Impelement functionality to display post username and timestamp
tomcarmichael May 15, 2023
b3a431a
Add formatting to display of username and timestamp for posts
tomcarmichael May 15, 2023
93d979b
updated post to patch in AddComment
pablisch May 15, 2023
f32ecc1
update to AddComment controller and comp
pablisch May 15, 2023
b8b5c7e
Update to AddComment component to fix token
pablisch May 15, 2023
17280a1
added username to navbar
ManuelaIacobovici May 15, 2023
d5e56f5
Some CSS to ease the eyes
pablisch May 15, 2023
bfde89f
Add AuthorUserID to new post in posts conroller before saving to DB...
tomcarmichael May 15, 2023
4754ab4
remove erroneous comment. Comment block in posts controller still to …
tomcarmichael May 15, 2023
80ba62e
added username to the navbar
ManuelaIacobovici May 16, 2023
87ba3f9
Remove errnoeuous commented out code block in posts.js
tomcarmichael May 16, 2023
8a7d2a5
tiny css button and input changes
pablisch May 16, 2023
7af127c
Merge pull request #7 from ManuelaIacobovici/mijr/navbar/view
ManuelaIacobovici May 16, 2023
8a8d2c7
Merge with main locally
tomcarmichael May 16, 2023
396f729
Merge pull request #8 from ManuelaIacobovici/tcac/display-username
tomcarmichael May 16, 2023
423df85
Merge branch 'main' into DjPj/new/AddComment
pablisch May 16, 2023
4fef3ed
Merge pull request #9 from ManuelaIacobovici/DjPj/new/AddComment
pablisch May 16, 2023
463c8fb
Removed redundant comma line 12 post model
tomcarmichael May 16, 2023
e48cbdf
Merge pull request #11 from ManuelaIacobovici/tomcarmichael-patch-1
pablisch May 16, 2023
7b5bbdf
Co-authored-by: Tom Carmichael-Mhanna <[email protected]
carolrs May 16, 2023
e1b705c
Add author to comments object and display both
pablisch May 16, 2023
c834ceb
Merge branch 'main' into tcpjmi/fix.add-comments
pablisch May 16, 2023
3fac572
add likes d.b/controller and test for likes
carolrs May 16, 2023
1af9699
Merge pull request #10 from ManuelaIacobovici/NavBar
carolrs May 16, 2023
fc794fe
remove comments and add setNewComment("")
pablisch May 16, 2023
0d27392
Merge pull request #12 from ManuelaIacobovici/tcpjmi/fix.add-comments
pablisch May 16, 2023
81e34ab
Merge branch 'main' into TJA/Likes
carolrs May 16, 2023
6a6dc87
Merge pull request #13 from ManuelaIacobovici/TJA/Likes
carolrs May 16, 2023
f83c12c
username login and logout to login page
pablisch May 16, 2023
4398f48
indentation fix on navbar file
pablisch May 16, 2023
ab04b4a
Update post component unit test so mock post object structure matches…
tomcarmichael May 16, 2023
1ae22bf
adding testing for likes in the models.
carolrs May 16, 2023
cdac3fc
Fix broken feed component unit test, mocking complete post object in …
tomcarmichael May 16, 2023
57a6099
testing for comments
carolrs May 16, 2023
c0f2247
Partial fix of all frontend cypress test, AddComment test outstanding
tomcarmichael May 16, 2023
cfc0822
cypress did this not me!
pablisch May 16, 2023
ebfd0d7
Updated cypresss screenshot for AddComment test
tomcarmichael May 17, 2023
3b1922a
testing avatar
carolrs May 17, 2023
c989a65
Merge pull request #14 from ManuelaIacobovici/pj/fix/username-login
pablisch May 17, 2023
c57c4a9
Local merge with main
tomcarmichael May 17, 2023
1054a2c
Merge pull request #15 from ManuelaIacobovici/tc/testing
tomcarmichael May 17, 2023
6e9390a
Fix failing tests for addComment and addPost
tomcarmichael May 17, 2023
62765c7
add --runInBand flag to npm run test script in backend package.json..
tomcarmichael May 17, 2023
c85ec49
Fix LoginForm test now that we log in with username not email
tomcarmichael May 17, 2023
ed054cf
Fixed e2e signing in test now that sign-in asks for username instead …
tomcarmichael May 17, 2023
095b620
Uncomment window.location.reload() in AddPost.js
tomcarmichael May 17, 2023
d2cad3b
feature setup
tomcarmichael May 17, 2023
c161eb2
Merge pull request #17 from ManuelaIacobovici/tcpj/addCommentTest
tomcarmichael May 17, 2023
4ad75d3
Merge branch 'TJA/Likes' into pj/add/css
pablisch May 17, 2023
8667275
Merge branch 'main' into testing
carolrs May 17, 2023
d7a3974
Merge pull request #18 from ManuelaIacobovici/testing
carolrs May 17, 2023
9adbbb2
correct folder structure error and remove old comments
tomcarmichael May 17, 2023
7633f11
Merge branch 'main' into pj/add/css
pablisch May 17, 2023
17ac584
added labels to input fields for signup and login
ManuelaIacobovici May 17, 2023
8eb9442
trying to merge my branch with main
ManuelaIacobovici May 17, 2023
01362ce
ammended AddLikes in posts controller to use req.user_id & return new…
tomcarmichael May 17, 2023
3b2f8d5
some css on the navbar component
pablisch May 17, 2023
02ef7ff
refactored
ManuelaIacobovici May 17, 2023
64137a4
Co-authored-by: Jamie Richardson <[email protected]
carolrs May 17, 2023
0366b8b
Write intiial code for Likes component
tomcarmichael May 17, 2023
da168b2
single navbar return
ManuelaIacobovici May 17, 2023
54b659b
Merge pull request #19 from ManuelaIacobovici/manuela
ManuelaIacobovici May 17, 2023
6bfb621
Merge pull request #20 from ManuelaIacobovici/midj/fix/navbuttons
ManuelaIacobovici May 17, 2023
ad7c326
navbar css fonts
pablisch May 17, 2023
aff82d7
Merge branch 'main' into pj/add/css
pablisch May 17, 2023
7a6e2be
Basic css for most of site
pablisch May 17, 2023
05d1ec0
fixed the login signup button context thing
pablisch May 17, 2023
0a375fa
Iterate on likes component
tomcarmichael May 18, 2023
6a21b5b
Adjusted NavBar component cypress test to reflect changes and pass tests
tomcarmichael May 18, 2023
6ca21ef
review changes
pablisch May 18, 2023
ee6f91a
Merge branch 'pj/add/css' of https://github.com/ManuelaIacobovici/ace…
pablisch May 18, 2023
a6642fa
Merge pull request #21 from ManuelaIacobovici/pj/add/css
pablisch May 18, 2023
e68b78c
warning fix
pablisch May 18, 2023
9953b36
Merge pull request #22 from ManuelaIacobovici/pj/fix/warning
pablisch May 18, 2023
6b3fe73
Change thumbs up images and correct folder structure
tomcarmichael May 18, 2023
c0ffcb8
Merge with main and resolve conflicts in post component
tomcarmichael May 18, 2023
31522a2
added missing e2e folder in cypress dir
tomcarmichael May 18, 2023
be355c1
fixed two failing tests on the backend - token generator which now t…
tomcarmichael May 18, 2023
aa56549
Merge branch 'main' into testing
carolrs May 18, 2023
c67ffca
Updated AddLikes function in posts controller to look for 'article_id…
tomcarmichael May 18, 2023
a3db32a
taking out the comments
carolrs May 18, 2023
f93840e
continue implementation of like
tomcarmichael May 18, 2023
985714f
adjust posts controller addLikes to take article_id as body param
tomcarmichael May 18, 2023
bcd3ed1
Likes can be added from the front end, display does not yet update
tomcarmichael May 18, 2023
a9a5e54
Merge pull request #23 from ManuelaIacobovici/testing
carolrs May 18, 2023
97cc185
Correct the logic for displaying right like button if user has liked …
tomcarmichael May 18, 2023
86b66d3
Like thumb image is refreshed automatically after user has liked
tomcarmichael May 18, 2023
e739d5d
Update likes label to be singular with just one like
tomcarmichael May 18, 2023
0153799
Working password validation
djohn06 May 18, 2023
13676ec
Update likes component
tomcarmichael May 18, 2023
450e54a
adjust size of liked thumb image
tomcarmichael May 18, 2023
b1f98b9
Write and pass component test for Likes
tomcarmichael May 18, 2023
aa165b6
New posts refresh Feed
pablisch May 18, 2023
a7b3e22
feed reloads when new comment is made
pablisch May 18, 2023
ca3081a
Fix failing test for AddPost and AddComment
tomcarmichael May 18, 2023
1bd9a6f
Local merge with main
tomcarmichael May 18, 2023
e485c7a
Fix cypress e2e tests with valid password
tomcarmichael May 18, 2023
231feec
Fix broken backend tests
tomcarmichael May 18, 2023
20d62a0
Create passing tests for email validation is spec/controllers/users
tomcarmichael May 18, 2023
e3e5c0a
Resolve merge conflict with main
tomcarmichael May 18, 2023
5a25d7f
Merge pull request #24 from ManuelaIacobovici/Dj/new/passwordValidation
djohn06 May 18, 2023
ba21d36
Supplied props to AddPost and AddComment component tests
tomcarmichael May 18, 2023
1981541
Correct token generator test in backend
tomcarmichael May 18, 2023
28534c5
comments collapse and css for changes
pablisch May 18, 2023
5cd01db
package.json changes
pablisch May 18, 2023
7deeb1f
remove redundant comment and console log as per review suggestions
tomcarmichael May 18, 2023
5961c0f
Merge pull request #25 from ManuelaIacobovici/tc/displayLikes
tomcarmichael May 18, 2023
d923d84
tests pass... no, really!
pablisch May 18, 2023
d3e85ed
Merge branch 'main' into pj/new/collapse-comments
pablisch May 18, 2023
21ca2f4
Merge branch 'main' into pablo-test
pablisch May 18, 2023
ca2f6b5
Merge pull request #27 from ManuelaIacobovici/pablo-test
pablisch May 18, 2023
b430ff4
Reformat like button and comments slightly
tomcarmichael May 18, 2023
ed3ebc3
Merge branch 'main' into pj/new/collapse-comments
pablisch May 18, 2023
97f75e9
duplicate code fix
pablisch May 18, 2023
4dacd0f
Create failing test for e2e making a post
tomcarmichael May 18, 2023
4b0ffd2
merge with main
tomcarmichael May 18, 2023
bb4859f
e2e test for making a post passes after merge with re render feature …
tomcarmichael May 18, 2023
e6b6ef6
Merge pull request #29 from ManuelaIacobovici/pj/new/collapse-comments
pablisch May 18, 2023
9dfe5cf
merge with main
tomcarmichael May 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions api/models/user.js
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ const mongoose = require("mongoose");

const UserSchema = new mongoose.Schema({
email: { type: String, required: true },
username: { type: String, required: true },
password: { type: String, required: true },
});

1 change: 1 addition & 0 deletions frontend/cypress/e2e/signing_up.cy.js
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ describe("Signing up", () => {
cy.visit("/signup");
cy.get("#email").type("[email protected]");
cy.get("#password").type("password");
cy.get("#username").type("username");
cy.get("#submit").click();

cy.url().should("include", "/login");
Binary file added frontend/cypress/videos/making_a_post.cy.js.mp4
Binary file not shown.
Binary file added frontend/cypress/videos/signing_in.cy.js.mp4
Binary file not shown.
Binary file added frontend/cypress/videos/signing_up.cy.js.mp4
Binary file not shown.
23 changes: 23 additions & 0 deletions frontend/src/components/AddPost/AddPost.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import AddPost from './AddPost';
// const navigate = () => {};

describe('AddPost', () => {
xit('creates a new post', () => {
cy.mount(<AddPost />);

cy.intercept('POST', '/posts', {
statusCode: 201,
body: {
message: 'Hello FarceBook',
},
}).as('newPostRequest');

cy.get('#message').type('text');
cy.get('#submit').click();

cy.wait('@newPostRequest').then((interception) => {
expect(interception.response.body.message).to.eq('Hello FarceBook');
});
});
});

54 changes: 54 additions & 0 deletions frontend/src/components/AddPost/AddPost.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import React, { useState } from 'react';

const AddPost = () => { // was passing in navigate but that is not passed into this component in Feed
const [message, setMessage] = useState('');
const [token, setToken] = useState(window.localStorage.getItem("token"));

const handleSubmit = async (event) => {
event.preventDefault();

if (token) {

console.log(`${message}`) // VISIBILITY
const response = await fetch('/posts', {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ message: message })
})
if (response.status !== 201) {
console.log("oops")
// navigate('/login')
} else {
console.log("yay!")
let data = await response.json()
console.log(data) // VISIBILITY
window.localStorage.setItem("token", data.token)
setToken(window.localStorage.getItem("token"));
// navigate('/posts'); // navigate is not present in this component
}
}
}

const handleMessageChange = (event) => {
setMessage(event.target.value)
}

return (
<>
<form onSubmit={handleSubmit}>
<input placeholder='Message' id="message" type='text' value={message} onChange={handleMessageChange} />
<input role='submit-button' id='submit' type="submit" value="Submit" />
</form>

</>
)
}

export default AddPost;




16 changes: 9 additions & 7 deletions frontend/src/components/feed/Feed.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useEffect, useState } from 'react';
import Post from '../post/Post'
import Post from '../post/Post';
import AddPost from '../AddPost/AddPost';

const Feed = ({ navigate }) => {
const [posts, setPosts] = useState([]);
@@ -31,13 +32,14 @@ const Feed = ({ navigate }) => {
return(
<>
<h2>Posts</h2>
<button onClick={logout}>
Logout
</button>
<button onClick={logout}>
Logout
</button>
<AddPost />
<div id='feed' role="feed">
{posts.map(
(post) => ( <Post post={ post } key={ post._id } /> )
)}
{posts.map(
(post) => ( <Post post={ post } key={ post._id } /> )
)}
</div>
</>
)
2 changes: 2 additions & 0 deletions frontend/src/components/user/SignUpForm.cy.js
Original file line number Diff line number Diff line change
@@ -9,6 +9,8 @@ describe("Signing up", () => {

cy.get("#email").type("[email protected]");
cy.get("#password").type("password");
cy.get("#username").type("username");

cy.get("#submit").click();
cy.wait('@signUpRequest').then( interception => {
expect(interception.response.body.message).to.eq("OK")
8 changes: 7 additions & 1 deletion frontend/src/components/user/SignUpForm.js
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ import React, { useState } from 'react';
const SignUpForm = ({ navigate }) => {

const [email, setEmail] = useState("");
const [username, setUsername] = useState("");
const [password, setPassword] = useState("");

const handleSubmit = async (event) => {
@@ -13,7 +14,7 @@ const SignUpForm = ({ navigate }) => {
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ email: email, password: password })
body: JSON.stringify({ email: email, username: username, password: password })
})
.then(response => {
if(response.status === 201) {
@@ -28,6 +29,10 @@ const SignUpForm = ({ navigate }) => {
setEmail(event.target.value)
}

const handleUsernameChange = (event) => {
setUsername(event.target.value)
}

const handlePasswordChange = (event) => {
setPassword(event.target.value)
}
@@ -45,6 +50,7 @@ const SignUpForm = ({ navigate }) => {
</button>
<form onSubmit={handleSubmit}>
<input placeholder="Email" id="email" type='text' value={ email } onChange={handleEmailChange} />
<input placeholder="Username" id="username" type='text' value={ username } onChange={handleUsernameChange} />
<input placeholder="Password" id="password" type='password' value={ password } onChange={handlePasswordChange} />
<input id='submit' type="submit" value="Submit" />
</form>
2 changes: 2 additions & 0 deletions frontend/src/index.css
Original file line number Diff line number Diff line change
@@ -17,3 +17,5 @@ code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}