Fix cypress tests
This commit is contained in:
parent
85a0ba1d25
commit
1fdabf77c0
|
|
@ -1,6 +1,7 @@
|
||||||
import orderBy from "lodash/orderBy";
|
import orderBy from "lodash/orderBy";
|
||||||
|
|
||||||
import { Circle } from "@/services/circle";
|
import { Circle } from "@/services/circle";
|
||||||
|
import { useCourseSessionsStore } from "@/stores/courseSessions";
|
||||||
import { useLearningPathStore } from "@/stores/learningPath";
|
import { useLearningPathStore } from "@/stores/learningPath";
|
||||||
import type {
|
import type {
|
||||||
Course,
|
Course,
|
||||||
|
|
@ -16,11 +17,13 @@ export interface ContinueData {
|
||||||
has_no_progress: boolean;
|
has_no_progress: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLastCompleted(courseId: number, completionData: CourseCompletion[]) {
|
function getLastCompleted(courseSlug: string, completionData: CourseCompletion[]) {
|
||||||
|
const courseSessionsStore = useCourseSessionsStore();
|
||||||
|
const courseSession = courseSessionsStore.courseSessionForCourse(courseSlug);
|
||||||
return orderBy(completionData, ["updated_at"], "desc").find((c: CourseCompletion) => {
|
return orderBy(completionData, ["updated_at"], "desc").find((c: CourseCompletion) => {
|
||||||
return (
|
return (
|
||||||
c.completion_status === "success" &&
|
c.completion_status === "success" &&
|
||||||
c.course === courseId &&
|
c.course_session === courseSession?.id &&
|
||||||
c.page_type === "learnpath.LearningContent"
|
c.page_type === "learnpath.LearningContent"
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
@ -115,7 +118,7 @@ export class LearningPath implements WagtailLearningPath {
|
||||||
this.nextLearningContent = undefined;
|
this.nextLearningContent = undefined;
|
||||||
|
|
||||||
const lastCompletedLearningContent = getLastCompleted(
|
const lastCompletedLearningContent = getLastCompleted(
|
||||||
this.course.id,
|
this.course.slug,
|
||||||
completionData
|
completionData
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -184,7 +184,7 @@ export interface CourseCompletion {
|
||||||
page_key: string;
|
page_key: string;
|
||||||
page_type: string;
|
page_type: string;
|
||||||
page_slug: string;
|
page_slug: string;
|
||||||
course: number;
|
course_session: number;
|
||||||
completion_status: CourseCompletionStatus;
|
completion_status: CourseCompletionStatus;
|
||||||
additional_json_data: unknown;
|
additional_json_data: unknown;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import mitt from "mitt";
|
import mitt from "mitt";
|
||||||
|
|
||||||
export type MittEvents = {
|
export type MittEvents = {
|
||||||
|
// FIXME:
|
||||||
switchedCourseSession: number;
|
switchedCourseSession: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue