Skip to content

Commit c8f5134

Browse files
committed
Merge branch 'kl/scrum-56-email-notifications' of https://github.com/UTSC-CSCC01-Software-Engineering-I/term-group-project-c01w25-project-course-matrix into kl/scrum-56-email-notifications
2 parents 75114d4 + 8a44705 commit c8f5134

File tree

5 files changed

+207
-126
lines changed

5 files changed

+207
-126
lines changed
Lines changed: 170 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { describe, expect, jest, test } from '@jest/globals';
2-
import { isDateBetween } from "../src/utils/compareDates"
1+
import { describe, expect, jest, test } from "@jest/globals";
2+
import { isDateBetween } from "../src/utils/compareDates";
33

44
// For testing purposes, we need to modify the function to accept a custom "now" date
55
// This allows us to test all scenarios regardless of the current date
66
function correctDay(offering: any, customNow?: Date): boolean {
7-
const weekdays = ["SU", "MO", "TU", "WE", "TH", "FR", "SA"]
7+
const weekdays = ["SU", "MO", "TU", "WE", "TH", "FR", "SA"];
88
const semester = offering?.offering;
99
const day = offering?.day;
1010
if (!semester || !day) return false;
@@ -14,12 +14,11 @@ function correctDay(offering: any, customNow?: Date): boolean {
1414
if (semester === "Summer 2025") {
1515
startDay = new Date(2025, 5, 2);
1616
endDay = new Date(2025, 8, 7);
17-
}
18-
else if (semester === "Fall 2025") {
17+
} else if (semester === "Fall 2025") {
1918
startDay = new Date(2025, 9, 3);
2019
endDay = new Date(2025, 12, 3);
21-
}
22-
else { // Winter 2026
20+
} else {
21+
// Winter 2026
2322
startDay = new Date(2026, 1, 6);
2423
endDay = new Date(2026, 4, 4);
2524
}
@@ -32,149 +31,225 @@ function correctDay(offering: any, customNow?: Date): boolean {
3231
return true;
3332
}
3433

35-
describe('correctDay function', () => {
36-
test('should return false for null or undefined offering', () => {
34+
describe("correctDay function", () => {
35+
test("should return false for null or undefined offering", () => {
3736
expect(correctDay(null)).toBe(false);
3837
expect(correctDay(undefined)).toBe(false);
3938
});
40-
41-
test('should return false for missing offering properties', () => {
39+
40+
test("should return false for missing offering properties", () => {
4241
expect(correctDay({})).toBe(false);
4342
expect(correctDay({ offering: "Summer 2025" })).toBe(false);
4443
expect(correctDay({ day: "MO" })).toBe(false);
4544
});
46-
47-
test('should validate correct day in Summer 2025', () => {
45+
46+
test("should validate correct day in Summer 2025", () => {
4847
// Create specific dates for each day of the week within Summer 2025
4948
const summerDates = [
50-
new Date(2025, 5, 8), // Sunday (June 8, 2025)
51-
new Date(2025, 5, 9), // Monday (June 9, 2025)
49+
new Date(2025, 5, 8), // Sunday (June 8, 2025)
50+
new Date(2025, 5, 9), // Monday (June 9, 2025)
5251
new Date(2025, 5, 10), // Tuesday (June 10, 2025)
5352
new Date(2025, 5, 11), // Wednesday (June 11, 2025)
5453
new Date(2025, 5, 12), // Thursday (June 12, 2025)
5554
new Date(2025, 5, 13), // Friday (June 13, 2025)
56-
new Date(2025, 5, 14) // Saturday (June 14, 2025)
55+
new Date(2025, 5, 14), // Saturday (June 14, 2025)
5756
];
58-
57+
5958
// Test each day with its corresponding date
6059
const weekdays = ["SU", "MO", "TU", "WE", "TH", "FR", "SA"];
6160
summerDates.forEach((date, index) => {
6261
// Make sure the getDay returns the expected index
63-
jest.spyOn(date, 'getDay').mockReturnValue(index);
64-
62+
jest.spyOn(date, "getDay").mockReturnValue(index);
63+
6564
// This should pass only for the matching day
66-
expect(correctDay({ offering: "Summer 2025", day: weekdays[index] }, date)).toBe(true);
67-
65+
expect(
66+
correctDay({ offering: "Summer 2025", day: weekdays[index] }, date),
67+
).toBe(true);
68+
6869
// Test all other days should fail
6970
weekdays.forEach((wrongDay, wrongIndex) => {
7071
if (wrongIndex !== index) {
71-
expect(correctDay({ offering: "Summer 2025", day: wrongDay }, date)).toBe(false);
72+
expect(
73+
correctDay({ offering: "Summer 2025", day: wrongDay }, date),
74+
).toBe(false);
7275
}
7376
});
7477
});
7578
});
76-
77-
test('should validate correct day in Fall 2025', () => {
79+
80+
test("should validate correct day in Fall 2025", () => {
7881
// Create a date in Fall 2025
7982
const fallDate = new Date(2025, 9, 15); // October 15, 2025
80-
83+
8184
// Mock getDay to return 3 (Wednesday)
82-
jest.spyOn(fallDate, 'getDay').mockReturnValue(3);
83-
85+
jest.spyOn(fallDate, "getDay").mockReturnValue(3);
86+
8487
// Test all days - only Wednesday should pass
85-
expect(correctDay({ offering: "Fall 2025", day: "WE" }, fallDate)).toBe(true);
86-
expect(correctDay({ offering: "Fall 2025", day: "SU" }, fallDate)).toBe(false);
87-
expect(correctDay({ offering: "Fall 2025", day: "MO" }, fallDate)).toBe(false);
88-
expect(correctDay({ offering: "Fall 2025", day: "TU" }, fallDate)).toBe(false);
89-
expect(correctDay({ offering: "Fall 2025", day: "TH" }, fallDate)).toBe(false);
90-
expect(correctDay({ offering: "Fall 2025", day: "FR" }, fallDate)).toBe(false);
91-
expect(correctDay({ offering: "Fall 2025", day: "SA" }, fallDate)).toBe(false);
88+
expect(correctDay({ offering: "Fall 2025", day: "WE" }, fallDate)).toBe(
89+
true,
90+
);
91+
expect(correctDay({ offering: "Fall 2025", day: "SU" }, fallDate)).toBe(
92+
false,
93+
);
94+
expect(correctDay({ offering: "Fall 2025", day: "MO" }, fallDate)).toBe(
95+
false,
96+
);
97+
expect(correctDay({ offering: "Fall 2025", day: "TU" }, fallDate)).toBe(
98+
false,
99+
);
100+
expect(correctDay({ offering: "Fall 2025", day: "TH" }, fallDate)).toBe(
101+
false,
102+
);
103+
expect(correctDay({ offering: "Fall 2025", day: "FR" }, fallDate)).toBe(
104+
false,
105+
);
106+
expect(correctDay({ offering: "Fall 2025", day: "SA" }, fallDate)).toBe(
107+
false,
108+
);
92109
});
93-
94-
test('should validate correct day in Winter 2026', () => {
110+
111+
test("should validate correct day in Winter 2026", () => {
95112
// Create a date in Winter 2026
96113
const winterDate = new Date(2026, 1, 20); // February 20, 2026
97-
114+
98115
// Mock getDay to return 5 (Friday)
99-
jest.spyOn(winterDate, 'getDay').mockReturnValue(5);
100-
116+
jest.spyOn(winterDate, "getDay").mockReturnValue(5);
117+
101118
// Test all days - only Friday should pass
102-
expect(correctDay({ offering: "Winter 2026", day: "FR" }, winterDate)).toBe(true);
103-
expect(correctDay({ offering: "Winter 2026", day: "SU" }, winterDate)).toBe(false);
104-
expect(correctDay({ offering: "Winter 2026", day: "MO" }, winterDate)).toBe(false);
105-
expect(correctDay({ offering: "Winter 2026", day: "TU" }, winterDate)).toBe(false);
106-
expect(correctDay({ offering: "Winter 2026", day: "WE" }, winterDate)).toBe(false);
107-
expect(correctDay({ offering: "Winter 2026", day: "TH" }, winterDate)).toBe(false);
108-
expect(correctDay({ offering: "Winter 2026", day: "SA" }, winterDate)).toBe(false);
119+
expect(correctDay({ offering: "Winter 2026", day: "FR" }, winterDate)).toBe(
120+
true,
121+
);
122+
expect(correctDay({ offering: "Winter 2026", day: "SU" }, winterDate)).toBe(
123+
false,
124+
);
125+
expect(correctDay({ offering: "Winter 2026", day: "MO" }, winterDate)).toBe(
126+
false,
127+
);
128+
expect(correctDay({ offering: "Winter 2026", day: "TU" }, winterDate)).toBe(
129+
false,
130+
);
131+
expect(correctDay({ offering: "Winter 2026", day: "WE" }, winterDate)).toBe(
132+
false,
133+
);
134+
expect(correctDay({ offering: "Winter 2026", day: "TH" }, winterDate)).toBe(
135+
false,
136+
);
137+
expect(correctDay({ offering: "Winter 2026", day: "SA" }, winterDate)).toBe(
138+
false,
139+
);
109140
});
110-
111-
test('should return false when date is outside semester range', () => {
141+
142+
test("should return false when date is outside semester range", () => {
112143
// Create dates outside each semester range
113144
const beforeSummer = new Date(2025, 5, 1); // June 1, 2025 (before Summer 2025)
114-
const afterSummer = new Date(2025, 8, 8); // September 8, 2025 (after Summer 2025)
115-
const beforeFall = new Date(2025, 9, 2); // October 2, 2025 (before Fall 2025)
116-
const afterFall = new Date(2025, 12, 4); // December 4, 2025 (after Fall 2025)
145+
const afterSummer = new Date(2025, 8, 8); // September 8, 2025 (after Summer 2025)
146+
const beforeFall = new Date(2025, 9, 2); // October 2, 2025 (before Fall 2025)
147+
const afterFall = new Date(2025, 12, 4); // December 4, 2025 (after Fall 2025)
117148
const beforeWinter = new Date(2026, 1, 5); // February 5, 2026 (before Winter 2026)
118-
const afterWinter = new Date(2026, 4, 5); // May 5, 2026 (after Winter 2026)
119-
149+
const afterWinter = new Date(2026, 4, 5); // May 5, 2026 (after Winter 2026)
150+
120151
// Mock getDay to return 0 (Sunday) for all dates
121-
const testDates = [beforeSummer, afterSummer, beforeFall, afterFall, beforeWinter, afterWinter];
122-
testDates.forEach(date => {
123-
jest.spyOn(date, 'getDay').mockReturnValue(0);
152+
const testDates = [
153+
beforeSummer,
154+
afterSummer,
155+
beforeFall,
156+
afterFall,
157+
beforeWinter,
158+
afterWinter,
159+
];
160+
testDates.forEach((date) => {
161+
jest.spyOn(date, "getDay").mockReturnValue(0);
124162
});
125-
163+
126164
// Test dates outside Summer 2025
127-
expect(correctDay({ offering: "Summer 2025", day: "SU" }, beforeSummer)).toBe(false);
128-
expect(correctDay({ offering: "Summer 2025", day: "SU" }, afterSummer)).toBe(false);
129-
165+
expect(
166+
correctDay({ offering: "Summer 2025", day: "SU" }, beforeSummer),
167+
).toBe(false);
168+
expect(
169+
correctDay({ offering: "Summer 2025", day: "SU" }, afterSummer),
170+
).toBe(false);
171+
130172
// Test dates outside Fall 2025
131-
expect(correctDay({ offering: "Fall 2025", day: "SU" }, beforeFall)).toBe(false);
132-
expect(correctDay({ offering: "Fall 2025", day: "SU" }, afterFall)).toBe(false);
133-
173+
expect(correctDay({ offering: "Fall 2025", day: "SU" }, beforeFall)).toBe(
174+
false,
175+
);
176+
expect(correctDay({ offering: "Fall 2025", day: "SU" }, afterFall)).toBe(
177+
false,
178+
);
179+
134180
// Test dates outside Winter 2026
135-
expect(correctDay({ offering: "Winter 2026", day: "SU" }, beforeWinter)).toBe(false);
136-
expect(correctDay({ offering: "Winter 2026", day: "SU" }, afterWinter)).toBe(false);
181+
expect(
182+
correctDay({ offering: "Winter 2026", day: "SU" }, beforeWinter),
183+
).toBe(false);
184+
expect(
185+
correctDay({ offering: "Winter 2026", day: "SU" }, afterWinter),
186+
).toBe(false);
137187
});
138-
139-
test('should return true for dates inside semester range', () => {
188+
189+
test("should return true for dates inside semester range", () => {
140190
// Create dates inside each semester range
141191
const duringSummer = new Date(2025, 6, 15); // July 15, 2025 (during Summer 2025)
142-
const duringFall = new Date(2025, 10, 15); // November 15, 2025 (during Fall 2025)
192+
const duringFall = new Date(2025, 10, 15); // November 15, 2025 (during Fall 2025)
143193
const duringWinter = new Date(2026, 2, 15); // March 15, 2026 (during Winter 2026)
144-
194+
145195
// Mock getDay to return 0 (Sunday) for all dates
146196
const testDates = [duringSummer, duringFall, duringWinter];
147-
testDates.forEach(date => {
148-
jest.spyOn(date, 'getDay').mockReturnValue(0);
197+
testDates.forEach((date) => {
198+
jest.spyOn(date, "getDay").mockReturnValue(0);
149199
});
150-
200+
151201
// Test dates inside each semester (with matching day)
152-
expect(correctDay({ offering: "Summer 2025", day: "SU" }, duringSummer)).toBe(true);
153-
expect(correctDay({ offering: "Fall 2025", day: "SU" }, duringFall)).toBe(true);
154-
expect(correctDay({ offering: "Winter 2026", day: "SU" }, duringWinter)).toBe(true);
202+
expect(
203+
correctDay({ offering: "Summer 2025", day: "SU" }, duringSummer),
204+
).toBe(true);
205+
expect(correctDay({ offering: "Fall 2025", day: "SU" }, duringFall)).toBe(
206+
true,
207+
);
208+
expect(
209+
correctDay({ offering: "Winter 2026", day: "SU" }, duringWinter),
210+
).toBe(true);
155211
});
156-
157-
test('should validate edge dates correctly', () => {
212+
213+
test("should validate edge dates correctly", () => {
158214
// Test exact start and end dates of semesters
159-
const summerStart = new Date(2025, 5, 2); // June 2, 2025
160-
const summerEnd = new Date(2025, 8, 7); // September 7, 2025
161-
const fallStart = new Date(2025, 9, 3); // October 3, 2025
162-
const fallEnd = new Date(2025, 12, 3); // December 3, 2025
163-
const winterStart = new Date(2026, 1, 6); // February 6, 2026
164-
const winterEnd = new Date(2026, 4, 4); // May 4, 2026
165-
215+
const summerStart = new Date(2025, 5, 2); // June 2, 2025
216+
const summerEnd = new Date(2025, 8, 7); // September 7, 2025
217+
const fallStart = new Date(2025, 9, 3); // October 3, 2025
218+
const fallEnd = new Date(2025, 12, 3); // December 3, 2025
219+
const winterStart = new Date(2026, 1, 6); // February 6, 2026
220+
const winterEnd = new Date(2026, 4, 4); // May 4, 2026
221+
166222
// Mock getDay to return 0 (Sunday) for all dates
167-
const edgeDates = [summerStart, summerEnd, fallStart, fallEnd, winterStart, winterEnd];
168-
edgeDates.forEach(date => {
169-
jest.spyOn(date, 'getDay').mockReturnValue(0);
223+
const edgeDates = [
224+
summerStart,
225+
summerEnd,
226+
fallStart,
227+
fallEnd,
228+
winterStart,
229+
winterEnd,
230+
];
231+
edgeDates.forEach((date) => {
232+
jest.spyOn(date, "getDay").mockReturnValue(0);
170233
});
171-
234+
172235
// Edge dates should be included in the valid range
173-
expect(correctDay({ offering: "Summer 2025", day: "SU" }, summerStart)).toBe(true);
174-
expect(correctDay({ offering: "Summer 2025", day: "SU" }, summerEnd)).toBe(true);
175-
expect(correctDay({ offering: "Fall 2025", day: "SU" }, fallStart)).toBe(true);
176-
expect(correctDay({ offering: "Fall 2025", day: "SU" }, fallEnd)).toBe(true);
177-
expect(correctDay({ offering: "Winter 2026", day: "SU" }, winterStart)).toBe(true);
178-
expect(correctDay({ offering: "Winter 2026", day: "SU" }, winterEnd)).toBe(true);
236+
expect(
237+
correctDay({ offering: "Summer 2025", day: "SU" }, summerStart),
238+
).toBe(true);
239+
expect(correctDay({ offering: "Summer 2025", day: "SU" }, summerEnd)).toBe(
240+
true,
241+
);
242+
expect(correctDay({ offering: "Fall 2025", day: "SU" }, fallStart)).toBe(
243+
true,
244+
);
245+
expect(correctDay({ offering: "Fall 2025", day: "SU" }, fallEnd)).toBe(
246+
true,
247+
);
248+
expect(
249+
correctDay({ offering: "Winter 2026", day: "SU" }, winterStart),
250+
).toBe(true);
251+
expect(correctDay({ offering: "Winter 2026", day: "SU" }, winterEnd)).toBe(
252+
true,
253+
);
179254
});
180-
});
255+
});

course-matrix/backend/src/db/setupDb.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ export const supabaseServersideClient = createClient(
1818
config.DATABASE_KEY!,
1919
{
2020
auth: {
21-
persistSession: false
22-
}
23-
}
21+
persistSession: false,
22+
},
23+
},
2424
);
2525

2626
console.log("Connected to Supabase Client!");
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import * as React from "react"
2-
import * as SwitchPrimitives from "@radix-ui/react-switch"
1+
import * as React from "react";
2+
import * as SwitchPrimitives from "@radix-ui/react-switch";
33

4-
import { cn } from "@/lib/utils"
4+
import { cn } from "@/lib/utils";
55

66
const Switch = React.forwardRef<
77
React.ElementRef<typeof SwitchPrimitives.Root>,
@@ -10,18 +10,18 @@ const Switch = React.forwardRef<
1010
<SwitchPrimitives.Root
1111
className={cn(
1212
"peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",
13-
className
13+
className,
1414
)}
1515
{...props}
1616
ref={ref}
1717
>
1818
<SwitchPrimitives.Thumb
1919
className={cn(
20-
"pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0"
20+
"pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0",
2121
)}
2222
/>
2323
</SwitchPrimitives.Root>
24-
))
25-
Switch.displayName = SwitchPrimitives.Root.displayName
24+
));
25+
Switch.displayName = SwitchPrimitives.Root.displayName;
2626

27-
export { Switch }
27+
export { Switch };

0 commit comments

Comments
 (0)