Skip to content

Commit

Permalink
test(retain-old-grading-data-option): repo_browser_manual_collection_…
Browse files Browse the repository at this point in the history
…form
  • Loading branch information
pranavrao145 committed Oct 16, 2024
1 parent 76e1739 commit 70a407b
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import Modal from "react-modal";

describe("CollectSubmissionsModal", () => {
let props;
let component;

beforeEach(() => {
props = {
Expand All @@ -17,7 +16,7 @@ describe("CollectSubmissionsModal", () => {

// Set the app element for React Modal
Modal.setAppElement("body");
component = render(<CollectSubmissionsModal {...props} />);
render(<CollectSubmissionsModal {...props} />);
});

it("should display the option to recollect old submissions unchecked by default", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import * as React from "react";
import {render, screen} from "@testing-library/react";
import {ManualCollectionForm} from "../repo_browser";

describe("RepoBrowser's ManualCollectionForm", () => {
let props, component;

beforeEach(() => {
props = {
course_id: 1,
assignment_id: 2,
late_penalty: false,
grouping_id: 1,
revision_identifier: "test",
collected_revision_id: "test",
};

// Set the app element for React Modal
component = render(<ManualCollectionForm {...props} />);
});

it("shows the option to retain existing grading when there is a collected revision present", () => {
const lblRecollectExistingSubmissions = screen.getByTestId("lbl_retain_existing_grading");
const chkRecollectExistingSubmissions = screen.getByTestId("chk_retain_existing_grading");

expect(lblRecollectExistingSubmissions).toBeInTheDocument();
expect(chkRecollectExistingSubmissions).toBeInTheDocument();
});

it("does not show the option to retain existing grading when there is a not collected revision present", () => {
props.collected_revision_id = "";
component.rerender(<ManualCollectionForm {...props} />);

const lblRecollectExistingSubmissions = screen.queryByTestId("lbl_retain_existing_grading");
const chkRecollectExistingSubmissions = screen.queryByTestId("chk_retain_existing_grading");

expect(lblRecollectExistingSubmissions).not.toBeInTheDocument();
expect(chkRecollectExistingSubmissions).not.toBeInTheDocument();
});
});
7 changes: 6 additions & 1 deletion app/assets/javascripts/Components/repo_browser.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,15 @@ class ManualCollectionForm extends React.Component {
<input
type="checkbox"
name="retain_existing_grading"
data-testid="chk_retain_existing_grading"
checked={this.state.retainExistingGrading}
onChange={e => {
this.setState({retainExistingGrading: e.target.checked});
}}
/>
<label>{I18n.t("submissions.collect.retain_existing_grading")}</label>
<label data-testid="lbl_retain_existing_grading">
{I18n.t("submissions.collect.retain_existing_grading")}
</label>
</div>
)}
<button
Expand Down Expand Up @@ -215,3 +218,5 @@ class ManualCollectionForm extends React.Component {
export function makeRepoBrowser(elem, props) {
render(<RepoBrowser {...props} />, elem);
}

export {ManualCollectionForm};
4 changes: 3 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ module.exports = {
// globalTeardown: undefined,

// A set of global variables that need to be available in all test environments
// globals: {},
globals: {
AUTH_TOKEN: "test_auth_token",
},

// The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
// maxWorkers: "50%",
Expand Down

0 comments on commit 70a407b

Please sign in to comment.