From eda54046a40c108e993cb8efd73a1a36bcbfd225 Mon Sep 17 00:00:00 2001
From: alex <alex@alexloehr.net>
Date: Fri, 20 Jun 2025 08:58:35 +0000
Subject: [PATCH] GS-2156

---
 test/testImportIliasUser.js |   42 ++++++++++++++++++++++++------------------
 1 files changed, 24 insertions(+), 18 deletions(-)

diff --git a/test/testImportIliasUser.js b/test/testImportIliasUser.js
index a19e10b..116b571 100644
--- a/test/testImportIliasUser.js
+++ b/test/testImportIliasUser.js
@@ -8,6 +8,7 @@
 
 describe("the function importIliasUser", function () {
 
+   let lastUserId = null
    const user = {
       // Action: "Insert",
       login: "affoReloaded",
@@ -20,21 +21,17 @@
       department: "Bananenpflücker",
       institution: "Globus Budapest",
       roleIdGlobal: 4,
-      userDefinedField: [
-         {
-            name: "Markt",
-            value: "Markt UDF",
-         },
-         {
-            name: "Marktnummer",
-            value: "Marktnummer UDF",
-         },
-         {
-            name: "Personalnummer",
-            value: "Personalnummer UDF",
-         },
-      ],
+      udf_Markt: "Markt UDF",
+      udf: { // ACHTUNG: Die Nummer enspricht der id in der Tabelle udf_definition und kann je nach Reihenfolge anders sein!
+         1: "Markt UDF",
+         2: "Marktnummer UDF",
+         3: "Personal UDF",
+      },
    }
+
+   afterEach(async function () {
+      await deleteUser(lastUserId)
+   })
 
    it("should import a new user to ILIAS", async function () {
       const res = await libIlias.importIliasUser(user)
@@ -44,15 +41,24 @@
       expect(res.usr_id).to.be.a("number").above(0)
 
       const {usr_id} = res
+      lastUserId = usr_id
       const user2 = await db.getUserByUserId(usr_id)
       console.log(user2)
       expect(user2).to.have.property("login").and.to.equal("affoReloaded")
       expect(user2).to.have.property("usr_id").and.to.equal(res.usr_id)
 
-      const res2 = await libIlias.deleteUser(usr_id)
-      console.log(res2)
-      expect(res2).to.have.property("status").and.to.equal("ok")
-      expect(res2).to.have.property("command").and.to.equal("deleteUser")
+      // const res2 = await libIlias.deleteUser(usr_id)
+      // console.log(res2)
+      // expect(res2).to.have.property("status").and.to.equal("ok")
+      // expect(res2).to.have.property("command").and.to.equal("deleteUser")
    })
 
 })
+
+
+async function deleteUser (usr_id) {
+   const res2 = await libIlias.deleteUser(usr_id)
+   console.log(res2)
+   expect(res2).to.have.property("status").and.to.equal("ok")
+   expect(res2).to.have.property("command").and.to.equal("deleteUser")
+}

--
Gitblit v1.8.0