Skip to content

Commit

Permalink
Feat para assignment tests (#252)
Browse files Browse the repository at this point in the history
* Add duration assigment step and create task on save

Closes #238.

* Fix type issues

* added tests for iep.getSubgoal and iep.assignTaskToParas

---------

Co-authored-by: Max Isom <[email protected]>
  • Loading branch information
tessathornberry and codetheweb authored Nov 16, 2023
1 parent eac7184 commit 40d75bd
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
26 changes: 22 additions & 4 deletions src/backend/routers/iep.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ test("basic flow - add/get goals, subgoals, tasks", async (t) => {
authenticateAs: "case_manager",
});

const para_id = seed.para.user_id;

const iep = await trpc.student.addIep.mutate({
student_id: seed.student.student_id,
start_date: new Date("2023-01-01"),
Expand All @@ -18,25 +20,36 @@ test("basic flow - add/get goals, subgoals, tasks", async (t) => {
description: "goal 1",
category: "writing",
});

await trpc.iep.addSubgoal.mutate({
goal_id: goal1!.goal_id,
description: "subgoal 1",
instructions: "instructions here",
target_max_attempts: 5,
});

const subgoal2 = await trpc.iep.addSubgoal.mutate({
goal_id: goal1!.goal_id,
description: "subgoal 2",
instructions: "",
target_max_attempts: null,
});
const subgoal2Id = subgoal2!.subgoal_id;

await trpc.iep.addTask.mutate({
subgoal_id: subgoal2!.subgoal_id,
assignee_id: seed.para.user_id,
subgoal_id: subgoal2Id,
assignee_id: para_id,
due_date: new Date("2023-12-31"),
trial_count: 5,
});

const assignTask = await trpc.iep.assignTaskToParas.mutate({
subgoal_id: subgoal2Id,
para_ids: [para_id],
});
t.is(assignTask?.subgoal_id, subgoal2Id);
t.is(assignTask?.assignee_id, para_id);

const gotGoals = await trpc.iep.getGoals.query({ iep_id: iep.iep_id });
t.is(gotGoals.length, 1);

Expand All @@ -45,12 +58,17 @@ test("basic flow - add/get goals, subgoals, tasks", async (t) => {
});
t.is(gotSubgoals.length, 2);

const gotSubgoal = await trpc.iep.getSubgoal.query({
subgoal_id: subgoal2Id,
});
t.is(gotSubgoal[0].description, "subgoal 2");

// TODO: Don't query db directly and use an API method instead. Possibly create a getTasks method later
t.truthy(
await db
.selectFrom("task")
.where("subgoal_id", "=", subgoal2!.subgoal_id)
.where("assignee_id", "=", seed.para.user_id)
.where("subgoal_id", "=", subgoal2Id)
.where("assignee_id", "=", para_id)
.selectAll()
.executeTakeFirstOrThrow()
);
Expand Down
1 change: 0 additions & 1 deletion src/backend/routers/iep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ export const iep = router({
)
.returningAll()
.executeTakeFirst();

return result;
}),
//Temporary function to easily assign tasks to self for testing
Expand Down
1 change: 0 additions & 1 deletion src/components/subgoal/Subgoal-Assignment-Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ export const SubgoalAssignmentModal = (props: SubgoalAssignmentModalProps) => {
? assignmentDuration.minimumNumberOfCollections
: undefined,
});

handleClose();
}
};
Expand Down
1 change: 0 additions & 1 deletion src/pages/benchmarks/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import noBenchmarks from "../../public/img/no-benchmarks.png";

function Benchmarks() {
const { data: tasks, isLoading } = trpc.para.getMyTasks.useQuery();
console.log("tasks ", tasks);

if (isLoading) {
return <div>Loading...</div>;
Expand Down

0 comments on commit 40d75bd

Please sign in to comment.