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
32 changes: 32 additions & 0 deletions frontend/__tests__/utils/strings.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,38 @@ describe("string utils", () => {
missed: 0,
},
},
{
description: "count extra chars as extra",
input: {
inputWord: "abcx",
targetWord: "abc ",
lastWord: true,
shouldLastPartialWordCount: true,
},
expected: {
allCorrect: 3,
correctWord: 0,
incorrect: 0,
extra: 1,
missed: 0,
},
},
{
description: "count extra chars as extra (with space)",
input: {
inputWord: "abcx ",
targetWord: "abc ",
lastWord: true,
shouldLastPartialWordCount: true,
},
expected: {
allCorrect: 3,
correctWord: 0,
incorrect: 1,
extra: 1,
missed: 0,
},
},
];

it.each(testCases)("$description", ({ input, expected }) => {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/ts/components/pages/account/HistoryChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ export function HistoryChart(props: {
</div>
<div class="grid grid-cols-1 items-center lg:grid-cols-[1fr_30rem]">
<Trend results={props.results} />
<div class="grid grid-cols-4 gap-2 text-em-xs">
<div class="grid grid-cols-4 gap-2 text-em-xs max-[475px]:grid-cols-2">
<Button
fa={{ icon: "fa-tachometer-alt", fixedWidth: true }}
text="Speed"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ function Picker(props: { color: ColorName }): JSXElement {
>
<div>{text()}</div>
<input
// class="text-center"
class="w-full"
type="text"
value={getTheme()[props.color]}
onChange={(e) => {
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/ts/test/test-logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ import {
getKeypressesPerSecond,
} from "./events/stats";
import { calculateWpm } from "../utils/numbers";
import { isDevEnvironment } from "../utils/env";

let failReason = "";

Expand Down Expand Up @@ -910,7 +911,7 @@ function buildCompletedEvent(
return completedEvent;
}

const ALWAYSREPORT = false;
const ALWAYSREPORT = isDevEnvironment() || false;

// window.ce2 = buildCompletedEvent2;

Expand Down Expand Up @@ -1282,7 +1283,7 @@ function compareCompletedEvents(
difficulty: ce.difficulty,
duration: ce.testDuration,
funboxes: getActiveFunboxNames().join(","),
version: 5,
version: 7,
// ce: ce as Record<string, unknown>,
// ce2: ce2 as Record<string, unknown>,
},
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/ts/test/test-stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,8 @@ function countChars(final = false): CharCount {
countCharsUtils(
inputWord,
targetWord,
!final || (i === inputWords.length - 1 && final),
isTimedTest,
i === inputWords.length - 1,
(isTimedTest && final) || !final,
);

correctWordChars += correctWord;
Expand Down
7 changes: 5 additions & 2 deletions frontend/src/ts/utils/strings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,11 @@ export function countChars(
if (!(lastWord && shouldLastPartialWordCount)) {
missed += 1;
}
} else if (targetChar === undefined) {
//extra char
} else if (
targetChar === undefined ||
(targetChar === " " && inputChar !== " " && !inputWord.includes(" "))
) {
//extra char (past target, or typed in place of word-ending space)
extra += 1;
} else {
//incorrect char
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts/src/results.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(5),
version: z.literal(7),
// ce: z.record(z.unknown()),
// ce2: z.record(z.unknown()),
});
Expand Down
Loading