Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
c0b1e96
Refactored user model to separate snippets
kyleslugg May 16, 2023
fbbef71
Updated routes after testing (all but DELETE working)
kyleslugg May 16, 2023
bf2b7f3
Merge pull request #1 from ECRI40-Velocirabbit/ks
LeRocque May 16, 2023
fca674e
pulling
LeRocque May 16, 2023
7c7db68
Added comments throughout front end code
jimpulsee May 16, 2023
d3beae6
Merged with dev
jimpulsee May 16, 2023
62d5ccf
Merge remote-tracking branch 'origin/dev' into tadd
LeRocque May 16, 2023
ac9bbd7
Auth0Started
LeRocque May 16, 2023
e6c3a7f
Installed supertest and added jest to our eslint
jimpulsee May 16, 2023
775f560
Tests for GET request to snippets endpoint
jimpulsee May 16, 2023
80c6a95
Working on updating fetch() formatting to match route patterns
kyleslugg May 16, 2023
8f6fb2f
Merge pull request #2 from ECRI40-Velocirabbit/jt
kyleslugg May 16, 2023
7917f32
Merge pull request #3 from ECRI40-Velocirabbit/jb/tests
kyleslugg May 16, 2023
d0f9df9
added login component and signup component
WandefulWorld May 16, 2023
0d162c8
Merge branch 'Ivy/new' of https://github.com/ECRI40-Velocirabbit/scra…
WandefulWorld May 16, 2023
34bdeb9
Deconflicted with Dev
kyleslugg May 16, 2023
1f97ce7
Merge branch 'dev' into Ivy/new
kyleslugg May 16, 2023
907a583
Merge pull request #4 from ECRI40-Velocirabbit/Ivy/new
kyleslugg May 16, 2023
88f74cc
Merge branch 'dev' into ks
kyleslugg May 16, 2023
2df3f5b
Removed lingering merge comments
kyleslugg May 16, 2023
3bcc6f4
pulling
LeRocque May 16, 2023
9cee5d3
Merge remote-tracking branch 'origin/dev' into newTadd
LeRocque May 16, 2023
e577a05
The GET test keeps failing, so I changed the test.
jimpulsee May 16, 2023
1fe3c92
Fixing loading issues
kyleslugg May 16, 2023
20b5e9c
testing with anthentication url
WandefulWorld May 17, 2023
ebdd48f
auth started
LeRocque May 17, 2023
46fd371
Added lifecycle, setup methods to test suite
jimpulsee May 17, 2023
afbe9c3
signup refactored-ready
LeRocque May 17, 2023
5f011f0
completed POST request for snippets endpoint
jimpulsee May 17, 2023
233b556
Merge branch 'dev' into jb/tests
jimpulsee May 17, 2023
9e9daa4
Merge pull request #5 from ECRI40-Velocirabbit/jb/tests
kyleslugg May 17, 2023
3840695
Wrote tests for DELETE to snippets endpoint
jimpulsee May 17, 2023
cb3c919
Merge pull request #6 from ECRI40-Velocirabbit/newTadd
kyleslugg May 17, 2023
a8cc9d0
Latest updates to React and associated routes
kyleslugg May 17, 2023
2908471
Merge branch 'dev' into ks
kyleslugg May 17, 2023
7535ca4
login-ready
LeRocque May 17, 2023
8f28815
completed css styling for login, signup and main content, and built c…
WandefulWorld May 17, 2023
92eda36
Merge pull request #7 from ECRI40-Velocirabbit/newTadd
kyleslugg May 17, 2023
9508f25
Merge pull request #8 from ECRI40-Velocirabbit/Ivy/new
kyleslugg May 17, 2023
c2d15ad
Refactored Snippets test to be run consecutively
jimpulsee May 17, 2023
aa63977
Revised editing; working on tags display
kyleslugg May 17, 2023
b2a7ac2
Merged in latest on dev
kyleslugg May 17, 2023
b475635
wrote test for error handling
jimpulsee May 17, 2023
519c472
Merge branch 'dev' into jb/tests
jimpulsee May 17, 2023
a7574ee
pulling dev
LeRocque May 17, 2023
d96ef41
Merge remote-tracking branch 'origin/dev' into newTadd
LeRocque May 17, 2023
295277c
Merge pull request #9 from ECRI40-Velocirabbit/ks
jimpulsee May 17, 2023
51c0602
Merge branch 'dev' into jb/tests
jimpulsee May 17, 2023
9e3caa6
completed all functionality for front-end to interact with the back-e…
WandefulWorld May 17, 2023
59bdbe3
Merge pull request #10 from ECRI40-Velocirabbit/Ivy/new
kyleslugg May 17, 2023
b17f22d
Finished backend testing suite
jimpulsee May 17, 2023
dce5370
Merge branch 'dev' into jb/tests
jimpulsee May 17, 2023
4af6a0f
Additional styling, plus start of tags display
kyleslugg May 17, 2023
ebcc827
Merge branch 'dev' into ks
kyleslugg May 17, 2023
02356c8
Merge pull request #11 from ECRI40-Velocirabbit/jb/tests
LeRocque May 17, 2023
acd59d1
Merge pull request #12 from ECRI40-Velocirabbit/ks
LeRocque May 17, 2023
9932586
Minor stylistic changes
kyleslugg May 17, 2023
13539e6
Merge branch 'dev' into ks
kyleslugg May 17, 2023
2c748e6
working on cookie
LeRocque May 18, 2023
aabdcca
removed logs
LeRocque May 18, 2023
85823e6
removed unneeded require
LeRocque May 18, 2023
4ad4ce6
Merge pull request #13 from ECRI40-Velocirabbit/newTadd
kyleslugg May 18, 2023
74d1a9d
Added preliminary tag support, though not yet filtering
kyleslugg May 18, 2023
899717c
Merge branch 'dev' into ks
kyleslugg May 18, 2023
ed51c0e
Merge pull request #14 from ECRI40-Velocirabbit/ks
LeRocque May 18, 2023
fb7c0a1
updated styles
jimpulsee May 18, 2023
e8bd100
cookies-solved
LeRocque May 18, 2023
3b8e1a3
Merge pull request #15 from ECRI40-Velocirabbit/newTadd
kyleslugg May 18, 2023
ec174fb
a
kyleslugg May 18, 2023
64bfeb8
Merged in working authentication
kyleslugg May 18, 2023
5453e7e
Removed hardcoded user ID; now working with ID cookie
kyleslugg May 18, 2023
f9925a1
token-done
LeRocque May 18, 2023
2fe2b61
Merge branch 'dev' into newTadd
kyleslugg May 18, 2023
6ad8630
Merge pull request #17 from ECRI40-Velocirabbit/newTadd
kyleslugg May 18, 2023
1830660
Now with Passport authentication!
kyleslugg May 18, 2023
d7a2127
Merge branch 'dev' into j/styles
jimpulsee May 18, 2023
a7e2b90
Removed hard-coded userId; fetching user info from Passport middleware
kyleslugg May 18, 2023
3761e8d
Merge pull request #18 from ECRI40-Velocirabbit/ks
jimpulsee May 18, 2023
b0059cd
Now with filtering by tags
kyleslugg May 18, 2023
8e0dd2d
Merge branch 'dev' into ks
kyleslugg May 18, 2023
4a60f3e
greet user, logout button, sidebar position
jimpulsee May 18, 2023
b868ad9
Merge branch 'dev' into j/styles
jimpulsee May 18, 2023
5b122e6
auto login after sign up
jimpulsee May 18, 2023
1fc6c31
added feedback for copy
jimpulsee May 18, 2023
9dd2d36
Now with filtering by tags and scrolling list displays
kyleslugg May 18, 2023
8fcbc2b
responds to incorrect un or pw
jimpulsee May 18, 2023
eabb47a
Merge pull request #19 from ECRI40-Velocirabbit/j/styles
kyleslugg May 18, 2023
57366e0
Commiting prior to dev merge
kyleslugg May 18, 2023
e4f4c25
Merge branch 'dev' into ks
kyleslugg May 18, 2023
68b508e
Enhanced scrollbar styling, plus edit protection for all fields when …
kyleslugg May 18, 2023
acc563d
Merge pull request #20 from ECRI40-Velocirabbit/ks
jimpulsee May 18, 2023
4e0d3cd
added functionalities for user login and signup screen message when i…
WandefulWorld May 18, 2023
e775462
Merge branch 'dev' into Ivy/new
kyleslugg May 18, 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
5 changes: 3 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"env": {
"node": true,
"browser": true,
"es2021": true
"es2021": true,
"jest": true
},
"plugins": ["import", "react", "jsx-a11y", "css-modules"],
"extends": [
Expand Down Expand Up @@ -39,4 +40,4 @@
}
}
}
}
}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ package-lock.json
npm-debug.log*

# output from webpack
dist/
dist/

#environment file
.env
324 changes: 324 additions & 0 deletions __tests__/routes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,324 @@
const request = require('supertest');
const mongoose = require('mongoose');
const Users = require('../server/models/userModel');
const Snippets = require('../server/models/snippetModel');

require('dotenv').config();

const server = 'http://localhost:3000';
const mongoURI = process.env.MONGO_URI;

describe('Snippets route', () => {
let user;
let snippet_id;
const username = '__DummyData__';
const password = 'codesmith';
const snippet = {
title: 'FAKE DATA',
comments: 'FUN COMMENTS!',
storedCode: 'cry()',
tags: ['1', '2', '3'],
language: 'Klingon',
};
const newSnippet = {
title: 'NEW FAKE DATA',
comments: 'MORE FUN COMMENTS!',
storedCode: 'cryAgain()',
tags: ['4', '5', '6'],
language: 'Huttese',
};
describe('GET', () => {
//before all GET test:
beforeAll(async () => {
console.log('Connecting to the database!');
await mongoose.connect(mongoURI);

console.log('Creating dummy data!');
user = await Users.create({ username, password });

const fakeSnippet = await Snippets.create(snippet);
snippet_id = fakeSnippet._id;
user.snippets.push(fakeSnippet._id);

return user.save();
});

afterAll(async () => {
console.log('Deleting dummy data!');
await Users.findByIdAndDelete(user._id);
await Snippets.findByIdAndDelete(snippet_id);

console.log('Disconnecting from the database!');
return await mongoose.connection.close();
});
it('responds with 200 status and json', () => {
return request(server)
.get(`/snippets/?userId=${user._id}`)
.expect(200)
.expect('Content-Type', 'application/json; charset=utf-8');
});
it('responds with data that has keys: title, comments, storedCode, language', () => {
return request(server)
.get(`/snippets/?userId=${user._id}`)
.expect((res) => {
if (!res.body[0].hasOwnProperty('title')) {
throw new Error("Expected 'title' key!");
}
if (!res.body[0].hasOwnProperty('comments')) {
throw new Error("Expected 'comments' key!");
}
if (!res.body[0].hasOwnProperty('language')) {
throw new Error("Expected 'language' key!");
}
if (!res.body[0].hasOwnProperty('storedCode')) {
throw new Error("Expected 'storedCode' key!");
}
});
});
it('responds with data that has key, tags, and value of an array', () => {
return request(server)
.get(`/snippets/?userId=${user._id}`)
.expect((res) => {
if (!res.body[0].hasOwnProperty('tags')) {
throw new Error("Expected 'tags' key!");
}
if (!Array.isArray(res.body[0].tags)) {
throw new Error("Expected 'tags' to be an array!");
}
});
});
});
describe('POST', () => {
beforeAll(async () => {
console.log('Connecting to the database!');
await mongoose.connect(mongoURI);

console.log('Creating dummy data!');
user = await Users.create({ username, password });

return user.save();
});
afterAll(async () => {
console.log('Deleting dummy data!');

await Users.findByIdAndDelete(user._id);

console.log('Disconnecting from the database!');
return await mongoose.connection.close();
});
afterEach(async () => {
user = await Users.findById(user._id);
snippet_id = user.snippets.pop();
await user.save();
return await Snippets.findByIdAndDelete(snippet_id);
});
it('responds with 200 status and json', () => {
return request(server)
.post(`/snippets/?userId=${user._id}`)
.send(snippet)
.expect(200)
.expect('Content-Type', 'application/json; charset=utf-8');
});
it('responds with the newly created document', () => {
return request(server)
.post(`/snippets/?userId=${user._id}`)
.send(snippet)
.expect((res) => {
expect(res.body.title).toBe(snippet.title);
expect(res.body.comments).toBe(snippet.comments);
expect(res.body.storedCode).toBe(snippet.storedCode);
expect(res.body.language).toBe(snippet.language);
expect(res.body.tags).toEqual(snippet.tags);
});
});
it("pushes newly created document to user's snippets array", () => {
return request(server)
.post(`/snippets/?userId=${user._id}`)
.send(snippet)
.expect(async (res) => {
user = await Users.findById(user._id);
expect(user.snippets.length).toEqual(1);
});
});
});
describe('PUT', () => {
beforeAll(async () => {
console.log('Connecting to the database!');
await mongoose.connect(mongoURI);

console.log('Creating dummy data!');
user = await Users.create({ username, password });

const fakeSnippet = await Snippets.create(snippet);
snippet_id = fakeSnippet._id;

return;
});
afterEach(async () => {
return await Snippets.findByIdAndUpdate(snippet_id, snippet);
});
afterAll(async () => {
console.log('Deleting dummy data!');
await Snippets.findByIdAndDelete(snippet_id);
await Users.findByIdAndDelete(user._id);

console.log('Disconnecting from the database!');
return await mongoose.connection.close();
});
it('responds with 200 status and json', () => {
return request(server)
.put(`/snippets/?snippetId=${snippet_id}&userId=${user._id}`)
.send(newSnippet)
.expect(200)
.expect('Content-Type', 'application/json; charset=utf-8');
});
it('responds with unupdated document', () => {
return request(server)
.put(`/snippets/?snippetId=${snippet_id}&userId=${user._id}`)
.send(newSnippet)
.expect((res) => {
console.log(res.body);
expect(res.body.snippet.title).toEqual(snippet.title);
expect(res.body.snippet.comments).toEqual(snippet.comments);
expect(res.body.snippet.language).toEqual(snippet.language);
});
});
});
describe('DELETE', () => {
beforeAll(async () => {
console.log('Connecting to the database!');
await mongoose.connect(mongoURI);

console.log('Creating dummy data!');
return (user = await Users.create({ username, password }));
});
beforeEach(async () => {
const fakeSnippet = await Snippets.create(snippet);
snippet_id = fakeSnippet._id;
user.snippets.push(fakeSnippet._id);
return user.save();
});
afterAll(async () => {
console.log('Deleting dummy data!');
await Users.findByIdAndDelete(user._id);

console.log('Disconnecting from the database!');
return await mongoose.connection.close();
});
it('responds with 200 status and json', () => {
return request(server)
.delete(`/snippets/?userId=${user._id}&snippetId=${snippet_id}`)
.expect(200)
.expect('Content-Type', 'application/json; charset=utf-8');
});
it('responds with the deleted document', () => {
return request(server)
.delete(`/snippets/?userId=${user._id}&snippetId=${snippet_id}`)
.expect((res) => {
expect(res.body.snippet.title).toBe(snippet.title);
expect(res.body.snippet.comments).toBe(snippet.comments);
expect(res.body.snippet.storedCode).toBe(snippet.storedCode);
expect(res.body.snippet.language).toBe(snippet.language);
expect(res.body.snippet.tags).toEqual(snippet.tags);
});
});
it("removes delete document from user's snippets array", () => {
return request(server)
.delete(`/snippets/?userId=${user._id}&snippetId=${snippet_id}`)
.expect(async () => {
user = await Users.findById(user._id);
expect(user.snippets.length).toEqual(0);
});
});
});
});

describe('Authentication route', () => {
let user;
const username = '__DummyData__';
const password = 'codesmith';
const languages = ['klingon'];
const tags = ['1', '2', '3'];
describe('GET', () => {
beforeAll(async () => {
console.log('Connecting to the database!');
await mongoose.connect(mongoURI);

console.log('Creating dummy data!');
return (user = await Users.create({
username,
password,
languages,
tags,
}));
});
afterAll(async () => {
console.log('Deleting dummy data!');
await Users.findByIdAndDelete(user._id);

console.log('Disconnecting from database!');
return await mongoose.connection.close();
});
it('responds with 200 status and json', () => {
return request(server)
.get(`/authentication/?_id=${user._id}`)
.expect(200)
.expect('Content-Type', 'application/json; charset=utf-8');
});
it('responds with the correct user data', () => {
return request(server)
.get(`/authentication/?_id=${user._id}`)
.expect((res) => {
expect(res.body.username).toEqual(username);
expect(res.body.languages[0]).toBe(languages[0]);
expect(res.body.tags[0]).toBe(tags[0]);
});
});
});
describe('POST', () => {
beforeAll(async () => {
console.log('Connecting to the database!');
return await mongoose.connect(mongoURI);
});
afterEach(async () => {
console.log('Deleting dummy data!');
return await Users.findByIdAndDelete(user._id);
});
afterAll(async () => {
console.log('Disconnecting from database!');
return await mongoose.connection.close();
});
it('responds with 200 status and json', () => {
return request(server)
.post('/authentication/signup')
.send({ username, password })
.expect(201)
.expect('Content-Type', 'application/json; charset=utf-8')
.expect((res) => {
user = res.body;
});
});
it('responds with newly created user document', () => {
return request(server)
.post('/authentication/signup')
.send({ username, password })
.expect((res) => {
user = res.body;
expect(res.body.username).toEqual(username);
});
});
});
});

describe('Error handling', () => {
describe('Invalid route', () => {
it('it returns a 404 status and error message', () => {
return request(server)
.get('/lorem_ipsum')
.expect(404)
.expect((res) => {
expect(res.text).toEqual('Invalid endpoint');
});
});
});
});
7 changes: 5 additions & 2 deletions client/App.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import React from 'react';

// importing child components
import MainContainer from './src/containers/MainContainer/MainContainer.jsx';

const App = () => (
<div id="app">
<div id='app'>
<h1 id='headerTitle'>CODESNIPPET</h1>
<MainContainer />
</div>
);

export default App;
export default App;
Binary file modified client/src/assets/arrow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading