diff --git a/apps/frontend/app/(client)/(code-editor)/_components/TestcasePanel/TestcasePanel.tsx b/apps/frontend/app/(client)/(code-editor)/_components/TestcasePanel/TestcasePanel.tsx
index 716441d451..9f9705a571 100644
--- a/apps/frontend/app/(client)/(code-editor)/_components/TestcasePanel/TestcasePanel.tsx
+++ b/apps/frontend/app/(client)/(code-editor)/_components/TestcasePanel/TestcasePanel.tsx
@@ -35,7 +35,20 @@ export default function TestcasePanel() {
}
}
+ const MAX_OUTPUT_LENGTH = 100000
const testResults = useTestResults()
+ const processedData = testResults.map((testcase) => ({
+ ...testcase,
+ output:
+ testcase.output.length > MAX_OUTPUT_LENGTH
+ ? testcase.output.slice(0, MAX_OUTPUT_LENGTH)
+ : testcase.output
+ }))
+ const summaryData = processedData.map(({ id, result, isUserTestcase }) => ({
+ id,
+ result,
+ isUserTestcase
+ }))
return (
<>
@@ -96,15 +109,15 @@ export default function TestcasePanel() {
{currentTab === 0 ? (
-
+
) : (
item.id === currentTab)}
+ data={processedData.find((item) => item.id === currentTab)}
/>
)}
@@ -175,15 +188,23 @@ function TestcaseTab({
)
}
-function TestSummary({ data }: { data: TestResultDetail[] }) {
+function TestSummary({
+ data
+}: {
+ data: { id: number; result: string; isUserTestcase: boolean }[]
+}) {
const acceptedCount = data.filter(
(testcase) => testcase.result === 'Accepted'
).length
const total = data.length
- const notAcceptedIndexes = data
- .map((testcase, index) => (testcase.result !== 'Accepted' ? index : -1))
+ const notAcceptedTestcases = data
+ .map((testcase, index) =>
+ testcase.result !== 'Accepted'
+ ? `${testcase.isUserTestcase ? 'User' : 'Sample'} #${index + 1}`
+ : -1
+ )
.filter((index) => index !== -1)
return (
@@ -195,15 +216,13 @@ function TestSummary({ data }: { data: TestResultDetail[] }) {
{acceptedCount}/{total}
- {notAcceptedIndexes.length > 0 && (
+ {notAcceptedTestcases.length > 0 && (
Wrong Testcase Number:
|
- {notAcceptedIndexes
- .map((index) => `Sample #${index + 1}`)
- .join(', ')}
+ {notAcceptedTestcases.join(', ')}
|
)}
diff --git a/apps/frontend/app/(client)/(code-editor)/_components/WhitespaceVisualizer.tsx b/apps/frontend/app/(client)/(code-editor)/_components/WhitespaceVisualizer.tsx
index aa1896f1e4..9866e91a17 100644
--- a/apps/frontend/app/(client)/(code-editor)/_components/WhitespaceVisualizer.tsx
+++ b/apps/frontend/app/(client)/(code-editor)/_components/WhitespaceVisualizer.tsx
@@ -12,10 +12,15 @@ export function WhitespaceVisualizer({
}) {
const whitespaceStyle =
'color: rgb(53, 129, 250); min-width: 0.5em; display: inline-block;'
- const highlightedWhitespaceText = text
- .replaceAll(/ /g, `
␣`)
- .replaceAll(/\n/g, `
↵\n`)
- .replaceAll(/\t/g, `
↹`)
+
+ // NOTE: Skip highlighting if text exceeds 100,000 characters to avoid performance issues.
+ const highlightedWhitespaceText =
+ text.length >= 100000
+ ? text
+ : text
+ .replaceAll(/ /g, `
␣`)
+ .replaceAll(/\n/g, `
↵\n`)
+ .replaceAll(/\t/g, `
↹`)
const lines = highlightedWhitespaceText.split('\n')
const visibleLines = lines.slice(0, 3).join('\n')