Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion app/components/NavBarMenus/NavBarMenus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export default function NavBarMenu() {
className={navBarStyles.menuButton}
onBlur={() => setIsOpen(false)}
onClick={() => {

sendGAEvent("event", "buttonClicked", {
value: "Settings",
});
Expand Down
22 changes: 14 additions & 8 deletions app/components/Output/Output.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useState } from "react";
import styles from "./Output.module.css";
import classnames from "classnames";
import { OutputResult } from "@/lib/types";
import FailedTestCasesWindow from "../TestCaseWindow/TestCaseWindow";
import TestCasesWindow from "../TestCaseWindow/TestCaseWindow";
import MyBtn from "../MyBtn";
import { InvalidSchemaError } from "@hyperjump/json-schema/draft-2020-12";
import { schemaUrl } from "@/lib/validators";
Expand Down Expand Up @@ -101,12 +101,18 @@ function Output({
);
} else if (outputResult.validityStatus == "valid") {
outputBodyContent = (
<div className={styles.valid}>
<b className={styles.validMessage}>Valid Schema!</b>
<span className={styles.validSmallMessage}>
Let&apos;s move on to the next step
</span>
</div>
<>
<div className={styles.valid}>
<b className={styles.validMessage}>Valid Schema!</b>
<span className={styles.validSmallMessage}>
Let&apos;s move on to the next step
</span>
</div>
<TestCasesWindow
testCaseResult={outputResult.testCaseResults!}
totalTestCases={outputResult.totalTestCases!}
/>
</>
);
} else if (outputResult.validityStatus == "syntaxError") {
outputBodyContent = (
Expand All @@ -128,7 +134,7 @@ function Output({
);
} else {
outputBodyContent = (
<FailedTestCasesWindow
<TestCasesWindow
testCaseResult={outputResult.testCaseResults!}
totalTestCases={outputResult.totalTestCases!}
/>
Expand Down
14 changes: 8 additions & 6 deletions app/components/TestCaseWindow/TestCaseWindow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,14 @@ export default function TestCasesWindow({

return (
<div className={styles.TestCasesWindow}>
<div className={styles.TestCasesHeaderWrapper}>
<span className={styles.TestCasesHeader}>Invalid Schema!</span>
<span className={styles.TestCasesSubtitle}>
{numberOfFailedTestCases} out of {totalTestCases} test cases failed
</span>
</div>
{numberOfFailedTestCases > 0 && (
<div className={styles.TestCasesHeaderWrapper}>
<span className={styles.TestCasesHeader}>Invalid Schema!</span>
<span className={styles.TestCasesSubtitle}>
{numberOfFailedTestCases} out of {totalTestCases} test cases failed
</span>
</div>
)}
<Flex dir="row" gap={2}>
{!areBothDisabled && (
<button
Expand Down
11 changes: 10 additions & 1 deletion lib/client-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,16 @@ export async function validateCode(
}

if (validationStatus === "valid") {
dispatchOutput({ type: "valid", payload: {} });
const sortedResults = testCaseResults.sort((a, b) => {
if (a.passed === b.passed) {
return 0; // If both are the same, their order doesn't change
}
return a.passed ? 1 : -1; // If a.passed is true, put a after b; if false, put a before b
});
dispatchOutput({
type: "valid",
payload: { testCaseResults: sortedResults, totalTestCases },
});
completeStep(chapterIndex, stepIndex);
sendGAEvent("event", "validation", {
validation_result: "passed",
Expand Down
7 changes: 6 additions & 1 deletion lib/reducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ export function outputReducer(
): OutputResult {
switch (action.type) {
case "valid":
return { ...state, validityStatus: "valid" };
return {
...state,
validityStatus: "valid",
testCaseResults: action.payload.testCaseResults,
totalTestCases: action.payload.totalTestCases,
};
case "syntaxError":
return {
...state,
Expand Down