| | |
| | | const expect = require("chai").expect |
| | | const _ = require("lodash") |
| | | |
| | | const settings = require("../settings") |
| | | const libIlias = require("../lib/libIlias") |
| | | const db = require("../lib/db") |
| | | const testData = require("./data") |
| | | |
| | | ///////////////////////////////////////////////////////////////////////// |
| | | |
| | | describe.skip("the function anmelden", function () { |
| | | // Integration test against a real ILIAS instance. |
| | | // Creates a temporary user, enrolls it via libIlias.anmelden() into an |
| | | // existing course and verifies the membership, then cleans up. |
| | | describe("the function anmelden", function () { |
| | | |
| | | const kurs = testData.kurs // TODO |
| | | const user = testData.user |
| | | |
| | | let kursId = 31938 |
| | | let userId = 31954 |
| | | const courseId = testData.anmelden.obj_id |
| | | let user = null |
| | | let userId = null |
| | | |
| | | beforeEach(async function () { |
| | | // TODO add kurs |
| | | // const res = await libIlias.importIliasUser(user) |
| | | // userId = res.usr_id |
| | | user = _.cloneDeep(testData.user) |
| | | const res = await libIlias.importIliasUser(user) |
| | | userId = res.usr_id |
| | | }) |
| | | |
| | | afterEach(async function () { |
| | | // await libIlias.deleteUser(userId) |
| | | // TODO delete kurs |
| | | if (!userId) return |
| | | // best effort cleanup |
| | | await libIlias.abmelden(userId, courseId).catch(console.error) |
| | | await libIlias.deleteUser(userId).catch(console.error) |
| | | userId = null |
| | | }) |
| | | |
| | | it("should import a new user to ILIAS", async function () { |
| | | console.log("++anmelden", userId, kursId) |
| | | const res = await libIlias.anmelden(userId, kursId) |
| | | console.dir(res, {depth: null}) |
| | | it("should enroll a user into a course", async function () { |
| | | const res = await libIlias.anmelden(userId, courseId) |
| | | expect(res).to.have.property("status").and.to.equal("ok") |
| | | expect(res.command).to.equal("anmelden") |
| | | expect(res.method).to.equal("POST") |
| | | expect(res).to.have.property("command").and.to.equal("anmelden") |
| | | expect(res).to.have.property("method").and.to.equal("POST") |
| | | |
| | | const members = await db.getKursTeilnehmerByRole(courseId) |
| | | expect(members.map(m => m.usr_id)).to.include(userId) |
| | | }) |
| | | |
| | | }) |
| | | |
| | | ///////////////////////////////////////////////////////////////////////// |
| | | |