diff --git a/frontend/src/ts/input/handlers/before-delete.ts b/frontend/src/ts/input/handlers/before-delete.ts index c6bbf68c0f57..3dc7c77a1c73 100644 --- a/frontend/src/ts/input/handlers/before-delete.ts +++ b/frontend/src/ts/input/handlers/before-delete.ts @@ -12,12 +12,15 @@ export function onBeforeDelete(event: InputEvent): void { return; } if (TestState.testRestarting) { + event.preventDefault(); return; } if (isAwaitingNextWord()) { + event.preventDefault(); return; } if (TestState.resultCalculating) { + event.preventDefault(); return; } diff --git a/frontend/src/ts/test/test-logic.ts b/frontend/src/ts/test/test-logic.ts index 6934fff82a95..337e19eb11c9 100644 --- a/frontend/src/ts/test/test-logic.ts +++ b/frontend/src/ts/test/test-logic.ts @@ -85,7 +85,11 @@ import { qs } from "../utils/dom"; import { setAccountButtonSpinner } from "../states/header"; import { Config } from "../config/store"; import { setQuoteLengthAll, toggleFunbox, setConfig } from "../config/setters"; -import { resetTestEvents, cleanupData } from "./events/data"; +import { + resetTestEvents, + cleanupData, + logEventsDataToTheConsoleTable, +} from "./events/data"; import { getKeypressDurations, getChars, @@ -901,6 +905,8 @@ function buildCompletedEvent( return completedEvent; } +const ALWAYSREPORT = false; + function compareCompletedEvents( ce: Omit, ): void { @@ -1057,25 +1063,6 @@ function compareCompletedEvents( ); } } - - { - const a = TestInput.keypressCountHistory; - const b = getKeypressesPerSecond(); - if (a.length === b.length && a.every((val, i) => val === b[i])) { - console.debug( - `Completed event match on key keypressCountHistory:`, - a, - ); - } else { - notMatching.push(`keypressCountHistory (values differ)`); - mismatchedKeys.push("keypressCountHistory"); - console.error( - `Completed event mismatch on key keypressCountHistory:`, - a, - b, - ); - } - } } else if (key === "wpmConsistency" || key === "keyConsistency") { const a = val1 as number; const b = val2 as number; @@ -1114,13 +1101,55 @@ function compareCompletedEvents( } } + { + const a = TestInput.keypressCountHistory; + const b = getKeypressesPerSecond(); + if (a.length === b.length && a.every((val, i) => val === b[i])) { + console.debug(`Completed event match on key keypressCountHistory:`, a); + } else { + notMatching.push(`keypressCountHistory (values differ)`); + mismatchedKeys.push("keypressCountHistory"); + console.error( + `Completed event mismatch on key keypressCountHistory:`, + a, + b, + ); + } + } + + { + const a = TestInput.keypressCountHistory.reduce((acc, val) => { + if (val === undefined) return acc; + return acc + val; + }, 0); + const b = getKeypressesPerSecond().reduce((acc, val) => { + if (val === undefined) return acc; + return acc + val; + }, 0); + if (a === b) { + console.debug(`Completed event match on totalKeypressCountHistory:`, a); + } else { + notMatching.push(`totalKeypressCountHistory (${a} vs ${b})`); + mismatchedKeys.push("totalKeypressCountHistory"); + console.error( + `Completed event mismatch on totalKeypressCountHistory:`, + a, + b, + ); + } + } + if (notMatching.length === 0) { - // showSuccessNotification("Completed events match", { important: true }); + if (ALWAYSREPORT) { + showSuccessNotification("Completed events match", { important: true }); + } } else { - // showErrorNotification( - // `Completed event mismatch: ${notMatching.join(", ")}`, - // { important: true }, - // ); + if (ALWAYSREPORT) { + showErrorNotification( + `Completed event mismatch: ${notMatching.join(", ")}`, + { important: true }, + ); + } mismatchedKeys.sort(); const groupKey = mismatchedKeys.join(","); Ape.results @@ -1499,11 +1528,16 @@ export async function finish(difficultyFailed = false): Promise { // test is valid + if (ALWAYSREPORT) { + logEventsDataToTheConsoleTable(); + } + if ( - getAuthenticatedUser() !== null && - !dontSave && - !difficultyFailed && - Config.resultSaving + (getAuthenticatedUser() !== null && + !dontSave && + !difficultyFailed && + Config.resultSaving) || + ALWAYSREPORT ) { compareCompletedEvents(ce); }