From bb8c950fc8c126f88399f05dd7035a17d81e2ad6 Mon Sep 17 00:00:00 2001 From: Nicole Lim Date: Wed, 30 Oct 2024 18:23:04 +0800 Subject: [PATCH] Add test case components --- frontend/src/components/TestCase/index.tsx | 49 +++++++++++++++++++++ frontend/src/pages/CollabSandbox/index.tsx | 51 +++++++++++++++++++++- 2 files changed, 98 insertions(+), 2 deletions(-) create mode 100644 frontend/src/components/TestCase/index.tsx diff --git a/frontend/src/components/TestCase/index.tsx b/frontend/src/components/TestCase/index.tsx new file mode 100644 index 0000000000..424eee0004 --- /dev/null +++ b/frontend/src/components/TestCase/index.tsx @@ -0,0 +1,49 @@ +import { Box, styled, Typography } from "@mui/material"; + +type TestCaseProps = { + input: string; + output: string; + stdout: string; + result: string; +}; + +const StyledBox = styled(Box)(({ theme }) => ({ + margin: theme.spacing(2, 0), +})); + +const StyledTypography = styled(Typography)(({ theme }) => ({ + background: theme.palette.divider, + padding: theme.spacing(1, 2), + borderRadius: theme.spacing(1), + whiteSpace: "pre-line", +})); + +const TestCase: React.FC = ({ + input, + output, + stdout, + result, +}) => { + return ( + + ({ marginBottom: theme.spacing(2) })}> + Input + {input} + + + Output + {output} + + + Standard output + {stdout} + + + Result + {result} + + + ); +}; + +export default TestCase; diff --git a/frontend/src/pages/CollabSandbox/index.tsx b/frontend/src/pages/CollabSandbox/index.tsx index 713138894d..9d2bf9afb4 100644 --- a/frontend/src/pages/CollabSandbox/index.tsx +++ b/frontend/src/pages/CollabSandbox/index.tsx @@ -10,7 +10,6 @@ import { Grid2, Tab, Tabs, - Typography, } from "@mui/material"; import classes from "./index.module.css"; import { useMatch } from "../../contexts/MatchContext"; @@ -26,6 +25,31 @@ import QuestionDetailComponent from "../../components/QuestionDetail"; import { Navigate } from "react-router-dom"; import Chat from "../../components/Chat"; import TabPanel from "../../components/TabPanel"; +import TestCase from "../../components/TestCase"; + +// hardcode for now... + +type TestCase = { + input: string; + output: string; + stdout: string; + result: string; +}; + +const testcases: TestCase[] = [ + { + input: "1 2 3 4", + output: "1 2 3 4", + stdout: "1\n2\n3\n4", + result: "1 2 3 4", + }, + { + input: "5 6 7 8", + output: "5 6 7 8", + stdout: "5\n6\n7\n8", + result: "5 6 7 8", + }, +]; const CollabSandbox: React.FC = () => { const [showErrorScreen, setShowErrorScreen] = useState(false); @@ -48,6 +72,7 @@ const CollabSandbox: React.FC = () => { const [state, dispatch] = useReducer(reducer, initialState); const { selectedQuestion } = state; const [selectedTab, setSelectedTab] = useState<"tests" | "chat">("tests"); + const [selectedTestcase, setSelectedTestcase] = useState(0); useEffect(() => { if (!partner) { @@ -193,7 +218,29 @@ const CollabSandbox: React.FC = () => { - Tests + ({ margin: theme.spacing(2, 0) })}> + {[...Array(testcases.length)] + .map((_, index) => index + 1) + .map((i) => ( + + ))} + +