Skip to content

Commit

Permalink
Merge pull request #15 from abodian/timestamp
Browse files Browse the repository at this point in the history
Added timestamps
  • Loading branch information
JamesJPaterson authored Feb 14, 2023
2 parents 7996dd8 + 698db1f commit e9412fd
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 deletions.
4 changes: 3 additions & 1 deletion api/models/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ const mongoose = require("mongoose");
const PostSchema = new mongoose.Schema({
message: String,
userName: String,
});
},
{timestamps: true }
);

const Post = mongoose.model("Post", PostSchema);

Expand Down
13 changes: 12 additions & 1 deletion frontend/cypress/e2e/making_a_post.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,15 @@ it("tests to see if the post button and box works properly", () => {
cy.url().should('include', '/posts');
cy.get('#feed').should('contain', 'cypress test 2')
})
})
it("tests to see if the post button and box works properly", () => {
// need to login in from the login page
cy.visit('/login');
cy.get("#email").type("[email protected]");
cy.get("#password").type("password");
cy.get("#submit").click();
cy.get('#message').type('cypress test 2');
cy.get('#submit').click();
cy.url().should('include', '/posts');
cy.get('#feed').should('contain', '2023-02-14')
})
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
7 changes: 6 additions & 1 deletion frontend/src/components/feed/Feed.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const Feed = ({ navigate }) => {
navigate("/login");
};

const post = () => {};
const post = () => { };

const [user, setUser] = useState({});

Expand Down Expand Up @@ -128,6 +128,11 @@ const Feed = ({ navigate }) => {
posts={posts}
token={token}
/>
<div data-cy="timestamp" class="posttimestamp">
{console.log(post)}
{post.createdAt && new Date(post.createdAt).toISOString().split('.')[0].replace('T', ' ')}
</div>

<div class="postContent">{post.message}</div>
<div class="postButtons">
<button id="like">Like</button>
Expand Down

0 comments on commit e9412fd

Please sign in to comment.