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
1 change: 1 addition & 0 deletions backend/__tests__/api/controllers/result.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,7 @@ describe("result controller test", () => {
xp: 0,
dailyXpBonus: false,
xpBreakdown: {
configMultiplier: 0,
accPenalty: 28,
base: 20,
incomplete: 5,
Expand Down
14 changes: 13 additions & 1 deletion backend/src/api/controllers/result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,18 @@ export async function addResult(
streak,
);

if (isNaN(xpGained.xp)) {
throw new MonkeyError(
500,
"Calculated XP is NaN",
JSON.stringify({
xpGained,
result: completedEvent,
}),
uid,
);
}

if (xpGained.xp < 0) {
throw new MonkeyError(
500,
Expand Down Expand Up @@ -813,7 +825,7 @@ async function calculateXp(
const totalXp =
Math.round((xpAfterAccuracy + incompleteXp) * gainMultiplier) + dailyBonus;

if (gainMultiplier > 1) {
if (gainMultiplier !== 1) {
// breakdown.push([
// "configMultiplier",
// Math.round((xpAfterAccuracy + incompleteXp) * (gainMultiplier - 1)),
Expand Down
2 changes: 2 additions & 0 deletions frontend/__tests__/components/ui/form/InputField.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function makeField(name: string, value = "") {
errors: [],
},
},
options: {},
handleBlur: vi.fn(),
handleChange: vi.fn(),
getMeta: () => ({ hasWarning: false, warnings: [] }),
Expand Down Expand Up @@ -85,6 +86,7 @@ describe("InputField", () => {

it("shows FieldIndicator", () => {
const field = makeField("name");
field.options = { validators: { onChange: () => undefined } };
field.state.meta.isValidating = true;
const { container } = render(() => <InputField field={() => field} />);

Expand Down
3 changes: 3 additions & 0 deletions frontend/src/ts/commandline/commandline-metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import * as UI from "../ui";
import { typedKeys } from "../utils/misc";
import { Validation } from "../types/validation";

//TODO: remove display property and instead use optionsMetadata from configMetadata
// eventually this file should be fully merged into config metadata, probably under the 'commandline' property

type ConfigKeysWithoutCommands =
| "minWpmCustomSpeed"
| "minAccCustom"
Expand Down
Loading