-
Notifications
You must be signed in to change notification settings - Fork 2
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
Test project routes #107
Open
Amal-Mousa
wants to merge
6
commits into
main
Choose a base branch
from
97-test-project-routes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Test project routes #107
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4c2b498
fix: test project route
Amal-Mousa 3dc3978
Merge branch 'main' into 97-test-project-routes
Amal-Mousa 2115b48
fix: test project routes
Amal-Mousa 8135c0b
feat: test project routes
Amal-Mousa 415152f
fix: resolve conflicts
Amal-Mousa c34acdf
fix: fix project routes
Amal-Mousa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import request from "supertest"; | ||
import dotenv from 'dotenv'; | ||
import app from "../src/app"; | ||
import buildDatabase from "../src/database/config/build"; | ||
import connection from "../src/database/config"; | ||
|
||
dotenv.config(); | ||
|
||
beforeAll(() => { | ||
buildDatabase(); | ||
}); | ||
|
||
// describe('Test Project Routes', () => { | ||
// test('Should add a new project', (done) => { | ||
// request(app) | ||
// .post('/project') | ||
// .set('cookie', `token=${process.env.TOKEN}`) | ||
// .send({ | ||
// title: 'Team-5', | ||
// description: 'This is team 5 project', | ||
// }) | ||
// .expect(201) | ||
// .end((err, res) => { | ||
// if (err) return done(err); | ||
// expect(res.body.message).toBe('New Project added Successfully') | ||
// expect(res.body.data.length).toBe(1); | ||
// done(); | ||
// }) | ||
// }); | ||
|
||
// test('Should return validation error for missing project title', (done) => { | ||
// request(app) | ||
// .post('/project') | ||
// .set('cookie', `token=${process.env.TOKEN}`) | ||
// .send({ | ||
// description: 'This is the description for the project', | ||
// }) | ||
// .expect(406) | ||
// .expect({'message': '\"title\" is required'}) | ||
// .end((err, res) => { | ||
// if (err) return done(err); | ||
// done(); | ||
// }); | ||
// }); | ||
|
||
// test('Should return validation error for missing project description', (done) => { | ||
// request(app) | ||
// .post('/project') | ||
// .set('cookie', `token=${process.env.TOKEN}`) | ||
// .send({ | ||
// title:'Team 5', | ||
// }) | ||
// .expect(406) | ||
// .end((err, res) => { | ||
// if (err) return done(err); | ||
// expect(res.body.message).toBe('\"description\" is required'); | ||
// done(); | ||
// }); | ||
// }); | ||
|
||
// }); | ||
|
||
|
||
describe('Get Project Route', () => { | ||
test('Should display projects', (done) => { | ||
request(app) | ||
.get('/projects') | ||
.set('cookie', `token=${process.env.TOKEN}`) | ||
.expect(200) | ||
.end((err, res) => { | ||
if (err) return done(err); | ||
expect(res.body.message).toBe('Show Projects Successfully'); | ||
// expect(res.body.data.length).toBe(2); | ||
console.log(res.body.data.length); | ||
|
||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
afterAll((done) => { | ||
connection.end(); | ||
done(); | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,82 @@ | ||
-- SQLBook: Code | ||
|
||
BEGIN; | ||
|
||
DROP TABLE IF EXISTS users, projects, tasks, project_users, roles, user_tasks , attachments, priorities, sections CASCADE; | ||
DROP TABLE | ||
IF EXISTS users, | ||
projects, | ||
tasks, | ||
project_users, | ||
roles, | ||
user_tasks, | ||
attachments, | ||
priorities, | ||
sections CASCADE; | ||
|
||
CREATE TABLE users( | ||
id SERIAL PRIMARY KEY , | ||
name VARCHAR(255) NOT NULL, | ||
email VARCHAR(255) UNIQUE NOT NULL, | ||
phone VARCHAR(60) NOT NULL, | ||
password VARCHAR(255) NOT NULL, | ||
created_at TIMESTAMP DEFAULT now() | ||
); | ||
CREATE TABLE | ||
users( | ||
id SERIAL PRIMARY KEY, | ||
name VARCHAR(255) NOT NULL, | ||
email VARCHAR(255) UNIQUE NOT NULL, | ||
phone VARCHAR(60) NOT NULL, | ||
password VARCHAR(255) NOT NULL, | ||
created_at TIMESTAMP DEFAULT now() | ||
); | ||
|
||
CREATE TABLE projects( | ||
id SERIAL PRIMARY KEY, | ||
title VARCHAR(255) NOT NULL, | ||
description TEXT, | ||
created_at TIMESTAMP DEFAULT now() | ||
); | ||
CREATE TABLE | ||
projects( | ||
id SERIAL PRIMARY KEY, | ||
title VARCHAR(255) NOT NULL, | ||
description TEXT, | ||
created_at TIMESTAMP DEFAULT now() | ||
); | ||
|
||
CREATE TABLE roles( | ||
id SERIAL PRIMARY KEY, | ||
role VARCHAR(55) NOT NULL | ||
); | ||
CREATE TABLE | ||
roles( | ||
id SERIAL PRIMARY KEY, | ||
role VARCHAR(55) NOT NULL | ||
); | ||
|
||
CREATE TABLE project_users( | ||
id SERIAL PRIMARY KEY, | ||
user_id INTEGER REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE, | ||
project_id INTEGER REFERENCES projects(id) ON UPDATE CASCADE ON DELETE CASCADE, | ||
role_id INTEGER REFERENCES roles(id) ON UPDATE CASCADE ON DELETE CASCADE | ||
); | ||
CREATE TABLE | ||
project_users( | ||
id SERIAL PRIMARY KEY, | ||
user_id INTEGER REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE, | ||
project_id INTEGER REFERENCES projects(id) ON UPDATE CASCADE ON DELETE CASCADE, | ||
role_id INTEGER REFERENCES roles(id) ON UPDATE CASCADE ON DELETE CASCADE | ||
); | ||
|
||
CREATE TABLE priorities( | ||
id SERIAL PRIMARY KEY, | ||
priority VARCHAR(55) NOT NULL, | ||
color VARCHAR(55) NOT NULL | ||
); | ||
CREATE TABLE | ||
priorities( | ||
id SERIAL PRIMARY KEY, | ||
priority VARCHAR(55) NOT NULL, | ||
color VARCHAR(55) NOT NULL | ||
); | ||
|
||
CREATE TABLE sections( | ||
id SERIAL PRIMARY KEY, | ||
section VARCHAR(55) NOT NULL | ||
); | ||
CREATE TABLE | ||
sections( | ||
id SERIAL PRIMARY KEY, | ||
section VARCHAR(55) NOT NULL | ||
); | ||
|
||
CREATE TABLE tasks( | ||
id SERIAL PRIMARY KEY, | ||
title VARCHAR(255) NOT NULL, | ||
description TEXT , | ||
created_at TIMESTAMP DEFAULT now(), | ||
due_date DATE, | ||
user_id INTEGER REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE, | ||
project_id INTEGER REFERENCES projects(id) ON UPDATE CASCADE ON DELETE CASCADE, | ||
priority_id INTEGER REFERENCES priorities(id) ON UPDATE CASCADE ON DELETE CASCADE, | ||
section_id INTEGER REFERENCES sections(id) ON UPDATE CASCADE ON DELETE CASCADE | ||
); | ||
CREATE TABLE | ||
tasks( | ||
id SERIAL PRIMARY KEY, | ||
title VARCHAR(255) NOT NULL, | ||
description TEXT, | ||
created_at TIMESTAMP DEFAULT now(), | ||
due_date DATE, | ||
user_id INTEGER REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE, | ||
project_id INTEGER REFERENCES projects(id) ON UPDATE CASCADE ON DELETE CASCADE, | ||
priority_id INTEGER REFERENCES priorities(id) ON UPDATE CASCADE ON DELETE CASCADE, | ||
section_id INTEGER REFERENCES sections(id) ON UPDATE CASCADE ON DELETE CASCADE | ||
); | ||
|
||
CREATE TABLE attachments( | ||
id SERIAL PRIMARY KEY , | ||
attach_s3 TEXT NOT NULL, | ||
user_id INTEGER REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE, | ||
task_id INTEGER REFERENCES tasks(id) ON UPDATE CASCADE ON DELETE CASCADE | ||
); | ||
CREATE TABLE | ||
attachments( | ||
id SERIAL PRIMARY KEY, | ||
attach_s3 TEXT NOT NULL, | ||
user_id INTEGER REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE, | ||
task_id INTEGER REFERENCES tasks(id) ON UPDATE CASCADE ON DELETE CASCADE | ||
); | ||
|
||
COMMIT; | ||
COMMIT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good Job Amal, but delete comments Please!!