-
-
Notifications
You must be signed in to change notification settings - Fork 17
Add dolt_tests to workbench #630
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
Changes from 1 commit
0e78a39
6fc6c4a
ac39cdb
46abe0e
73c167b
ddb6213
c205b85
e0b9ab3
fc5c5e7
58745c4
b8d9711
7932781
a76ffa2
3649ff6
63a9c52
7d10988
e2629e1
8dfc499
d214da9
2c325f2
6912709
ccb1545
4b59d4b
dfbf42e
cc9be6c
f544e7c
5c46682
3b943f5
0034fe1
067ce12
99b2a5f
ca6d784
fc81c29
2addd3c
993aba2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -275,15 +275,17 @@ function TestResultsListItem({ | |
|
||
function TestResults({ params }: { params: RefParams }) { | ||
const [testResults, setTestResults] = useState<TestResult[]>([]); | ||
const [runTests] = useRunTestsLazyQuery(); | ||
const { data } = useTestListQuery({ | ||
const [runTestError, setRunTestError] = useState<string | null>(null); | ||
const [runTests, { error: runTestsError }] = useRunTestsLazyQuery(); | ||
const { data, loading, error } = useTestListQuery({ | ||
variables: { | ||
databaseName: params.databaseName, | ||
refName: params.refName, | ||
}, | ||
}); | ||
|
||
const handleRunTests = useCallback(async () => { | ||
setRunTestError(null); | ||
try { | ||
const result = await runTests({ | ||
variables: { | ||
|
@@ -292,12 +294,50 @@ function TestResults({ params }: { params: RefParams }) { | |
}, | ||
}); | ||
|
||
if (result.error) { | ||
console.error("Error running tests:", result.error); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You don't need to console the error if you're displaying the error |
||
setRunTestError(result.error.message); | ||
setTestResults([]); | ||
return; | ||
} | ||
|
||
setTestResults(result.data?.runTests.list ?? []); | ||
} catch { | ||
} catch (err) { | ||
console.error("Error running tests:", err); | ||
setRunTestError( | ||
err instanceof Error ? err.message : "Failed to run tests", | ||
); | ||
setTestResults([]); | ||
} | ||
}, [runTests, params.databaseName, params.refName]); | ||
|
||
if (loading) { | ||
return ( | ||
<div className={css.testResultsOuter}> | ||
<SmallLoader.WithText text="Loading tests..." loaded={false} /> | ||
</div> | ||
); | ||
} | ||
|
||
if (error) { | ||
console.error("Error loading test list:", error); | ||
return ( | ||
<div className={css.testResultsOuter}> | ||
<div className={css.testResultsContainer}> | ||
<div className={css.testResultsTop}> | ||
<span style={{ color: "red" }}> | ||
Failed to load tests: {error.message} | ||
</span> | ||
Comment on lines
+328
to
+330
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should use |
||
</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
if (runTestsError) { | ||
console.error("Run Tests query error:", runTestsError); | ||
} | ||
Comment on lines
+337
to
+339
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't need this |
||
|
||
if (!data?.tests.list || data.tests.list.length === 0) { | ||
return null; | ||
} | ||
|
@@ -338,6 +378,11 @@ function TestResults({ params }: { params: RefParams }) { | |
[css.testResultsTestsOrange]: orange, | ||
})} | ||
> | ||
{(runTestError || runTestsError) && ( | ||
<div style={{ color: "red", padding: "8px" }}> | ||
Error running tests: {runTestError || runTestsError?.message} | ||
</div> | ||
Comment on lines
+382
to
+384
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here too. And should generally avoid using inline styling like this and use classes instead |
||
)} | ||
<ul> | ||
{testResults.length > 0 ? ( | ||
testResults.map(test => ( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,8 @@ export default function TestList({ params }: Props) { | |
groupedTests, | ||
sortedGroupEntries, | ||
emptyGroups, | ||
testsLoading, | ||
testsError, | ||
setState, | ||
handleRunAll, | ||
handleHashNavigation, | ||
|
@@ -66,26 +68,28 @@ export default function TestList({ params }: Props) { | |
<div className={css.container}> | ||
<div className={css.top}> | ||
<h1>Tests</h1> | ||
<div className={css.actionArea}> | ||
<div className={css.createActions}> | ||
<HideForNoWritesWrapper params={params}> | ||
<CreateDropdown | ||
onCreateGroup={() => setShowNewGroupModal(true)} | ||
/> | ||
</HideForNoWritesWrapper> | ||
<Link {...workingDiff(params)}> | ||
<Button>Commit</Button> | ||
</Link> | ||
</div> | ||
{!testsLoading && !testsError && ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should put all of this in an if (loading) return <Loader />
if (error) return <ErrorMsg />
return <div>{...inner test stuff that relies on query results}</div> There's also a |
||
<div className={css.actionArea}> | ||
<div className={css.createActions}> | ||
<HideForNoWritesWrapper params={params}> | ||
<CreateDropdown | ||
onCreateGroup={() => setShowNewGroupModal(true)} | ||
/> | ||
</HideForNoWritesWrapper> | ||
<Link {...workingDiff(params)}> | ||
<Button>Commit</Button> | ||
</Link> | ||
</div> | ||
|
||
<div className={css.primaryActions}> | ||
{tests.length > 0 && ( | ||
<Button onClick={handleRunAll} className={css.runAllButton}> | ||
Run All | ||
</Button> | ||
)} | ||
<div className={css.primaryActions}> | ||
{tests.length > 0 && ( | ||
<Button onClick={handleRunAll} className={css.runAllButton}> | ||
Run All | ||
</Button> | ||
)} | ||
</div> | ||
</div> | ||
</div> | ||
)} | ||
</div> | ||
|
||
<NewGroupModal | ||
|
@@ -125,6 +129,12 @@ export default function TestList({ params }: Props) { | |
)} | ||
</div> | ||
</div> | ||
) : testsError ? ( | ||
<div className={css.errorContainer}> | ||
<p className={css.errorText}>Failed to load tests: {testsError}</p> | ||
</div> | ||
) : testsLoading ? ( | ||
<p className={css.loading}>Loading tests...</p> | ||
) : ( | ||
<p className={css.noTests}>No tests found</p> | ||
)} | ||
|
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.
useApolloError
might simplify some of the type casting below