Skip to content

Commit

Permalink
Merge pull request #2605 from Northeastern-Electric-Racing/Fix-Failin…
Browse files Browse the repository at this point in the history
…g-Tests

Fix Tests
  • Loading branch information
Peyton-McKee authored May 26, 2024
2 parents f301ef7 + 2d50956 commit 4e07101
Show file tree
Hide file tree
Showing 44 changed files with 677 additions and 328 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"concurrently": "^5.2.0",
"eslint": "^7.0.0",
"eslint-config-prettier": "^8.5.0",
"eslint-config-react-app": "^7.0.1",
"eslint-plugin-prettier": "^4.2.1",
"prettier": "^2.0.5",
"rimraf": "^3.0.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const changeRequestTransformer = (changeRequest: ChangeRequest | Standard
}
const output: ChangeRequest = data;

const workPackageProposedChanges = (changeRequest as StandardChangeRequest).workPackageProposedChanges;
const { workPackageProposedChanges } = changeRequest as StandardChangeRequest;
if (workPackageProposedChanges && workPackageProposedChanges.startDate) {
const scopeOutput = {
...data,
Expand Down
3 changes: 1 addition & 2 deletions src/frontend/src/app/AppAuthenticated.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ const AppAuthenticated: React.FC<AppAuthenticatedProps> = ({ userId, userRole })
if (isError) {
if ((error as Error).message === 'Authentication Failed: Invalid JWT!') {
return <SessionTimeoutAlert />;
} else {
return <ErrorPage error={error as Error} message={(error as Error).message} />;
}
return <ErrorPage error={error as Error} message={(error as Error).message} />;
}

return userSettingsData.slackId || isGuest(userRole) ? (
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/components/DetailDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const DetailDisplay: React.FC<DetailDisplayProps> = ({ label, content, paddingRi
return (
<Box display="flex" alignItems="center">
<div>
<Typography sx={{ fontWeight: 'bold', paddingRight: paddingRight }} display="inline">
<Typography sx={{ fontWeight: 'bold', paddingRight }} display="inline">
{label}
{': '}
</Typography>
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/components/TimeSlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const TimeSlot: React.FC<TimeSlotProps> = ({
sx={{
height: small ? '25px' : '4.7vh',
width: small ? '81px' : '12.2%',
backgroundColor: backgroundColor,
backgroundColor,
cursor: onMouseEnter ? 'pointer' : undefined,
borderStyle: 'solid',
borderColor: selected ? '#ffff8c' : 'gray',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const ManufacturerTable: React.FC = () => {

const handleDeleteManufacturer = async (manufacturerName: string) => {
try {
await mutateAsync({ manufacturerName: manufacturerName });
await mutateAsync({ manufacturerName });
toast.success(`Manufacturer: ${manufacturerName} Deleted Successfully!`);
} catch (error: unknown) {
if (error instanceof Error) {
Expand Down
3 changes: 1 addition & 2 deletions src/frontend/src/pages/CalendarPage/CalendarPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ const CalendarPage = () => {
confirmedDesignReviews.sort((designReview1, designReview2) => {
if (designReview1.dateScheduled.getTime() === designReview2.dateScheduled.getTime()) {
return designReview1.meetingTimes[0] - designReview2.meetingTimes[0];
} else {
return designReview1.dateScheduled.getTime() - designReview2.dateScheduled.getTime();
}
return designReview1.dateScheduled.getTime() - designReview2.dateScheduled.getTime();
});

confirmedDesignReviews.forEach((designReview) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const DesignReviewDetailPage: React.FC<DesignReviewDetailPageProps> = ({ designR
const [requiredUsers, setRequiredUsers] = useState(designReview.requiredMembers.map(userToAutocompleteOption));
const [optionalUsers, setOptionalUsers] = useState(designReview.optionalMembers.map(userToAutocompleteOption));
const [date, setDate] = useState(
new Date(designReview.dateScheduled?.getTime() - designReview.dateScheduled?.getTimezoneOffset() * -60000)
new Date(designReview.dateScheduled.getTime() - designReview.dateScheduled.getTimezoneOffset() * -60000)
);
const [showDeleteModal, setShowDeleteModal] = useState(false);
const [startTime, setStateTime] = useState(designReview.meetingTimes[0] % 12);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ interface DesignReviewEditAttendeesProps {

const DesignReviewSummaryModalAttendees: React.FC<DesignReviewSummaryModalAttendeesProps> = ({ designReview }) => {
const toast = useToast();
const requiredMembers = designReview.requiredMembers;
const optionalMembers = designReview.optionalMembers;
const { requiredMembers } = designReview;
const { optionalMembers } = designReview;
const currentUser = useCurrentUser();

const { isLoading: editDesignReviewIsLoading, mutateAsync: editDesignReview } = useEditDesignReview(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const DiffPanel: React.FC<ProjectDiffPanelProps> = ({
const theme = useTheme();

const changeBullets: ChangeBullet[] = [];
for (var projectKey in projectProposedChanges) {
for (const projectKey in projectProposedChanges) {
if (projectProposedChanges.hasOwnProperty(projectKey)) {
changeBullets.push({
label: projectKey,
Expand All @@ -32,7 +32,7 @@ const DiffPanel: React.FC<ProjectDiffPanelProps> = ({
}
}

for (var workPackageKey in workPackageProposedChanges) {
for (let workPackageKey in workPackageProposedChanges) {
if (workPackageProposedChanges.hasOwnProperty(workPackageKey)) {
if (workPackageKey === 'duration') {
workPackageKey = 'endDate';
Expand All @@ -42,7 +42,7 @@ const DiffPanel: React.FC<ProjectDiffPanelProps> = ({
new Date(workPackageProposedChanges!.startDate).getTimezoneOffset() * -6000
);

const duration = workPackageProposedChanges.duration;
const { duration } = workPackageProposedChanges;
const endDate = calculateEndDate(startDate, duration);
changeBullets.push({
label: 'endDate',
Expand All @@ -64,29 +64,28 @@ const DiffPanel: React.FC<ProjectDiffPanelProps> = ({
{detailText}
</Typography>
);
} else {
return (
<List sx={{ listStyleType: 'disc', pl: 4 }}>
{detailText.map((bullet) => {
const url = bullet.includes('http') ? bullet.split(': ')[1] : undefined;
return (
<ListItem sx={{ display: 'list-item' }}>
{url ? (
<>
{bullet.split(': ')[0]}:{' '}
<Link color={'#ffff'} href={url}>
{bullet.split(': ')[1]}
</Link>
</>
) : (
bullet
)}
</ListItem>
);
})}
</List>
);
}
return (
<List sx={{ listStyleType: 'disc', pl: 4 }}>
{detailText.map((bullet) => {
const url = bullet.includes('http') ? bullet.split(': ')[1] : undefined;
return (
<ListItem sx={{ display: 'list-item' }}>
{url ? (
<>
{bullet.split(': ')[0]}:{' '}
<Link color={'#ffff'} href={url}>
{bullet.split(': ')[1]}
</Link>
</>
) : (
bullet
)}
</ListItem>
);
})}
</List>
);
};

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ const DiffSectionCreate: React.FC<DiffSectionCreateProps> = ({ projectProposedCh
delete workPackageProposedChanges?.manager;

if (isCreateProject) {
for (var projectKey in projectProposedChanges) {
for (const projectKey in projectProposedChanges) {
if (projectProposedChanges.hasOwnProperty(projectKey)) {
potentialChangeTypeMap.set(projectKey, PotentialChangeType.ADDED);
}
}
} else {
for (var workPackageKey in workPackageProposedChanges) {
for (const workPackageKey in workPackageProposedChanges) {
if (workPackageProposedChanges.hasOwnProperty(workPackageKey)) {
potentialChangeTypeMap.set(workPackageKey, PotentialChangeType.ADDED);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const DiffSectionEdit: React.FC<DiffSectionEditProps> = ({
const workPackageAsChanges = originalWorkPackageData ?? workPackageToProposedChangesPreview(workPackage);

if (isOnProject) {
for (var projectKey in projectProposedChanges) {
for (const projectKey in projectProposedChanges) {
if (projectProposedChanges.hasOwnProperty(projectKey)) {
const originalValue = projectAsChanges![projectKey as keyof ProjectProposedChangesPreview]!;
const proposedValue = projectProposedChanges[projectKey as keyof ProjectProposedChangesPreview]!;
Expand All @@ -78,7 +78,7 @@ const DiffSectionEdit: React.FC<DiffSectionEditProps> = ({
}
}
} else {
for (var workPackageKey in workPackageProposedChanges) {
for (let workPackageKey in workPackageProposedChanges) {
if (workPackageProposedChanges.hasOwnProperty(workPackageKey)) {
let originalValue = workPackageAsChanges![workPackageKey as keyof WorkPackageProposedChangesPreview]!;
let proposedValue = workPackageProposedChanges[workPackageKey as keyof WorkPackageProposedChangesPreview]!;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,8 @@ const ChangeRequestsTable: React.FC = () => {
return wbs1.projectNumber - wbs2.projectNumber;
} else if (wbs1.workPackageNumber !== wbs2.workPackageNumber) {
return wbs1.workPackageNumber - wbs2.workPackageNumber;
} else {
return 0;
}
return 0;
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import ErrorPage from '../../ErrorPage';
import EditReimbursementRequestRenderedDefaultValues from './EditReimbursementRequestRenderedDefaultValues';

const EditReimbursementRequestPage: React.FC = () => {
const id = useParams<{ id: string }>().id;
const { id } = useParams<{ id: string }>();

const { isLoading: editReimbursementRequestIsLoading, mutateAsync: editReimbursementRequest } =
useEditReimbursementRequest(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,23 @@ const ColumnHeader = ({
{title}
</TableCell>
);
} else {
return (
<TableCell
align={leftAlign ? 'left' : 'center'}
sx={{ fontSize: '16px', fontWeight: 600 }}
sortDirection={orderBy === id ? (isAscendingOrder ? 'asc' : 'desc') : false}
style={{ paddingLeft: '24px', paddingRight: '0px' }}
>
<TableSortLabel
active={orderBy === id}
direction={orderBy === id ? (isAscendingOrder ? 'asc' : 'desc') : 'asc'}
onClick={() => handleRequestSort(id)}
>
{title}
</TableSortLabel>
</TableCell>
);
}
return (
<TableCell
align={leftAlign ? 'left' : 'center'}
sx={{ fontSize: '16px', fontWeight: 600 }}
sortDirection={orderBy === id ? (isAscendingOrder ? 'asc' : 'desc') : false}
style={{ paddingLeft: '24px', paddingRight: '0px' }}
>
<TableSortLabel
active={orderBy === id}
direction={orderBy === id ? (isAscendingOrder ? 'asc' : 'desc') : 'asc'}
onClick={() => handleRequestSort(id)}
>
{title}
</TableSortLabel>
</TableCell>
);
};

export default ColumnHeader;
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const PendingAdvisorModal: React.FC<PendingAdvisorModalProps> = ({ open, saboNum
} = useForm({
resolver: yupResolver(schema),
defaultValues: {
saboNumbers: saboNumbers
saboNumbers
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ const ReimbursementRequestFormView: React.FC<ReimbursementRequestFormViewProps>
[...e.target.files].forEach((file) => {
if (file.size < 1000000) {
receiptPrepend({
file: file,
file,
name: file.name,
googleFileId: ''
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ const ReimbursementProductTable: React.FC<ReimbursementProductTableProps> = ({
const productReason = hasWbsNum ? wbsPipe(product.reason as WbsNumber) : (product.reason as string);
if (uniqueWbsElementsWithProducts.has(productReason)) {
const products = uniqueWbsElementsWithProducts.get(productReason);
products?.push({ ...product, index: index });
products?.push({ ...product, index });
} else {
uniqueWbsElementsWithProducts.set(productReason, [{ ...product, index: index }]);
uniqueWbsElementsWithProducts.set(productReason, [{ ...product, index }]);
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ const ReimbursementRequestForm: React.FC<ReimbursementRequestFormProps> = ({
const { data: userSecureSettings, isLoading: checkSecureSettingsIsLoading } = useCurrentUserSecureSettings();

// checks to make sure none of the secure settings fields are empty, indicating not properly set
const hasSecureSettingsSet = Object.values(userSecureSettings ?? {}).every((x) => x !== '') ? true : false;
const hasSecureSettingsSet = Object.values(userSecureSettings ?? {}).every((x) => x !== '');

const toast = useToast();
const history = useHistory();
Expand Down
71 changes: 34 additions & 37 deletions src/frontend/src/pages/HomePage/OverdueWorkPackageAlerts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,44 +23,41 @@ const OverdueWorkPackageAlerts: React.FC = () => {
// If there are no overdue work packages, don't display anything
if (!userOverdueWorkPackages || userOverdueWorkPackages.length === 0) {
return null;
} else {
return (
<Box sx={{ width: '100%', my: 2 }}>
<Alert
variant="filled"
severity="warning"
sx={{
'& .MuiAlert-message': {
width: '100%'
}
}}
>
<Box>
<AlertTitle>
{userOverdueWorkPackages.length > 1 ? 'Overdue Work Packages:' : 'Overdue Work Package:'}
</AlertTitle>
<Grid container spacing={2}>
{userOverdueWorkPackages.map((wp) => (
<Grid item xs={6} md={3} key={wp.id}>
{wbsPipe(wp.wbsNum)} - {wp.name}
<Typography fontWeight={'regular'} variant="inherit" noWrap my={0.5}>
{'Due: ' + datePipe(wp.endDate)}
</Typography>
<NERButton
variant="contained"
size="small"
onClick={() => history.push(`${routes.PROJECTS}/${wbsPipe(wp.wbsNum)}`)}
>
Create Change Request
</NERButton>
</Grid>
))}
</Grid>
</Box>
</Alert>
</Box>
);
}
return (
<Box sx={{ width: '100%', my: 2 }}>
<Alert
variant="filled"
severity="warning"
sx={{
'& .MuiAlert-message': {
width: '100%'
}
}}
>
<Box>
<AlertTitle>{userOverdueWorkPackages.length > 1 ? 'Overdue Work Packages:' : 'Overdue Work Package:'}</AlertTitle>
<Grid container spacing={2}>
{userOverdueWorkPackages.map((wp) => (
<Grid item xs={6} md={3} key={wp.id}>
{wbsPipe(wp.wbsNum)} - {wp.name}
<Typography fontWeight={'regular'} variant="inherit" noWrap my={0.5}>
{'Due: ' + datePipe(wp.endDate)}
</Typography>
<NERButton
variant="contained"
size="small"
onClick={() => history.push(`${routes.PROJECTS}/${wbsPipe(wp.wbsNum)}`)}
>
Create Change Request
</NERButton>
</Grid>
))}
</Grid>
</Box>
</Alert>
</Box>
);
};

export default OverdueWorkPackageAlerts;
4 changes: 2 additions & 2 deletions src/frontend/src/pages/LoginPage/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const Login = () => {
theme.toggleTheme();
}
if (authedUser.organizations.length > 0) {
const defaultOrganization = authedUser.organizations[0];
const [defaultOrganization] = authedUser.organizations;
organizationContext.selectOrganization(defaultOrganization);
}
redirectAfterLogin();
Expand All @@ -79,7 +79,7 @@ const Login = () => {
theme.toggleTheme();
}
if (authedUser.organizations.length > 0) {
const defaultOrganization = authedUser.organizations[0];
const [defaultOrganization] = authedUser.organizations;
organizationContext.selectOrganization(defaultOrganization);
}
redirectAfterLogin();
Expand Down
Loading

0 comments on commit 4e07101

Please sign in to comment.