Skip to content
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

Add home page, trial functionality #167

Merged
merged 36 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
5098ed6
add home page
LMAOboxhack Mar 28, 2024
e62a421
update package-lock
LMAOboxhack Mar 28, 2024
0bae44a
formatting
LMAOboxhack Mar 28, 2024
67d3dea
formatting
LMAOboxhack Mar 28, 2024
3ab556c
add course start date
LMAOboxhack Mar 29, 2024
a8cc6e1
formatting
LMAOboxhack Mar 29, 2024
d4bba9b
add unit tests
LMAOboxhack Mar 29, 2024
2773243
add startDate to course tests
LMAOboxhack Mar 29, 2024
3dc3b85
fix missing startDate for tests
LMAOboxhack Mar 29, 2024
5f1eeb4
update package-lo k
LMAOboxhack Mar 29, 2024
befb736
add unit tests for utils
LMAOboxhack Mar 29, 2024
8fd6292
add service tests
LMAOboxhack Mar 30, 2024
54e8c50
fix tests
LMAOboxhack Mar 30, 2024
00810db
fix tests
LMAOboxhack Mar 30, 2024
d5778f7
fix tests
LMAOboxhack Mar 30, 2024
7c6f003
add auth test
LMAOboxhack Mar 30, 2024
07aebe1
add auth tests
LMAOboxhack Mar 30, 2024
a7c245a
fix auth tests
LMAOboxhack Mar 30, 2024
5852f65
fix auth tests
LMAOboxhack Mar 30, 2024
bd144dd
fix auth tests
LMAOboxhack Mar 30, 2024
422e6b3
fix auth tests
LMAOboxhack Mar 30, 2024
1643738
auth test fix
LMAOboxhack Mar 30, 2024
e3534aa
fix auth tests
LMAOboxhack Mar 30, 2024
3c800d3
fix auth tests
LMAOboxhack Mar 30, 2024
b5da16e
add courseService tests
LMAOboxhack Mar 30, 2024
2705582
fix courseService tests
LMAOboxhack Mar 30, 2024
f2101ab
add teamService tests
LMAOboxhack Mar 30, 2024
34f25e1
bump deps
LMAOboxhack Mar 30, 2024
d7ac553
minor ui updates
LMAOboxhack Mar 31, 2024
e3125d4
finish tutorial
LMAOboxhack Apr 1, 2024
c82a3c3
Merge branch 'staging' into fy-s2-s6
LMAOboxhack Apr 1, 2024
292938f
fix merge conflicts
LMAOboxhack Apr 1, 2024
01be5b7
fix courseService tests
LMAOboxhack Apr 1, 2024
a3f0eee
add githubService tests
LMAOboxhack Apr 2, 2024
06c69dc
update .env.example
LMAOboxhack Apr 2, 2024
1bfa64b
Merge branch 'fy-s2-s6' of https://github.com/NUS-CRISP/CRISP into fy…
LMAOboxhack Apr 2, 2024
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
Prev Previous commit
Next Next commit
Merge branch 'staging' into fy-s2-s6
  • Loading branch information
LMAOboxhack committed Apr 1, 2024
commit c82a3c3d638fe914bf4572f28e3fe4ec1a446563
3 changes: 3 additions & 0 deletions backend/controllers/courseController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export const getCourses = async (req: Request, res: Response) => {
export const getCourse = async (req: Request, res: Response) => {
const courseId = req.params.id;
try {
const accountId = await getAccountId(req);
const accountId = await getAccountId(req);
const course = await getCourseById(courseId, accountId);
res.status(200).json(course);
Expand Down Expand Up @@ -247,6 +248,8 @@ export const removeTAs = async (req: Request, res: Response) => {
if (error instanceof NotFoundError) {
res.status(404).json({ error: error.message });
} else {
console.error('Error removing TAs:', error);
res.status(500).json({ error: 'Failed to remove TAs' });
console.error('Error removing tas:', error);
res.status(500).json({ error: 'Failed to remove TAs' });
}
Expand Down
88 changes: 48 additions & 40 deletions backend/test/controllers/accountController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
getPendingAccounts,
rejectAccounts,
} from '../../controllers/accountController';
import * as accountService from '../../services/accountService';
import { BadRequestError, NotFoundError } from '../../services/errors';

jest.mock('../../services/accountService');
Expand Down Expand Up @@ -187,7 +186,7 @@ describe('accountController', () => {

jest
.spyOn(accountService, 'rejectAccountByIds')
.mockRejectedValue(new Error('Error rejecting accounts'));
.mockRejectedValue(new Error('Error approving accounts'));

await rejectAccounts(req, res);

Expand All @@ -196,57 +195,66 @@ describe('accountController', () => {
error: 'Error rejecting accounts',
});
});
});

describe('getAccountStatuses', () => {
it('should retrieve account statuses and send a 200 status', async () => {
const req = mockRequest();
const res = mockResponse();
const mockStatuses: Record<string, boolean> = {
'123': true,
'456': false,
};
req.query = { ids: '123,456' };
describe('getAccountStatusesByUserIds', () => {
it('should return account statuses for given user IDs', async () => {
const req = mockRequest();
req.query = { ids: 'id1,id2' };
const res = mockResponse();
const mockStatuses = { id1: true, id2: false };

jest
.spyOn(accountService, 'getAccountStatusesByUserIds')
.mockResolvedValue(mockStatuses);
jest
.spyOn(accountService, 'getAccountStatusesByUserIds')
.mockResolvedValue(mockStatuses);

await getAccountStatuses(req, res);
await getAccountStatuses(req, res);

expect(res.status).toHaveBeenCalledWith(200);
expect(res.send).toHaveBeenCalledWith(mockStatuses);
expect(res.status).toHaveBeenCalledWith(200);
expect(res.send).toHaveBeenCalledWith(mockStatuses);
});

it('should handle invalid IDs and send a 400 status', async () => {
const req = mockRequest();
const res = mockResponse();

await getAccountStatuses(req, res);

expect(res.status).toHaveBeenCalledWith(400);
expect(res.send).toHaveBeenCalledWith({
error: 'Invalid or missing IDs',
});
});

it('should handle NotFoundError and send a 404 status', async () => {
const req = mockRequest();
const res = mockResponse();
req.query = { ids: '123,456' };
it('should handle NotFound and send a 404 status', async () => {
const req = mockRequest();
req.query = { ids: 'id1,id2' };
const res = mockResponse();

jest
.spyOn(accountService, 'getAccountStatusesByUserIds')
.mockRejectedValue(new NotFoundError('User not found'));
jest
.spyOn(accountService, 'getAccountStatusesByUserIds')
.mockRejectedValue(new NotFoundError('No accounts found'));

await getAccountStatuses(req, res);
await getAccountStatuses(req, res);

expect(res.status).toHaveBeenCalledWith(404);
expect(res.send).toHaveBeenCalledWith({ error: 'User not found' });
});
expect(res.status).toHaveBeenCalledWith(404);
expect(res.send).toHaveBeenCalledWith({ error: 'No accounts found' });
});

it('should handle error and send a 500 status', async () => {
const req = mockRequest();
const res = mockResponse();
req.query = { ids: '123,456' };
it('should handle error and send a 500 status', async () => {
const req = mockRequest();
req.query = { ids: 'id1,id2' };
const res = mockResponse();

jest
.spyOn(accountService, 'getAccountStatusesByUserIds')
.mockRejectedValue(new Error('Error getting account statuses'));
jest
.spyOn(accountService, 'getAccountStatusesByUserIds')
.mockRejectedValue(new Error('Error getting account statuses'));

await getAccountStatuses(req, res);
await getAccountStatuses(req, res);

expect(res.status).toHaveBeenCalledWith(500);
expect(res.send).toHaveBeenCalledWith({
error: 'Error getting account statuses',
});
expect(res.status).toHaveBeenCalledWith(500);
expect(res.send).toHaveBeenCalledWith({
error: 'Error getting account statuses',
});
});
});
Expand Down
Loading
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.