From e977250287652ed5925bf8a6ed0ce70df6ea5fff Mon Sep 17 00:00:00 2001 From: zkldi Date: Sat, 15 May 2021 07:13:34 +0100 Subject: [PATCH] first pass. --- .../framework/goals/goals.test.ts | 37 +++++++++++-------- server/src/types.ts | 4 ++ 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/server/src/score-import/framework/goals/goals.test.ts b/server/src/score-import/framework/goals/goals.test.ts index 9880e9d71..6680a5f4f 100644 --- a/server/src/score-import/framework/goals/goals.test.ts +++ b/server/src/score-import/framework/goals/goals.test.ts @@ -255,18 +255,23 @@ t.test("#UpdateGoalsForUser", (t) => { }); t.test("Should correctly update goals when user does not achieve goal.", async (t) => { - await db.goals.insert(baseGoalDocument); - delete baseGoalDocument._id; + const goal = deepmerge(baseGoalDocument, { criteria: { value: 2 } }); + await db.goals.insert(goal); - await db["user-goals"].insert(baseUserGoalDocument); + let userGoal = (deepmerge(baseUserGoalDocument, { + outOf: 2, + outOfHuman: "2", + }) as unknown) as UserGoalDocument; + + await db["user-goals"].insert(userGoal); // we dont delete _id here because updategoalsforuser // depends on usergoal _id - await db["score-pbs"].insert(deepmerge(TestingIIDXSPScorePB, { scoreData: { score: 0 } })); + await db["score-pbs"].insert(deepmerge(TestingIIDXSPScorePB, { scoreData: { score: 1 } })); - let ugMap = new Map([["FAKE_GOAL_ID", baseUserGoalDocument]]); + let ugMap = new Map([["FAKE_GOAL_ID", userGoal]]); - let res = await UpdateGoalsForUser([baseGoalDocument], ugMap, 1, logger); + let res = await UpdateGoalsForUser([goal], ugMap, 1, logger); t.strictSame(res, [ { @@ -274,15 +279,15 @@ t.test("#UpdateGoalsForUser", (t) => { old: { progress: 0, progressHuman: "0", - outOf: 1, - outOfHuman: "1", + outOf: 2, + outOfHuman: "2", achieved: false, }, new: { - progress: 0, - progressHuman: "0", - outOf: 1, - outOfHuman: "1", + progress: 1, + progressHuman: "1", + outOf: 2, + outOfHuman: "2", achieved: false, }, }, @@ -293,10 +298,10 @@ t.test("#UpdateGoalsForUser", (t) => { t.hasStrict( r, { - progress: 0, - progressHuman: "0", - outOf: 1, - outOfHuman: "1", + progress: 1, + progressHuman: "1", + outOf: 2, + outOfHuman: "2", achieved: false, } as any, "Should update goals in the database." diff --git a/server/src/types.ts b/server/src/types.ts index e418be980..942905d02 100644 --- a/server/src/types.ts +++ b/server/src/types.ts @@ -134,6 +134,8 @@ export interface ImportTypeDataMap { "file/eamusement-iidx-csv": IIDXEamusementCSVData; "file/batch-manual": BatchManualScore; "file/solid-state-squad": EmptyObject; + "file/mer-iidx": EmptyObject; + "file/pli-iidx-csv": EmptyObject; "ir/direct-manual": BatchManualScore; "ir/barbatos": BarbatosScore; @@ -156,6 +158,8 @@ export interface ImportTypeContextMap { "file/eamusement-iidx-csv": IIDXEamusementCSVContext; "file/batch-manual": BatchManualContext; "file/solid-state-squad": EmptyObject; + "file/mer-iidx": EmptyObject; + "file/pli-iidx-csv": EmptyObject; "ir/direct-manual": BatchManualContext; "ir/barbatos": EmptyObject;