Skip to content

Commit

Permalink
mutation passed and prettier run
Browse files Browse the repository at this point in the history
  • Loading branch information
Frank404NotFound committed May 30, 2024
1 parent 1f931db commit 53f8067
Show file tree
Hide file tree
Showing 2 changed files with 179 additions and 0 deletions.
135 changes: 135 additions & 0 deletions frontend/src/fixtures/sectionFixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,141 @@ export const threeSections = [
},
];

export const threeSectionsDiffQrts = [
{
courseInfo: {
quarter: "20221",
courseId: "ECE 1A -1",
title: "COMP ENGR SEMINAR",
description:
"Introductory seminar to expose students to a broad range of topics in computer engineering.",
},
section: {
enrollCode: "12583",
section: "0100",
session: null,
classClosed: null,
courseCancelled: null,
gradingOptionCode: null,
enrolledTotal: 84,
maxEnroll: 100,
secondaryStatus: null,
departmentApprovalRequired: false,
instructorApprovalRequired: false,
restrictionLevel: null,
restrictionMajor: "+PRCME+CMPEN",
restrictionMajorPass: null,
restrictionMinor: null,
restrictionMinorPass: null,
concurrentCourses: [],
timeLocations: [
{
room: "1260",
building: "PHELP",
roomCapacity: "90",
days: "M W ",
beginTime: "15:30",
endTime: "16:45",
},
],
instructors: [
{
instructor: "HESPANHA J P",
functionCode: "Teaching and in charge",
},
],
},
},
{
courseInfo: {
quarter: "20223",
courseId: "ECE 3A -1",
title: "COMPUTER ORGANIZATION",
description:
"Introduction to computer organization and architecture, including digital logic, instruction set architecture, memory hierarchy, and input/output systems.",
},
section: {
enrollCode: "12585",
section: "0300",
session: null,
classClosed: null,
courseCancelled: null,
gradingOptionCode: null,
enrolledTotal: 60,
maxEnroll: 70,
secondaryStatus: null,
departmentApprovalRequired: false,
instructorApprovalRequired: false,
restrictionLevel: null,
restrictionMajor: "+PRCME+CMPEN",
restrictionMajorPass: null,
restrictionMinor: null,
restrictionMinorPass: null,
concurrentCourses: [],
timeLocations: [
{
room: "2100",
building: "ENGR",
roomCapacity: "80",
days: "M W F ",
beginTime: "13:00",
endTime: "13:50",
},
],
instructors: [
{
instructor: "JOHNSON L",
functionCode: "Teaching and in charge",
},
],
},
},
{
courseInfo: {
quarter: "20222",
courseId: "ECE 2A -1",
title: "DIGITAL LOGIC DESIGN",
description:
"Introduction to digital logic design, including combinational and sequential circuits, logic gates, and Boolean algebra.",
},
section: {
enrollCode: "12584",
section: "0200",
session: null,
classClosed: null,
courseCancelled: null,
gradingOptionCode: null,
enrolledTotal: 75,
maxEnroll: 80,
secondaryStatus: null,
departmentApprovalRequired: false,
instructorApprovalRequired: false,
restrictionLevel: null,
restrictionMajor: "+PRCME+CMPEN",
restrictionMajorPass: null,
restrictionMinor: null,
restrictionMinorPass: null,
concurrentCourses: [],
timeLocations: [
{
room: "1124",
building: "HFH",
roomCapacity: null,
days: "T R ",
beginTime: "10:00",
endTime: "11:50",
},
],
instructors: [
{
instructor: "SMITH J",
functionCode: "Teaching but not in charge",
},
],
},
},
];

export const fiveSections = [
{
courseInfo: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import CourseOverTimeIndexPage from "main/pages/CourseOverTime/CourseOverTimeInd
import { apiCurrentUserFixtures } from "fixtures/currentUserFixtures";
import { systemInfoFixtures } from "fixtures/systemInfoFixtures";
import { threeSections } from "fixtures/sectionFixtures";
import { threeSectionsDiffQrts } from "fixtures/sectionFixtures";
import { allTheSubjects } from "fixtures/subjectFixtures";
import userEvent from "@testing-library/user-event";

Expand Down Expand Up @@ -95,4 +96,47 @@ describe("CourseOverTimeIndexPage tests", () => {

expect(screen.getByText("ECE 1A")).toBeInTheDocument();
});

test("sorts courses in descending order by quarter", async () => {
axiosMock.onGet("/api/UCSBSubjects/all").reply(200, allTheSubjects);
axiosMock
.onGet("/api/public/courseovertime/search")
.reply(200, threeSectionsDiffQrts);

render(
<QueryClientProvider client={queryClient}>
<MemoryRouter>
<CourseOverTimeIndexPage />
</MemoryRouter>
</QueryClientProvider>,
);

const selectStartQuarter = screen.getByLabelText("Start Quarter");
userEvent.selectOptions(selectStartQuarter, "20211");
const selectEndQuarter = screen.getByLabelText("End Quarter");
userEvent.selectOptions(selectEndQuarter, "20221");
const selectSubject = screen.getByLabelText("Subject Area");
userEvent.selectOptions(selectSubject, "ECE");
const enterCourseNumber = screen.getByLabelText(
"Course Number (Try searching '16' or '130A')",
);
userEvent.type(enterCourseNumber, "1");

const submitButton = screen.getByText("Submit");
expect(submitButton).toBeInTheDocument();
userEvent.click(submitButton);

await waitFor(() => {
expect(screen.getByText("COMP ENGR SEMINAR")).toBeInTheDocument();
});

const rows = screen.getAllByRole("row");
const [firstRow, secondRow, thirdRow] = rows
.slice(1, 4)
.map((row) => row.textContent);

expect(firstRow).toContain("M22");
expect(secondRow).toContain("S22");
expect(thirdRow).toContain("W22");
});
});

0 comments on commit 53f8067

Please sign in to comment.