test(backend): Testen voor DatabaseLearningPathProvider.fetchLearningPaths afgewerkt

Hierbij optredende problemen opgelost.
This commit is contained in:
Gerald Schmittinger 2025-03-10 21:14:40 +01:00
parent 1f9e9ed70a
commit 7018a8822d
10 changed files with 139 additions and 32 deletions

View file

@ -1,21 +1,28 @@
import {Language} from "../../../src/entities/content/language";
import {LearningPathTransition} from "../../../src/entities/content/learning-path-transition.entity";
import {LearningPathNode} from "../../../src/entities/content/learning-path-node.entity";
import {LearningPath} from "../../../src/entities/content/learning-path.entity";
export function createLearningPathTransition(condition: string | null, to: LearningPathNode) {
export function createLearningPathTransition(node: LearningPathNode, transitionNumber: number, condition: string | null, to: LearningPathNode) {
let trans = new LearningPathTransition();
trans.node = node;
trans.transitionNumber = transitionNumber;
trans.condition = condition || "true";
trans.next = to;
return trans;
}
export function createLearningPathNode(
learningPath: LearningPath,
nodeNumber: number,
learningObjectHruid: string,
version: number,
language: Language,
startNode: boolean
) {
let node = new LearningPathNode();
node.learningPath = learningPath;
node.nodeNumber = nodeNumber;
node.learningObjectHruid = learningObjectHruid;
node.version = version;
node.language = language;

View file

@ -1,16 +1,17 @@
import {LearningPath, LearningPathNode} from "../../../src/entities/content/learning-path.entity";
import {LearningPath} from "../../../src/entities/content/learning-path.entity";
import {Language} from "../../../src/entities/content/language";
import {EnvVars, getEnvVar} from "../../../src/util/envvars";
import {createLearningPathNode, createLearningPathTransition} from "./learning-path-utils";
import {LearningPathNode} from "../../../src/entities/content/learning-path-node.entity";
function createNodes(): LearningPathNode[] {
function createNodes(learningPath: LearningPath): LearningPathNode[] {
let nodes = [
createLearningPathNode("u_pn_werkingnotebooks", 3, Language.Dutch, true),
createLearningPathNode("pn_werkingnotebooks2", 3, Language.Dutch, false),
createLearningPathNode("pn_werkingnotebooks3", 3, Language.Dutch, false),
createLearningPathNode(learningPath, 0, "u_pn_werkingnotebooks", 3, Language.Dutch, true),
createLearningPathNode(learningPath, 1, "pn_werkingnotebooks2", 3, Language.Dutch, false),
createLearningPathNode(learningPath, 2, "pn_werkingnotebooks3", 3, Language.Dutch, false),
];
nodes[0].transitions.push(createLearningPathTransition("true", nodes[1]));
nodes[1].transitions.push(createLearningPathTransition("true", nodes[2]));
nodes[0].transitions.push(createLearningPathTransition(nodes[0], 0, "true", nodes[1]));
nodes[1].transitions.push(createLearningPathTransition(nodes[1], 0, "true", nodes[2]));
return nodes;
}
@ -21,7 +22,7 @@ const example: LearningPathExample = {
path.hruid = `${getEnvVar(EnvVars.UserContentPrefix)}pn_werking`;
path.title = "Werken met notebooks";
path.description = "Een korte inleiding tot Python notebooks. Hoe ga je gemakkelijk en efficiënt met de notebooks aan de slag?";
path.nodes = createNodes();
path.nodes = createNodes(path);
return path;
}
}