Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat para assignment tests #252

Merged
merged 6 commits into from
Nov 16, 2023
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
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
Loading