-
Notifications
You must be signed in to change notification settings - Fork 0
Async test result #549
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Phuong-Le-NN
wants to merge
14
commits into
main
Choose a base branch
from
async_test_res_2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Async test result #549
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
8102997
front end in prog , not working
e984708
backend in progress
406e8b1
fix scraping from leetcode
d6646e9
commit to keep progress
c716de0
able to sync input, output, expected output, commit to save prog
de777e9
fix unstable detecting run test button
c570257
complete?
a12a0f1
clean up
50664b6
random fix UI and clean up
5a31c91
tiny UI fix
fa40312
clean up debug log
3ae4f60
clean up abundant code
215ea8f
clean up remove unused code
ffaed7e
tiny clean up
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 118 additions & 0 deletions
118
extension/src/components/panel/editor/tab/TestResultTab.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| import { SkeletonWrapper } from "@cb/components/ui/SkeletonWrapper"; | ||
| import { useRoomData } from "@cb/hooks/store"; | ||
| import { Identifiable, PeerState, SelectableTestResult } from "@cb/types"; | ||
| import React from "react"; | ||
|
|
||
| interface TestResultTabProps { | ||
| activePeer: Identifiable<PeerState> | undefined; | ||
| activeTestResult: SelectableTestResult | undefined; | ||
| selectTestResult: (index: number) => void; | ||
| generalResult: boolean; | ||
| } | ||
|
|
||
| export const TestResultTab: React.FC<TestResultTabProps> = ({ | ||
| activePeer, | ||
| activeTestResult, | ||
| selectTestResult, | ||
| generalResult, | ||
| }) => { | ||
| const { self } = useRoomData(); | ||
| return ( | ||
| <SkeletonWrapper loading={false} className="relative"> | ||
| <div className="p-5 flex flex-col space-y-4 h-full w-full overflow-scroll hide-scrollbar"> | ||
| <div className="flex w-full flex-col items-start justify-between gap-4"> | ||
| <div className="text-label-1 dark:text-dark-label-1 text-xl"> | ||
| {activeTestResult ? ( | ||
| <> | ||
| {generalResult ? ( | ||
| <span className="text-green-500">Accepted</span> | ||
| ) : ( | ||
| <span className="text-red-500">Wrong Answer</span> | ||
| )} | ||
| </> | ||
| ) : null} | ||
| </div> | ||
| <div className="hide-scrollbar flex flex-nowrap items-center gap-x-2 gap-y-4 overflow-x-scroll"> | ||
| {(activePeer?.questions[self?.url ?? ""]?.testResults ?? []).map( | ||
| (test, idx) => { | ||
| const passed = (test.testResult ?? []).every( | ||
| (r: any) => r.output === r.expected | ||
| ); | ||
| const selected = !!test.selected; | ||
| return ( | ||
| <div key={idx} onClick={() => selectTestResult(idx)}> | ||
| {selected ? ( | ||
| passed ? ( | ||
| <button className="bg-fill-3 dark:bg-dark-fill-3 hover:bg-fill-2 dark:hover:bg-dark-fill-2 hover:text-label-1 dark:hover:text-dark-label-1 text-label-1 dark:text-dark-label-1 relative inline-flex items-center whitespace-nowrap rounded-lg px-4 py-1 text-sm font-semibold focus:outline-none"> | ||
| V Case {idx + 1} | ||
| </button> | ||
| ) : ( | ||
| <button className="bg-fill-3 dark:bg-dark-fill-3 hover:bg-fill-2 dark:hover:bg-dark-fill-2 hover:text-label-1 dark:hover:text-dark-label-1 text-label-1 dark:text-dark-label-1 relative inline-flex items-center whitespace-nowrap rounded-lg px-4 py-1 text-sm font-semibold focus:outline-none"> | ||
| X Case {idx + 1} | ||
| </button> | ||
| ) | ||
| ) : passed ? ( | ||
| <button className="hover:bg-fill-2 dark:hover:bg-dark-fill-2 text-label-2 dark:text-dark-label-2 hover:text-label-1 dark:hover:text-dark-label-1 dark:bg-dark-transparent relative inline-flex items-center whitespace-nowrap rounded-lg bg-transparent px-4 py-1 text-sm font-semibold focus:outline-none"> | ||
| V Case {idx + 1} | ||
| </button> | ||
| ) : ( | ||
| <button className="hover:bg-fill-2 dark:hover:bg-dark-fill-2 text-label-2 dark:text-dark-label-2 hover:text-label-1 dark:hover:text-dark-label-1 dark:bg-dark-transparent relative inline-flex items-center whitespace-nowrap rounded-lg bg-transparent px-4 py-1 text-sm font-semibold focus:outline-none"> | ||
| X Case {idx + 1} | ||
| </button> | ||
| )} | ||
| </div> | ||
| ); | ||
| } | ||
| )} | ||
| </div> | ||
| </div> | ||
| <div className="space-y-4 pb-12"> | ||
| <div> | ||
| <div className="flex h-full w-full flex-col space-y-2"> | ||
| {activeTestResult?.testResult.map((assignment, idx) => ( | ||
| <React.Fragment key={idx}> | ||
| {/* Input / Value */} | ||
| <div className="text-label-3 dark:text-dark-label-3 text-xs font-medium"> | ||
| Input | ||
| </div> | ||
| {Object.keys(assignment.input ?? {}).map( | ||
| (variable: string) => ( | ||
| <div | ||
| key={variable} | ||
| className="font-menlo bg-fill-3 dark:bg-dark-fill-3 w-full cursor-text rounded-lg border border-transparent px-3 py-[10px]" | ||
| > | ||
| <div className="font-menlo placeholder:text-label-4 dark:placeholder:text-dark-label-4 sentry-unmask w-full resize-none whitespace-pre-wrap break-words outline-none"> | ||
| {variable} = {assignment.input[variable]} | ||
| </div> | ||
| </div> | ||
| ) | ||
| )} | ||
|
|
||
| {/* Output */} | ||
| <div className="text-label-3 dark:text-dark-label-3 text-xs font-medium"> | ||
| Output | ||
| </div> | ||
| <div className="font-menlo bg-fill-3 dark:bg-dark-fill-3 w-full cursor-text rounded-lg border border-transparent px-3 py-[10px]"> | ||
| <div className="font-menlo placeholder:text-label-4 dark:placeholder:text-dark-label-4 sentry-unmask w-full resize-none whitespace-pre-wrap break-words outline-none"> | ||
| {assignment.output ?? "-"} | ||
| </div> | ||
| </div> | ||
|
|
||
| {/* Expected */} | ||
| <div className="text-label-3 dark:text-dark-label-3 text-xs font-medium"> | ||
| Expected | ||
| </div> | ||
| <div className="font-menlo bg-fill-3 dark:bg-dark-fill-3 w-full cursor-text rounded-lg border border-transparent px-3 py-[10px]"> | ||
| <div className="font-menlo placeholder:text-label-4 dark:placeholder:text-dark-label-4 sentry-unmask w-full resize-none whitespace-pre-wrap break-words outline-none"> | ||
| {assignment.expected ?? "-"} | ||
| </div> | ||
| </div> | ||
| </React.Fragment> | ||
| )) ?? null} | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </SkeletonWrapper> | ||
| ); | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| export { CodeTab } from "@cb/components/panel/editor/tab/CodeTab"; | ||
| export { TestResultTab } from "@cb/components/panel/editor/tab/TestResultTab"; | ||
| export { TestTab } from "@cb/components/panel/editor/tab/TestTab"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is
V? May be we can use an icon component instead?