Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
363f445
ai
Miodec Jun 22, 2026
c0b526a
dont use test words
Miodec Jun 23, 2026
6d98407
update
Miodec Jun 23, 2026
a8d27be
Merge branch 'master' into commit-character-in-generator
Miodec Jun 23, 2026
f558b5d
cleanup
Miodec Jun 23, 2026
ab9264f
fix tests
Miodec Jun 23, 2026
c65bf3c
cleanup
Miodec Jun 23, 2026
df9d115
rename
Miodec Jun 23, 2026
204cf85
Merge branch 'master' into commit-character-in-generator
Miodec Jun 24, 2026
2487aca
Merge branch 'master' into commit-character-in-generator
Miodec Jun 24, 2026
f8c8955
revert
Miodec Jun 24, 2026
8e80756
fix
Miodec Jun 24, 2026
2f58b15
fix
Miodec Jun 24, 2026
d00f3fa
refacto
Miodec Jun 24, 2026
79aed3d
blindly following instructions
Miodec Jun 24, 2026
53aaba2
yes honey
Miodec Jun 24, 2026
a9169e7
fix(test): make eager word separators work with plus_zero
Miodec Jun 24, 2026
324a6d1
update command
Miodec Jun 24, 2026
26f4c8d
update
Miodec Jun 24, 2026
e31babb
rename
Miodec Jun 24, 2026
ab1b46d
rework
Miodec Jun 24, 2026
7467489
remake
Miodec Jun 25, 2026
bc27c48
fix tests
Miodec Jun 25, 2026
a016f7a
better type
Miodec Jun 25, 2026
f4a2675
use text
Miodec Jun 25, 2026
adc7548
def 1
Miodec Jun 25, 2026
532e6b1
guard
Miodec Jun 25, 2026
00fb754
Merge branch 'master' into word-object
Miodec Jun 25, 2026
9a4a891
fix
Miodec Jun 26, 2026
7115104
Merge branch 'master' into commit-character-in-generator
Miodec Jun 27, 2026
7a32bcd
brrr
Miodec Jun 27, 2026
26423b4
remove debug
Miodec Jun 27, 2026
e9625b0
fix replay
Miodec Jun 27, 2026
02a1122
use text with commit
Miodec Jun 27, 2026
c28107f
trim
Miodec Jun 27, 2026
0881ed9
correctInsert
Miodec Jun 27, 2026
0c02f1a
refactor addWord to use new Word object structure from push method
Miodec Jun 27, 2026
d7c5f4f
fix
Miodec Jun 27, 2026
cb43350
cleanup
Miodec Jun 27, 2026
d70afb7
cleanup
Miodec Jun 27, 2026
ced40f5
remove comment
Miodec Jun 27, 2026
474295a
fix
Miodec Jun 27, 2026
f5484c7
trim
Miodec Jun 27, 2026
5248a7c
use text
Miodec Jun 27, 2026
3db589c
fix opposite shift
Miodec Jun 27, 2026
76076c5
fix
Miodec Jun 27, 2026
8e7ec7e
refactor
Miodec Jun 28, 2026
06ffc05
change import
Miodec Jun 28, 2026
b7c8da1
update comment
Miodec Jun 28, 2026
601e7e7
remove comment
Miodec Jun 28, 2026
e3b87b0
fix bug
Miodec Jun 28, 2026
bd853bb
comment
Miodec Jun 28, 2026
7775d06
fix unicode space issues
Miodec Jun 28, 2026
e75ecf9
fixes
Miodec Jun 28, 2026
4e8b141
fix, tests
Miodec Jun 28, 2026
3c32f01
comment
Miodec Jun 28, 2026
8efff59
improve
Miodec Jun 28, 2026
330d403
ignore separators
Miodec Jun 28, 2026
8cb997b
comment
Miodec Jun 28, 2026
28280af
fix
Miodec Jun 28, 2026
cb7f03a
no move overcommenting
Miodec Jun 28, 2026
93846ca
comment
Miodec Jun 28, 2026
0a1da16
holy nit but fine
Miodec Jun 28, 2026
cb0dfff
comment
Miodec Jun 28, 2026
5e8310a
remove
Miodec Jun 28, 2026
c94dc52
refactor
Miodec Jun 28, 2026
dd8264e
trimboth
Miodec Jun 28, 2026
025219a
include spaces
Miodec Jun 28, 2026
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
165 changes: 116 additions & 49 deletions frontend/__tests__/input/helpers/fail-or-finish.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
} from "../../../src/ts/input/helpers/fail-or-finish";
import { __testing } from "../../../src/ts/config/testing";
import * as Misc from "../../../src/ts/utils/misc";
import * as TestLogic from "../../../src/ts/test/test-logic";
import * as Strings from "../../../src/ts/utils/strings";

const { replaceConfig } = __testing;
Expand All @@ -20,10 +19,6 @@ vi.mock("../../../src/ts/utils/misc", async (importOriginal) => {
};
});

vi.mock("../../../src/ts/test/test-logic", () => ({
areAllTestWordsGenerated: vi.fn(),
}));

vi.mock("../../../src/ts/utils/strings", () => ({
isSpace: vi.fn(),
}));
Expand All @@ -38,8 +33,6 @@ describe("checkIfFailedDueToMinBurst", () => {
});
// oxlint-disable-next-line typescript/no-unsafe-call
(Misc.whorf as any).mockReturnValue(0);
// oxlint-disable-next-line typescript/no-unsafe-call
(TestLogic.areAllTestWordsGenerated as any).mockReturnValue(true);
});

afterAll(() => {
Expand Down Expand Up @@ -139,126 +132,202 @@ describe("checkIfFailedDueToDifficulty", () => {
desc: "zen mode, master - never fails",
config: { mode: "zen", difficulty: "master" },
correct: false,
spaceOrNewline: true,
input: "hello",
data: " ",
testInput: "hello",
targetWord: "hello ",
commitCharacterType: "separator",
expected: false,
},
{
desc: "zen mode - never fails",
config: { mode: "zen", difficulty: "normal" },
correct: false,
spaceOrNewline: true,
input: "hello",
data: " ",
testInput: "hello",
targetWord: "hello ",
commitCharacterType: "separator",
expected: false,
},
//
{
desc: "normal typing incorrect- never fails",
config: { difficulty: "normal" },
correct: false,
spaceOrNewline: false,
input: "hello",
data: "h",
testInput: "hell",
targetWord: "hello",
commitCharacterType: false,
expected: false,
},
{
desc: "normal typing space incorrect - never fails",
config: { difficulty: "normal" },
correct: false,
spaceOrNewline: true,
input: "hello",
data: " ",
testInput: "hell",
targetWord: "hello ",
commitCharacterType: "separator",
expected: false,
},
{
desc: "normal typing correct - never fails",
config: { difficulty: "normal" },
correct: true,
spaceOrNewline: false,
input: "hello",
data: "o",
testInput: "hell",
targetWord: "hello",
commitCharacterType: false,
expected: false,
},
{
desc: "normal typing space correct - never fails",
config: { difficulty: "normal" },
correct: true,
spaceOrNewline: true,
input: "hello",
data: " ",
testInput: "hello",
targetWord: "hello ",
commitCharacterType: "separator",
expected: false,
},
//
{
desc: "expert - fail if incorrect space",
config: { difficulty: "expert" },
correct: false,
spaceOrNewline: true,
input: "he",
data: " ",
testInput: "he",
targetWord: "hello ",
commitCharacterType: "separator",
expected: true,
},
{
desc: "expert - dont fail if space is the first character",
config: { difficulty: "expert" },
correct: false,
spaceOrNewline: true,
input: " ",
data: " ",
testInput: "",
targetWord: "hello ",
commitCharacterType: "separator",
expected: false,
},
{
desc: "expert: - dont fail if just typing",
config: { difficulty: "expert" },
correct: false,
spaceOrNewline: false,
input: "h",
data: "h",
testInput: "hell",
targetWord: "hello",
commitCharacterType: false,
expected: false,
},
{
desc: "expert: - dont fail if just typing",
config: { difficulty: "expert" },
correct: true,
spaceOrNewline: false,
input: "h",
data: "o",
testInput: "hell",
targetWord: "hello",
commitCharacterType: false,
expected: false,
},
{
// nospace commits on the final letter (empty input for a 1-letter word);
// an incorrect commit must still fail expert
desc: "expert - fail on incorrect nospace 1-letter word on empty input",
config: { difficulty: "expert" },
correct: false,
data: "b",
testInput: "",
targetWord: "a",
commitCharacterType: "nospace",
expected: true,
},
{
desc: "expert - dont fail on correct nospace 1-letter word on empty input",
config: { difficulty: "expert" },
correct: true,
data: "a",
testInput: "",
targetWord: "a",
commitCharacterType: "nospace",
expected: false,
},
{
desc: "expert - fail on incorrect nospace multi-letter word commit",
config: { difficulty: "expert" },
correct: false,
data: "o",
testInput: "helx",
targetWord: "hello",
commitCharacterType: "nospace",
expected: true,
},
//
{
desc: "master - fail if incorrect char",
config: { difficulty: "master" },
correct: false,
spaceOrNewline: false,
input: "h",
data: "h",
testInput: "hell",
targetWord: "hello",
commitCharacterType: false,
expected: true,
},
{
desc: "master - fail if incorrect first space",
config: { difficulty: "master" },
correct: true,
spaceOrNewline: true,
input: " ",
data: " ",
testInput: "",
targetWord: "hello ",
commitCharacterType: "separator",
expected: false,
},
{
desc: "master - dont fail if correct char",
config: { difficulty: "master" },
correct: true,
spaceOrNewline: false,
input: "a",
data: "a",
testInput: "te",
targetWord: "tea",
commitCharacterType: false,
expected: false,
},
{
desc: "master - dont fail if correct space",
config: { difficulty: "master" },
correct: true,
spaceOrNewline: true,
input: " ",
data: " ",
testInput: "hello",
targetWord: "hello ",
commitCharacterType: "separator",
expected: false,
},
])("$desc", ({ config, correct, spaceOrNewline, input, expected }) => {
replaceConfig(config as any);
const result = checkIfFailedDueToDifficulty({
testInputWithData: input,
])(
"$desc",
({
config,
correct,
spaceOrNewline,
});
expect(result).toBe(expected);
});
data,
testInput,
targetWord,
commitCharacterType,
expected,
}) => {
replaceConfig(config as any);
const result = checkIfFailedDueToDifficulty({
data,
testInput,
targetWord,
correct,
commitCharacterType: commitCharacterType as
| "separator"
| "nospace"
| false,
});
expect(result).toBe(expected);
},
);
});

describe("checkIfFinished", () => {
Expand All @@ -270,8 +339,6 @@ describe("checkIfFinished", () => {
});
// oxlint-disable-next-line typescript/no-unsafe-call
(Strings.isSpace as any).mockReturnValue(false);
// oxlint-disable-next-line typescript/no-unsafe-call
(TestLogic.areAllTestWordsGenerated as any).mockReturnValue(true);
});

afterAll(() => {
Expand Down Expand Up @@ -322,7 +389,7 @@ describe("checkIfFinished", () => {
allWordsTyped: true,
testInputWithData: "wo ",
currentWord: "word",
shouldGoToNextWord: true,
goingToNextWord: true,
expected: true,
},
{
Expand All @@ -336,7 +403,7 @@ describe("checkIfFinished", () => {
desc: string;
allWordsTyped: boolean;
allWordsGenerated?: boolean;
shouldGoToNextWord: boolean;
goingToNextWord: boolean;
testInputWithData: string;
currentWord: string;
config?: Record<string, any>;
Expand All @@ -347,7 +414,7 @@ describe("checkIfFinished", () => {
({
allWordsTyped,
allWordsGenerated,
shouldGoToNextWord,
goingToNextWord,
testInputWithData,
currentWord,
config,
Expand All @@ -356,7 +423,7 @@ describe("checkIfFinished", () => {
if (config) replaceConfig(config as any);

const result = checkIfFinished({
shouldGoToNextWord,
goingToNextWord,
testInputWithData,
currentWord,
allWordsTyped,
Expand Down
Loading
Loading