const expect = require("chai").expect
|
const _ = require("lodash")
|
|
const libIlias = require("../lib/libIlias")
|
const db = require("../lib/db")
|
const testData = require("./data")
|
|
/////////////////////////////////////////////////////////////////////////
|
|
// 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 courseId = testData.anmelden.obj_id
|
let user = null
|
let userId = null
|
|
beforeEach(async function () {
|
user = _.cloneDeep(testData.user)
|
const res = await libIlias.importIliasUser(user)
|
userId = res.usr_id
|
})
|
|
afterEach(async function () {
|
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 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).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)
|
})
|
|
})
|
|
/////////////////////////////////////////////////////////////////////////
|