From 5dca58c2a6cc27b4faa2670eccc13157cd3e6abb Mon Sep 17 00:00:00 2001 From: Miodec Date: Mon, 8 Jun 2026 23:34:02 +0200 Subject: [PATCH] chore: modify char counting, bump version --- frontend/__tests__/utils/strings.spec.ts | 17 +++++++++++++++++ frontend/src/ts/test/events/stats.ts | 2 +- frontend/src/ts/test/test-logic.ts | 2 +- packages/contracts/src/results.ts | 2 +- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/frontend/__tests__/utils/strings.spec.ts b/frontend/__tests__/utils/strings.spec.ts index 3d25abd070e2..dbe026559e5f 100644 --- a/frontend/__tests__/utils/strings.spec.ts +++ b/frontend/__tests__/utils/strings.spec.ts @@ -1083,6 +1083,23 @@ describe("string utils", () => { missed: 0, }, }, + { + description: + "incorrect last word, trailing confirm space, timed (stopOnError=word)", + input: { + inputWord: "jhow ", + targetWord: "how", + lastWord: true, + shouldLastPartialWordCount: true, + }, + expected: { + allCorrect: 0, + correctWord: 0, + incorrect: 3, + extra: 1, + missed: 0, + }, + }, ]; it.each(testCases)("$description", ({ input, expected }) => { diff --git a/frontend/src/ts/test/events/stats.ts b/frontend/src/ts/test/events/stats.ts index e55ebe94bafa..c16a98eaedb1 100644 --- a/frontend/src/ts/test/events/stats.ts +++ b/frontend/src/ts/test/events/stats.ts @@ -340,7 +340,7 @@ export function getChars(): CharCounts { (Config.mode === "custom" && CustomText.getLimit().mode === "time"); return countCharsForWords( getInputEventsPerWord(), - activeWordIndex, + isTimedTest ? activeWordIndex : TestWords.words.list.length - 1, isTimedTest, ); } diff --git a/frontend/src/ts/test/test-logic.ts b/frontend/src/ts/test/test-logic.ts index 4a6f382b2425..030b3b9ee1e9 100644 --- a/frontend/src/ts/test/test-logic.ts +++ b/frontend/src/ts/test/test-logic.ts @@ -1313,7 +1313,7 @@ function compareCompletedEvents( difficulty: ce.difficulty, duration: ce.testDuration, funboxes: getActiveFunboxNames().join(","), - version: 12, + version: 13, data: { words: TestWords.words.list.join(" "), events: getAllTestEvents(), diff --git a/packages/contracts/src/results.ts b/packages/contracts/src/results.ts index 8f6db596a54a..981caf7bc2f4 100644 --- a/packages/contracts/src/results.ts +++ b/packages/contracts/src/results.ts @@ -75,7 +75,7 @@ export const ReportCompletedEventMismatchRequestSchema = z.object({ difficulty: DifficultySchema.optional(), duration: z.number().max(200).optional(), funboxes: z.string().max(100).optional(), - version: z.literal(12), + version: z.literal(13), data: z.object({ words: z.string().max(10000), events: z.array(z.record(z.unknown())),