Merge pull request #261 from SELab-2/fix/testdata-niet-meer-correct-opgezet
Some checks failed
Backend Testing / Run backend unit tests (push) Has been cancelled
Frontend Testing / Run frontend unit tests (push) Has been cancelled
Lint / Run linters (push) Has been cancelled
Some checks failed
Backend Testing / Run backend unit tests (push) Has been cancelled
Frontend Testing / Run frontend unit tests (push) Has been cancelled
Lint / Run linters (push) Has been cancelled
chore: Testdata wordt geëxporteerd en gelinkt
This commit is contained in:
commit
57ddc3d608
41 changed files with 945 additions and 604 deletions
|
@ -17,7 +17,7 @@ export class AnswerController extends BaseController {
|
|||
|
||||
constructor(questionId: QuestionId) {
|
||||
super(
|
||||
`learningObject/${questionId.learningObjectIdentifier.hruid}/:${questionId.learningObjectIdentifier.version}/questions/${questionId.sequenceNumber}/answers`,
|
||||
`learningObject/${questionId.learningObjectIdentifier.hruid}/${questionId.learningObjectIdentifier.version}/questions/${questionId.sequenceNumber}/answers`,
|
||||
);
|
||||
this.loId = questionId.learningObjectIdentifier;
|
||||
this.sequenceNumber = questionId.sequenceNumber;
|
||||
|
|
31
frontend/tests/controllers/answers-controller.test.ts
Normal file
31
frontend/tests/controllers/answers-controller.test.ts
Normal file
|
@ -0,0 +1,31 @@
|
|||
import { describe, it, expect, beforeEach } from "vitest";
|
||||
import { AnswerController } from "../../src/controllers/answers";
|
||||
import { Language } from "@dwengo-1/common/util/language";
|
||||
|
||||
describe("AnswerController Tests", () => {
|
||||
let controller: AnswerController;
|
||||
|
||||
beforeEach(() => {
|
||||
const loiDTO = {
|
||||
hruid: "u_test_multiple_choice",
|
||||
language: Language.English,
|
||||
version: 1,
|
||||
};
|
||||
const questionId = { learningObjectIdentifier: loiDTO, sequenceNumber: 1 };
|
||||
controller = new AnswerController(questionId);
|
||||
});
|
||||
|
||||
it("should fetch all answers", async () => {
|
||||
const result = await controller.getAll(true);
|
||||
expect(result).toHaveProperty("answers");
|
||||
expect(Array.isArray(result.answers)).toBe(true);
|
||||
expect(result.answers.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it("should fetch an answer by sequencenumber", async () => {
|
||||
const answerNumber = 1; // Example sequence number
|
||||
const result = await controller.getBy(answerNumber);
|
||||
expect(result).toHaveProperty("answer");
|
||||
expect(result.answer).toHaveProperty("sequenceNumber", answerNumber);
|
||||
});
|
||||
});
|
30
frontend/tests/controllers/questions-controller.test.ts
Normal file
30
frontend/tests/controllers/questions-controller.test.ts
Normal file
|
@ -0,0 +1,30 @@
|
|||
import { describe, it, expect, beforeEach } from "vitest";
|
||||
import { Language } from "@dwengo-1/common/util/language";
|
||||
import { QuestionController } from "../../src/controllers/questions";
|
||||
|
||||
describe("QuestionController Tests", () => {
|
||||
let controller: QuestionController;
|
||||
|
||||
beforeEach(() => {
|
||||
const loiDTO = {
|
||||
hruid: "u_test_multiple_choice",
|
||||
language: Language.English,
|
||||
version: 1,
|
||||
};
|
||||
controller = new QuestionController(loiDTO);
|
||||
});
|
||||
|
||||
it("should fetch all questions", async () => {
|
||||
const result = await controller.getAll(true);
|
||||
expect(result).toHaveProperty("questions");
|
||||
expect(Array.isArray(result.questions)).toBe(true);
|
||||
expect(result.questions.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it("should fetch an question by sequencenumber", async () => {
|
||||
const questionNumber = 1; // Example sequence number
|
||||
const result = await controller.getBy(questionNumber);
|
||||
expect(result).toHaveProperty("question");
|
||||
expect(result.question).toHaveProperty("sequenceNumber", questionNumber);
|
||||
});
|
||||
});
|
|
@ -27,13 +27,8 @@ test.each([
|
|||
{ username: "DireStraits", firstName: "Mark", lastName: "Knopfler" },
|
||||
{ username: "Tool", firstName: "Maynard", lastName: "Keenan" },
|
||||
{ username: "SmashingPumpkins", firstName: "Billy", lastName: "Corgan" },
|
||||
{ username: "PinkFloyd", firstName: "David", lastName: "Gilmoure" },
|
||||
{ username: "TheDoors", firstName: "Jim", lastName: "Morisson" },
|
||||
// ⚠️ Deze mag niet gebruikt worden in elke test!
|
||||
{ username: "Nirvana", firstName: "Kurt", lastName: "Cobain" },
|
||||
// Makes sure when logged in as leerling1, there exists a corresponding user
|
||||
{ username: "testleerling1", firstName: "Gerald", lastName: "Schmittinger" },
|
||||
])("Get classes of student", async (student) => {
|
||||
const data = await controller.getClasses(student.username, true);
|
||||
expect(data.classes).to.have.length.greaterThan(0);
|
||||
expect(data.classes).to.have.length.greaterThan(0, `Found no classes for ${student.username}`);
|
||||
});
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
import { describe, expect, it } from "vitest";
|
||||
import { SubmissionController } from "../../src/controllers/submissions";
|
||||
import { Language } from "../../src/data-objects/language";
|
||||
|
||||
describe("Test controller submissions", () => {
|
||||
it("Get submission by number", async () => {
|
||||
const hruid = "id03";
|
||||
const classId = "X2J9QT"; // Class01
|
||||
const controller = new SubmissionController(hruid);
|
||||
|
||||
const data = await controller.getByNumber(Language.English, 1, classId, 1, 1, 1);
|
||||
|
||||
expect(data.submission).to.have.property("submissionNumber");
|
||||
});
|
||||
});
|
|
@ -1,5 +1,6 @@
|
|||
import { spawn } from "child_process";
|
||||
import { ChildProcess, spawnSync } from "node:child_process";
|
||||
import { getLogger } from "../../backend/src/logging/initalize";
|
||||
|
||||
let backendProcess: ChildProcess;
|
||||
|
||||
|
@ -35,6 +36,8 @@ export async function setup(): Promise<void> {
|
|||
|
||||
export async function teardown(): Promise<void> {
|
||||
if (backendProcess) {
|
||||
backendProcess.kill();
|
||||
while (!backendProcess.kill()) {
|
||||
getLogger().error(`Failed to kill backend process! Retrying...`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue