From 6822118a4a0be033c6e21db6893dceec2e9687b1 Mon Sep 17 00:00:00 2001 From: zkldi <20380519+zkldi@users.noreply.github.com> Date: Tue, 17 Jan 2023 14:00:58 +0000 Subject: [PATCH] fix: some tests and snapshots --- .../src/game-implementations/games/_common.ts | 6 ++--- .../score-importing/validate-score.ts | 2 +- .../router/ir/direct-manual/router.test.ts | 5 ++-- .../server/router/ir/fervidex/router.test.ts | 5 ++-- .../test-utils/snapshots/snapshot-data.json | 26 +++++++++---------- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/server/src/game-implementations/games/_common.ts b/server/src/game-implementations/games/_common.ts index 727fc4091..523a6ecc1 100644 --- a/server/src/game-implementations/games/_common.ts +++ b/server/src/game-implementations/games/_common.ts @@ -28,13 +28,11 @@ import type { GPTStrings, GradeBoundary, integer, SpecificUserGameStats } from " export const EX_SCORE_CHECK: ChartSpecificMetricValidator = (exScore, chart) => { if (exScore < 0) { - return `EX Score cannot be negative. Got ${exScore}.`; + return `EX Score cannot be negative.`; } if (exScore > chart.data.notecount * 2) { - return `EX Score cannot be greater than ${ - chart.data.notecount * 2 - } for this chart. Got ${exScore}.`; + return `EX Score cannot be greater than ${chart.data.notecount * 2} for this chart.`; } return true; diff --git a/server/src/lib/score-import/framework/score-importing/validate-score.ts b/server/src/lib/score-import/framework/score-importing/validate-score.ts index 9ddfa4299..be5340a0e 100644 --- a/server/src/lib/score-import/framework/score-importing/validate-score.ts +++ b/server/src/lib/score-import/framework/score-importing/validate-score.ts @@ -108,7 +108,7 @@ function ValidateMetrics( } if (typeof err === "string") { - errs.push(`Invalid value for ${metric}, ${err}`); + errs.push(`Invalid value for ${metric}, ${err} Got ${scoreVal}.`); } break; diff --git a/server/src/server/router/ir/direct-manual/router.test.ts b/server/src/server/router/ir/direct-manual/router.test.ts index 8ed83d637..54ac045e3 100644 --- a/server/src/server/router/ir/direct-manual/router.test.ts +++ b/server/src/server/router/ir/direct-manual/router.test.ts @@ -193,8 +193,9 @@ t.test("POST /ir/direct-manual/import", async (t) => { [ { type: "InvalidDatapoint", - message: `Got 1 error when validating score: -Invalid value for score, EX Score cannot be greater than 1572 for this chart. Got 9000.`, + message: `Got 2 errors when validating score: +Invalid value for score, EX Score cannot be greater than 1572 for this chart. Got 9000. +Invalid value for percent, Expected a number between 0 and 100. Got 572.5190839694657.`, }, ], "Should have one failed score." diff --git a/server/src/server/router/ir/fervidex/router.test.ts b/server/src/server/router/ir/fervidex/router.test.ts index 069e29930..d2a6d2437 100644 --- a/server/src/server/router/ir/fervidex/router.test.ts +++ b/server/src/server/router/ir/fervidex/router.test.ts @@ -456,8 +456,9 @@ t.test("POST /ir/fervidex/score/submit", (t) => { t.strictSame(imp?.errors, [ { type: "InvalidDatapoint", - message: `Got 1 error when validating score: -Invalid value for score, EX Score cannot be greater than 1572 for this chart. Got 9999.`, + message: `Got 2 errors when validating score: +Invalid value for score, EX Score cannot be greater than 1572 for this chart. Got 9999. +Invalid value for percent, Expected a number between 0 and 100. Got 636.0687022900763.`, }, ]); diff --git a/server/src/test-utils/snapshots/snapshot-data.json b/server/src/test-utils/snapshots/snapshot-data.json index 49819bbe6..c7827f53c 100644 --- a/server/src/test-utils/snapshots/snapshot-data.json +++ b/server/src/test-utils/snapshots/snapshot-data.json @@ -27,7 +27,7 @@ "Invalid Goal: folder-score for iidx is illegal": "Creating score goals on multiple charts where the maximum value is relative to the chart is a terrible idea, and has been disabled.", "Invalid Goal: any-score for iidx is illegal": "Invalid key for iidx with multiple charts. Creating score goals on multiple charts where score is relative to notecount is a terrible idea, and has been disabled.", "Invalid Goal: charts single but criteria not.": "Invalid countNum for goal with criteria.mode of 'absolute'. Expected a whole number less than the total amount of charts available and greater than 1. (Got 2, while total charts was 1.)", - "Invalid Goal: too big score": "Invalid value 9000 for score, EX Score cannot be greater than 1572 for this chart. Got 9000.", + "Invalid Goal: too big score": "Invalid value 9000 for score, EX Score cannot be greater than 1572 for this chart.", "Invalid Goal: LampIndex:Multi:Proportion Case": "Criteria Mode must be 'single' or 'absolute' if Charts Type is 'multi'. Doesn't make sense to have proportional goals when you're capped at 10 charts.", "Invalid Goal: GradeIndex:Multi:Proportion Case": "Criteria Mode must be 'single' or 'absolute' if Charts Type is 'multi'. Doesn't make sense to have proportional goals when you're capped at 10 charts.", "Invalid Goal: Percent:Multi:Proportion Case": "Criteria Mode must be 'single' or 'absolute' if Charts Type is 'multi'. Doesn't make sense to have proportional goals when you're capped at 10 charts.", @@ -35,17 +35,17 @@ "Jubeat Music Rate Validator: negative": "Expected a number between 0 and 100.", "Jubeat Music Rate Validator: too big": "Expected a number between 0 and 100.", "Jubeat Music Rate Validator: too big (hard)": "Expected a number between 0 and 120.", - "EX Score Validator SP: negative": "EX Score cannot be negative. Got -1.", - "EX Score Validator SP: excessive": "EX Score cannot be greater than 1572 for this chart. Got 1573.", - "EX Score Validator DP: negative": "EX Score cannot be negative. Got -1.", - "EX Score Validator DP: excessive": "EX Score cannot be greater than 1572 for this chart. Got 1573.", + "EX Score Validator SP: negative": "EX Score cannot be negative.", + "EX Score Validator SP: excessive": "EX Score cannot be greater than 1572 for this chart.", + "EX Score Validator DP: negative": "EX Score cannot be negative.", + "EX Score Validator DP: excessive": "EX Score cannot be greater than 1572 for this chart.", "EX Score Validator SDVX: negative": "EX Score must be non-negative. Got -1", - "EX Score Validator 7K: negative": "EX Score cannot be negative. Got -1.", - "EX Score Validator 7K: excessive": "EX Score cannot be greater than 4512 for this chart. Got 4513.", - "EX Score Validator 14K: negative": "EX Score cannot be negative. Got -1.", - "EX Score Validator 14K: excessive": "EX Score cannot be greater than 4512 for this chart. Got 4513.", - "EX Score Validator Controller: negative": "EX Score cannot be negative. Got -1.", - "EX Score Validator Controller: excessive": "EX Score cannot be greater than 4512 for this chart. Got 4513.", - "EX Score Validator Keyboard: negative": "EX Score cannot be negative. Got -1.", - "EX Score Validator Keyboard: excessive": "EX Score cannot be greater than 4512 for this chart. Got 4513." + "EX Score Validator 7K: negative": "EX Score cannot be negative.", + "EX Score Validator 7K: excessive": "EX Score cannot be greater than 4512 for this chart.", + "EX Score Validator 14K: negative": "EX Score cannot be negative.", + "EX Score Validator 14K: excessive": "EX Score cannot be greater than 4512 for this chart.", + "EX Score Validator Controller: negative": "EX Score cannot be negative.", + "EX Score Validator Controller: excessive": "EX Score cannot be greater than 4512 for this chart.", + "EX Score Validator Keyboard: negative": "EX Score cannot be negative.", + "EX Score Validator Keyboard: excessive": "EX Score cannot be greater than 4512 for this chart." } \ No newline at end of file