Skip to content

Commit 32c3d64

Browse files
author
Mateo
committed
ISSUE:7677: Update test cases
1 parent 3373c53 commit 32c3d64

File tree

2 files changed

+52
-9
lines changed

2 files changed

+52
-9
lines changed

app/javascript/Components/__tests__/groups_manager.test.jsx

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {render} from "@testing-library/react";
1+
import {render, screen} from "@testing-library/react";
22
import {GroupsManager} from "../groups_manager";
33
import {beforeEach, describe, expect, it} from "@jest/globals";
44

@@ -21,17 +21,47 @@ const groupMock = [
2121
display_label: "(inviter)",
2222
},
2323
],
24+
extension: {
25+
apply_penalty: false,
26+
grouping_id: 22,
27+
id: null,
28+
note: "",
29+
},
2430
section: "",
2531
},
32+
{
33+
group_name: "student1",
34+
inactive: false,
35+
instructor_approved: true,
36+
members: [
37+
{
38+
0: "student1",
39+
1: "inviter",
40+
2: false,
41+
display_label: "(inviter)",
42+
},
43+
],
44+
section: "",
45+
extension: {
46+
apply_penalty: true,
47+
days: 2,
48+
grouping_id: 16,
49+
hours: 0,
50+
id: 51,
51+
minutes: 0,
52+
note: "",
53+
weeks: 0,
54+
},
55+
},
2656
];
2757
const studentMock = [
2858
{
2959
assigned: true,
30-
first_name: "Magnard",
60+
first_name: "coolStudent",
3161
hidden: false,
3262
id: 8,
3363
last_name: "Alberic",
34-
user_name: "c9magnar",
64+
user_name: "student1",
3565
},
3666
];
3767

@@ -46,15 +76,23 @@ describe("GroupsManager", () => {
4676
json: jest.fn().mockResolvedValueOnce({
4777
templates: [],
4878
groups: groupMock,
79+
exam_templates: [],
4980
students: studentMock,
5081
clone_assignments: [],
5182
}),
5283
});
5384
const props = {
5485
course_id: 1,
86+
timed: false,
5587
assignment_id: 2,
88+
scanned_exam: false,
89+
examTemplates: [],
90+
times: ["weeks", "days", "hours", "minutes"],
5691
};
5792
render(<GroupsManager {...props} ref={wrapper} />);
93+
// wait for page to load and render content
94+
await screen.findByText("abcd").catch(err => err);
95+
// to view screen render: screen.debug(undefined, 300000)
5896
});
5997

6098
describe("DueDateExtensions", () => {
@@ -63,6 +101,11 @@ describe("GroupsManager", () => {
63101
wrapper.current.groupsTable.wrapped.checkboxTable.props.columns[5].filterMethod;
64102
});
65103

104+
it("append (Late Submissions Accepted) to assignments with extensions", async () => {
105+
const searchTerm = I18n.t("groups.late_submissions_accepted");
106+
expect(await screen.getByText(new RegExp(searchTerm, "i"))).toBeInTheDocument();
107+
});
108+
66109
it("returns true when the selected value is all", () => {
67110
expect(filter_method({value: "all"})).toEqual(true);
68111
});
@@ -74,7 +117,7 @@ describe("GroupsManager", () => {
74117
expect(filter_method({value: filterOptionsMock}, rowMock)).toEqual(true);
75118
});
76119
it("returns false when assignments with an extension are present", () => {
77-
const rowMock = {_original: {extension: {weeks: 1}}};
120+
const rowMock = {_original: {extension: {hours: 1}}};
78121
const filterOptionsMock = JSON.stringify({withExtension: false});
79122
expect(filter_method({value: filterOptionsMock}, rowMock)).toEqual(false);
80123
});
@@ -83,7 +126,7 @@ describe("GroupsManager", () => {
83126
describe("withExtension: true", () => {
84127
describe("withLateSubmission: true", () => {
85128
it("returns true when assignments have a late submission rule applied", () => {
86-
const rowMock = {_original: {extension: {weeks: 1, apply_penalty: true}}};
129+
const rowMock = {_original: {extension: {hours: 1, apply_penalty: true}}};
87130
const filterOptionsMock = JSON.stringify({withExtension: true, withLateSubmission: true});
88131
expect(filter_method({value: filterOptionsMock}, rowMock)).toEqual(true);
89132
});
@@ -95,7 +138,7 @@ describe("GroupsManager", () => {
95138
});
96139
describe("withLateSubmission: false", () => {
97140
it("returns true when assignments are missing an extension", () => {
98-
const rowMock = {_original: {extension: {weeks: 1, apply_penalty: true}}};
141+
const rowMock = {_original: {extension: {hours: 1, apply_penalty: true}}};
99142
const filterOptionsMock = JSON.stringify({
100143
withExtension: true,
101144
withLateSubmission: false,
@@ -104,7 +147,7 @@ describe("GroupsManager", () => {
104147
});
105148

106149
it("returns false when assignments have a late submission rule applied", () => {
107-
const rowMock = {_original: {extension: {weeks: 1, apply_penalty: true}}};
150+
const rowMock = {_original: {extension: {hours: 1, apply_penalty: true}}};
108151
const filterOptionsMock = JSON.stringify({
109152
withExtension: true,
110153
withLateSubmission: false,

app/javascript/Components/groups_manager.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -614,8 +614,8 @@ class RawGroupsTable extends React.Component {
614614
}
615615
const applyPenalty = row._original.extension.apply_penalty;
616616
const {withExtension, withLateSubmission} = JSON.parse(filter.value);
617-
// If there is an extension applied, the extension object will contain a property called weeks
618-
const hasExtension = Object.hasOwn(row._original.extension, "weeks");
617+
// If there is an extension applied, the extension object will contain a property called hours
618+
const hasExtension = Object.hasOwn(row._original.extension, "hours");
619619

620620
if (!withExtension) {
621621
return !hasExtension;

0 commit comments

Comments
 (0)