Skip to content

Commit

Permalink
changes test logic to reflect that only one learning cycle is valie
Browse files Browse the repository at this point in the history
  • Loading branch information
mantagen committed Aug 29, 2024
1 parent 7087965 commit 4ca8fff
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function useProgressForDownloads(lessonPlan: LooseLessonPlan) {
complete: getCompleteness(errors, ["cycle1", "cycle2", "cycle3"]),
},
{
label: "Exit Quiz",
label: "Exit quiz",
key: "exitQuiz",
complete: getCompleteness(errors, ["exitQuiz"]),
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import {
Cycle,
Keyword,
Misconception,
Quiz,
} from "@oakai/aila/src/protocol/schema";
import type { Meta, StoryObj } from "@storybook/react";

import { LessonPlanProgressDropdown } from "./LessonPlanProgressDropdown";
Expand All @@ -14,11 +20,15 @@ type Story = StoryObj<typeof LessonPlanProgressDropdown>;
export const Default: Story = {
args: {
lessonPlan: {
// 1 (lesson details)
title: "Introduction to Glaciation",
keyStage: "key-stage-3",
subject: "geography",
// 2
learningOutcome: "Sample learning outcome",
// 3
learningCycles: ["Sample learning cycles"],
// 4
priorKnowledge: ["Sample prior knowledge"],
},
sectionRefs: {
Expand All @@ -40,11 +50,23 @@ export const PartiallyCompleted: Story = {
args: {
...Default.args,
lessonPlan: {
...(Default?.args?.lessonPlan ?? {}),
// 1 (lesson details)
title: "Introduction to Glaciation",
keyStage: "key-stage-3",
subject: "geography",
// 2
learningOutcome: "Sample learning outcome",
// 3
learningCycles: ["Sample learning cycles"],
// 4
priorKnowledge: ["Sample prior knowledge"],
// 5
keyLearningPoints: ["Sample key learning point"],
misconceptions: [{ misconception: "Sample misconception" }],
cycle1: { title: "Sample cycle 1" },
// Only cycle1 is completed
// 6
misconceptions: [sampleMisconception()],
// 7
cycle1: sampleCycle(1),
// Only cycle1 is completed, but that is sufficient for downloads
},
},
};
Expand All @@ -53,22 +75,30 @@ export const FullyCompleted: Story = {
args: {
...Default.args,
lessonPlan: {
// 1 (lesson details)
title: "Introduction to Glaciation",
keyStage: "key-stage-3",
subject: "geography",
// 2
learningOutcome: "Sample learning outcome",
// 3
learningCycles: ["Sample learning cycles"],
// 4
priorKnowledge: ["Sample prior knowledge"],
// 5
keyLearningPoints: ["Sample key learning points"],
misconceptions: [{ misconception: "Sample misconceptions" }],
keywords: [{ keyword: "Sample keyword" }],
starterQuiz: [
{ question: "Sample starter quiz", answers: ["Sample answer"] },
],
cycle1: { title: "Sample cycle 1" },
cycle2: { title: "Sample cycle 2" },
cycle3: { title: "Sample cycle 3" },
exitQuiz: [{ question: "Sample exit quiz", answers: ["Answer"] }],
// 6
misconceptions: [sampleMisconception()],
// 7
keywords: [sampleKeyword()],
// 8
starterQuiz: sampleQuiz(),
// 9
cycle1: sampleCycle(1),
cycle2: sampleCycle(2),
cycle3: sampleCycle(3),
// 10
exitQuiz: sampleQuiz(),
additionalMaterials: "Sample additional materials",
},
},
Expand All @@ -78,10 +108,58 @@ export const PartialCycles: Story = {
args: {
...Default.args,
lessonPlan: {
// 1 - 4
...(Default?.args?.lessonPlan ?? {}),
cycle1: { title: "Sample cycle 1" },
cycle2: { title: "Sample cycle 2" },
// cycle3 is missing
// 5
cycle1: sampleCycle(1),
cycle2: sampleCycle(2),
// cycle3 is missing, but that is sufficient for downloads
},
},
};

function sampleCycle(i: number): Cycle {
return {
title: `Sample cycle ${i}`,
durationInMinutes: 10,
explanation: {
spokenExplanation: "Sample spoken explanation",
accompanyingSlideDetails: "Sample slide details",
imagePrompt: "Sample image prompt",
slideText: "Sample slide text",
},
checkForUnderstanding: [
{
question: "Sample question",
answers: ["Sample answer"],
distractors: ["Sample distractor"],
},
],
practice: "Sample practice",
feedback: "Sample feedback",
};
}

function sampleMisconception(): Misconception {
return {
misconception: "Sample misconception",
description: "Sample description",
};
}

function sampleKeyword(): Keyword {
return {
keyword: "Sample keyword",
definition: "Sample description",
};
}

function sampleQuiz(): Quiz {
return [
{
question: "Sample question",
answers: ["Sample answer"],
distractors: ["Sample distractor"],
},
];
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ describe("LessonPlanProgressDropdown", () => {

it("renders the PartiallyCompleted story with correct closed state", () => {
render(<PartiallyCompleted />);
// expect(screen.getByText("4 of 10 sections complete")).toBeInTheDocument();
expect(screen.getByText("5 of 10 sections complete")).toBeInTheDocument();
expect(screen.getByText("6 of 10 sections complete")).toBeInTheDocument();
expect(screen.getByText("7 of 10 sections complete")).toBeInTheDocument();
});

it("renders the FullyCompleted story with correct closed state", () => {
Expand All @@ -39,7 +37,7 @@ describe("LessonPlanProgressDropdown", () => {

it("renders the PartialCycles story with correct closed state", () => {
render(<PartialCycles />);
expect(screen.getByText("4 of 10 sections complete")).toBeInTheDocument();
expect(screen.getByText("5 of 10 sections complete")).toBeInTheDocument();
});

it("displays the dropdown menu when clicked and shows correct completed sections", async () => {
Expand Down Expand Up @@ -72,9 +70,9 @@ describe("LessonPlanProgressDropdown", () => {
{ name: "Prior knowledge", completed: true },
{ name: "Key learning points", completed: true },
{ name: "Misconceptions", completed: true },
{ name: "Keywords", completed: false },
{ name: "Key words", completed: false },
{ name: "Starter quiz", completed: false },
{ name: "Learning cycles", completed: false },
{ name: "Learning cycles", completed: true },
{ name: "Exit quiz", completed: false },
];

Expand Down Expand Up @@ -114,7 +112,7 @@ describe("LessonPlanProgressDropdown", () => {
"Prior knowledge",
"Key learning points",
"Misconceptions",
"Keywords",
"Key words",
"Starter quiz",
"Learning cycles",
"Exit quiz",
Expand Down Expand Up @@ -151,9 +149,9 @@ describe("LessonPlanProgressDropdown", () => {
{ name: "Prior knowledge", completed: true },
{ name: "Key learning points", completed: false },
{ name: "Misconceptions", completed: false },
{ name: "Keywords", completed: false },
{ name: "Key words", completed: false },
{ name: "Starter quiz", completed: false },
{ name: "Learning cycles", completed: false },
{ name: "Learning cycles", completed: true },
{ name: "Exit quiz", completed: false },
];

Expand Down

0 comments on commit 4ca8fff

Please sign in to comment.