Fix cypress tests by not loading unknown data
This commit is contained in:
parent
f212df5d29
commit
05fa4ab3be
|
|
@ -63,7 +63,9 @@ function logout() {
|
|||
|
||||
onMounted(() => {
|
||||
log.debug("MainNavigationBar mounted");
|
||||
courseSessionsStore.loadCourseSessionsData();
|
||||
if (userStore.loggedIn) {
|
||||
courseSessionsStore.loadCourseSessionsData();
|
||||
}
|
||||
});
|
||||
|
||||
const profileDropdownData: DropdownListItem[] = [
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ const learningPathData = ref<LearningPath | undefined>(undefined);
|
|||
const learningPathStore = useLearningPathStore();
|
||||
|
||||
learningPathStore
|
||||
.loadLearningPath(props.learningPathUrl.replace("/learn/", ""))
|
||||
.loadLearningPath(props.learningPathUrl.replace("/learn/", ""), false, false)
|
||||
.then((data) => {
|
||||
learningPathData.value = data;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ export const useLearningPathStore = defineStore({
|
|||
},
|
||||
getters: {},
|
||||
actions: {
|
||||
async loadLearningPath(slug: string, reload = false) {
|
||||
async loadLearningPath(slug: string, reload = false, fail = true) {
|
||||
this.loading = true;
|
||||
const completionStore = useCompletionStore();
|
||||
if (this.learningPath && !reload && slug === lastSlug) {
|
||||
|
|
@ -30,18 +30,21 @@ export const useLearningPathStore = defineStore({
|
|||
}
|
||||
this.learningPath = undefined;
|
||||
const learningPathData = await itGetCached(`/api/course/page/${slug}/`);
|
||||
lastSlug = slug;
|
||||
const completionData = await completionStore.loadCompletionData(
|
||||
learningPathData.course.id
|
||||
);
|
||||
|
||||
if (!learningPathData) {
|
||||
if (!learningPathData && fail) {
|
||||
throw `No learning path found with: ${slug}`;
|
||||
}
|
||||
|
||||
this.learningPath = LearningPath.fromJson(learningPathData, completionData);
|
||||
this.loading = false;
|
||||
return this.learningPath;
|
||||
if (learningPathData) {
|
||||
lastSlug = slug;
|
||||
const completionData = await completionStore.loadCompletionData(
|
||||
learningPathData.course.id
|
||||
);
|
||||
|
||||
this.learningPath = LearningPath.fromJson(learningPathData, completionData);
|
||||
this.loading = false;
|
||||
return this.learningPath;
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import * as log from "loglevel";
|
|||
|
||||
import { bustItGetCache, itGetCached, itPost } from "@/fetchHelpers";
|
||||
import { useAppStore } from "@/stores/app";
|
||||
import { useCourseSessionsStore } from "@/stores/courseSessions";
|
||||
import { defineStore } from "pinia";
|
||||
|
||||
const logoutRedirectUrl = import.meta.env.VITE_LOGOUT_REDIRECT;
|
||||
|
|
@ -75,6 +76,8 @@ export const useUserStore = defineStore({
|
|||
this.$state = data;
|
||||
this.loggedIn = true;
|
||||
appStore.userLoaded = true;
|
||||
const courseSessionsStore = useCourseSessionsStore();
|
||||
courseSessionsStore.loadCourseSessionsData();
|
||||
})
|
||||
.catch(() => {
|
||||
this.loggedIn = false;
|
||||
|
|
|
|||
Loading…
Reference in New Issue