|
1 | 1 | <script lang="ts"> |
2 | 2 | import { derived, writable } from "svelte/store"; |
3 | | - import { TestCase, TestResult } from "../shared/langsSchema"; |
| 3 | + import { |
| 4 | + TestCase, |
| 5 | + TestResult, |
| 6 | + TmcStyleValidationResult, |
| 7 | + TmcStyleValidationStrategy, |
| 8 | + } from "../shared/langsSchema"; |
4 | 9 | import Checkbox from "./Checkbox.svelte"; |
5 | 10 | import ProgressBar from "./ProgressBar.svelte"; |
6 | 11 | import { vscode } from "../utilities/vscode"; |
7 | 12 |
|
8 | 13 | export let totalPoints: number; |
9 | 14 | export let successPoints: number; |
10 | 15 | export let testResults: Array<TestResult | TestCase>; |
| 16 | + export let validationResult: TmcStyleValidationResult | null; |
11 | 17 | export let solutionUrl: string | null; |
12 | 18 |
|
| 19 | + const validationStrategy: TmcStyleValidationStrategy = validationResult?.strategy ?? "DISABLED"; |
| 20 | + const validationErrors = validationResult?.validationErrors ?? {}; |
| 21 | + const validationErrorsEntries = Object.entries(validationErrors); |
| 22 | + // validations pass if strategy is not set to fail, or if there are no validation errors |
| 23 | + const validationsPassed = validationStrategy !== "FAIL" || validationErrorsEntries.length === 0; |
| 24 | +
|
13 | 25 | const allTestsFailed = testResults.find((tr) => tr.successful) === undefined; |
14 | 26 | const allTestsPassed = testResults.find((tr) => !tr.successful) === undefined; |
| 27 | + const exercisePassed = allTestsPassed && validationsPassed; |
15 | 28 | // if all tests failed or passed, no need to show the checkbox |
16 | | - const alwaysShowPassedTests = allTestsFailed || allTestsPassed; |
| 29 | + const alwaysShowPassedTests = allTestsFailed || exercisePassed; |
17 | 30 |
|
18 | 31 | const showPassedTestsChecked = writable<boolean>(false); |
19 | 32 | const showPassedTests = derived(showPassedTestsChecked, ($showPassedTestsChecked) => { |
|
53 | 66 | </div> |
54 | 67 |
|
55 | 68 | <div class="test-results-container"> |
| 69 | + {#each validationErrorsEntries as [path, pathValidationErrors]} |
| 70 | + <div class="test failed-container"> |
| 71 | + <h2 class="failed">Code quality issue found</h2> |
| 72 | + <h3>File: {path}</h3> |
| 73 | + {#each pathValidationErrors as pathValidationError} |
| 74 | + <pre |
| 75 | + class="test-message">Line {pathValidationError.line}, column {pathValidationError.column}: {pathValidationError.message}</pre> |
| 76 | + {/each} |
| 77 | + </div> |
| 78 | + {/each} |
56 | 79 | {#each testResults as testResult} |
57 | 80 | {#if testResult.successful} |
58 | 81 | <div class="test passed-container" hidden={!$showPassedTests}> |
59 | | - <h2 class="passed">PASS:</h2> |
| 82 | + <h2 class="passed">Test passed!</h2> |
60 | 83 | <h3>{testResult.name}</h3> |
61 | 84 | </div> |
62 | 85 | {:else} |
63 | 86 | <div class="test failed-container"> |
64 | | - <h2 class="failed">FAIL:</h2> |
| 87 | + <h2 class="failed">Test failed</h2> |
65 | 88 | <h3>{testResult.name}</h3> |
66 | 89 | <pre class="test-message">{testResult.message}</pre> |
67 | 90 | </div> |
|
0 commit comments