Skip to content

Commit

Permalink
Merge pull request #792 from Lunatic-Labs/SKIL-565
Browse files Browse the repository at this point in the history
SKIL-565
  • Loading branch information
aparriaran authored Dec 2, 2024
2 parents 1d63b1e + b1e1472 commit 675590a
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 45 deletions.
52 changes: 44 additions & 8 deletions FrontEndReact/src/View/Admin/Add/AddCourse/AdminAddCourse.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import validator from "validator";
import ErrorMessage from "../../../Error/ErrorMessage.js";
import { genericResourcePOST, genericResourcePUT } from "../../../../utility.js";
import Cookies from "universal-cookie";
import { Box, Button, FormControl, Typography, TextField, FormControlLabel, Checkbox, FormGroup, } from "@mui/material";
import HelpOutlineIcon from "@mui/icons-material/HelpOutline";
import { Box, Button, FormControl, Typography, Popover, TextField, Tooltip, IconButton, FormControlLabel, Checkbox, FormGroup, } from "@mui/material";



Expand All @@ -25,7 +26,8 @@ class AdminAddCourse extends Component {
year: "",
active: true,
useTas: true,
useFixedTeams: true,
useFixedTeams: true,
anchorEl: null,

errors: {
courseName: "",
Expand All @@ -34,8 +36,13 @@ class AdminAddCourse extends Component {
year: "",
},
};

}

setAnchorEl = (element) => {
this.setState({ anchorEl: element });
};

componentDidMount() {
var navbar = this.props.navbar;
var state = navbar.state;
Expand All @@ -56,6 +63,13 @@ class AdminAddCourse extends Component {
});
}
}
handleClick = (event) => {
this.setAnchorEl(event.currentTarget);
};

handleClose = () => {
this.setAnchorEl(null);
};

handleChange = (e) => {
const { id, value } = e.target;
Expand Down Expand Up @@ -144,9 +158,6 @@ class AdminAddCourse extends Component {
if (term.trim() === "")
newErrors["term"] = "Term cannot be empty";

else if (term.trim() !== "Spring" && term.trim() !== "Fall" && term.trim() !== "Summer")
newErrors["term"] = "Term should be either Spring, Fall, or Summer";

if (newErrors["courseName"] !== "" || newErrors["courseNumber"] !== "" ||newErrors["year"] !== "" ||newErrors["term"] !== "") {
this.setState({
errors: newErrors
Expand Down Expand Up @@ -208,6 +219,8 @@ class AdminAddCourse extends Component {
var navbar = this.props.navbar;
var state = navbar.state;
var addCourse = state.addCourse;
const open = Boolean(this.state.anchorEl);
const id = open ? 'simple-popover' : undefined;

return (
<React.Fragment>
Expand Down Expand Up @@ -266,7 +279,7 @@ class AdminAddCourse extends Component {
id="term"
name="newTerm"
variant="outlined"
label="Term"
label="Type your Term name here"
fullWidth
value={term}
error={!!errors.term}
Expand Down Expand Up @@ -344,8 +357,31 @@ class AdminAddCourse extends Component {
}

name="newFixedTeams"
label="Fixed Team"
/>
label="Fixed Teams"
/>
<div style={{padding: '3px'}}>
<Tooltip title="Help">
<IconButton aria-label="help" onClick={this.handleClick}>
<HelpOutlineIcon />
</IconButton>
</Tooltip>
</div>
<Popover
id={id}
open={open}
anchorEl={this.state.anchorEl}
onClose={this.handleClose}
anchorOrigin={{
vertical: 'bottom',
horizontal: 'left',
}}
>
<Typography sx={{ p: 2 }}>Active: Uncheck this box at the end of the term to move it to the Inactive Courses table.<br>
</br>Use TA's:
Will you use Teaching or Learning Assistants in this course to fill out rubrics?<br>
</br>Fixed teams: Do you assign students to the same team for the entire semester?</Typography>
</Popover>

</FormGroup>

<Box
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,39 +224,7 @@ test("AdminAddCourse.test.js Test 7: HelperText error should show for the addCou
});
});


test("AdminAddCourse.test.js Test 8: HelperText error should show for the addCourseTerm text field when input is not 'Fall', 'Spring' or 'Summer'", async () => {
render(<Login />);

await waitFor(() => {
expectElementWithAriaLabelToBeInDocument(ct);
});

clickElementWithAriaLabel(ac);

await waitFor(() => {
expectElementWithAriaLabelToBeInDocument(act);
});

changeElementWithAriaLabelWithInput(cnami, "Object Oriented Programming");

changeElementWithAriaLabelWithInput(cnumi, "CS3423");

changeElementWithAriaLabelWithInput(cti, "A");

changeElementWithAriaLabelWithInput(cyi, "2025");

clickElementWithAriaLabel(aosacb);

await waitFor(() => {
expectElementWithAriaLabelToBeInDocument(acf);

expectElementWithAriaLabelToHaveErrorMessage(cti, "Term should be either Spring, Fall, or Summer");
});
});


test("AdminAddCourse.test.js Test 9: HelperText error should show for the addCourseYear text field when input is less than 2023", async () => {
test("AdminAddCourse.test.js Test 8: HelperText error should show for the addCourseYear text field when input is less than 2023", async () => {
render(<Login />);

await waitFor(() => {
Expand Down Expand Up @@ -287,7 +255,7 @@ test("AdminAddCourse.test.js Test 9: HelperText error should show for the addCou
});


test("AdminAddCourse.test.js Test 10: HelperText error should show for the addCourseYear text field when input is not a numeric value", async () => {
test("AdminAddCourse.test.js Test 9: HelperText error should show for the addCourseYear text field when input is not a numeric value", async () => {
render(<Login />);

await waitFor(() => {
Expand Down Expand Up @@ -318,7 +286,7 @@ test("AdminAddCourse.test.js Test 10: HelperText error should show for the addCo
});


test("AdminAddCourse.test.js Test 11: Filling in valid input and clicking the Add Course button should redirect you to course view page, and should contain the new course you just added", async () => {
test("AdminAddCourse.test.js Test 10: Filling in valid input and clicking the Add Course button should redirect you to course view page, and should contain the new course you just added", async () => {
render(<Login />);

await waitFor(() => {
Expand Down Expand Up @@ -354,7 +322,7 @@ test("AdminAddCourse.test.js Test 11: Filling in valid input and clicking the Ad
});
});

test("AdminAddCourse.test.js Test 12: HelperText errors should show for the addCourseYear and addCourseTerm text fields when the input year is not numeric and the term is not 'Spring', 'Fall', or 'Summer'", async () => {
test("AdminAddCourse.test.js Test 11: HelperText errors should show for the addCourseYear text field when the input year is not numeric", async () => {
render(<Login />);

await waitFor(() => {
Expand Down Expand Up @@ -382,6 +350,5 @@ test("AdminAddCourse.test.js Test 12: HelperText errors should show for the addC

expectElementWithAriaLabelToHaveErrorMessage(cyi, "Year must be a numeric value");

expectElementWithAriaLabelToHaveErrorMessage(cti, "Term should be either Spring, Fall, or Summer");
});
});

0 comments on commit 675590a

Please sign in to comment.