diff --git a/src/components/molecules/vImportUsersMatchSearch.unit.ts b/src/components/molecules/vImportUsersMatchSearch.unit.ts
index 5fc85e8dd4..038981a81a 100644
--- a/src/components/molecules/vImportUsersMatchSearch.unit.ts
+++ b/src/components/molecules/vImportUsersMatchSearch.unit.ts
@@ -1,5 +1,6 @@
import { importUsersModule } from "@/store";
import ImportUsersModule from "@/store/import-users";
+import { ImportUserResponseRoleNamesEnum } from "@/serverApi/v3";
import { THEME_KEY } from "@/utils/inject";
import {
createTestingI18n,
@@ -24,8 +25,9 @@ const testProps = {
loginName: "max_mus",
firstName: "Max",
lastName: "Mustermann",
- roleNames: ["student"],
+ roleNames: [ImportUserResponseRoleNamesEnum.Student],
classNames: ["6a"],
+ externalRoleNames: [],
},
isDialog: true,
ldapSource: "LDAP",
@@ -93,7 +95,7 @@ describe("@/components/molecules/vImportUsersMatchSearch", () => {
loginName: "lehrer@schul-cloud.org",
firstName: "Cord",
lastName: "Carl",
- roleNames: ["teacher"],
+ roleNames: [ImportUserResponseRoleNamesEnum.Teacher],
text: "Cord Carl",
};
const wrapper = getWrapper(testProps);
@@ -115,7 +117,7 @@ describe("@/components/molecules/vImportUsersMatchSearch", () => {
loginName: "lehrer@schul-cloud.org",
firstName: "Cord",
lastName: "Carl",
- roleNames: ["teacher"],
+ roleNames: [ImportUserResponseRoleNamesEnum.Teacher],
text: "Cord Carl",
};
@@ -150,7 +152,7 @@ describe("@/components/molecules/vImportUsersMatchSearch", () => {
loginName: "max_mus",
firstName: "Max",
lastName: "Mustermann",
- roleNames: ["student"],
+ roleNames: [ImportUserResponseRoleNamesEnum.Student],
classNames: ["6a"],
};
const match = {
@@ -158,7 +160,7 @@ describe("@/components/molecules/vImportUsersMatchSearch", () => {
loginName: "admin@schul-cloud.org",
firstName: "Thorsten",
lastName: "Test",
- roleNames: ["admin"],
+ roleNames: [ImportUserResponseRoleNamesEnum.Admin],
matchedBy: "admin",
};
const wrapper = getWrapper({
@@ -192,7 +194,7 @@ describe("@/components/molecules/vImportUsersMatchSearch", () => {
expect(deleteMatchButton.props("disabled")).toBe(true);
});
- it("should disable save button when no no item was selected", () => {
+ it("should disable save button when no item was selected", () => {
const wrapper = getWrapper(testProps);
const saveMatchButton = wrapper
@@ -213,4 +215,238 @@ describe("@/components/molecules/vImportUsersMatchSearch", () => {
expect(editedItemUsername.exists()).toBe(false);
});
+
+ describe("when the theme is not NBC", () => {
+ const setup = () => {
+ const setupTestProps = {
+ editedItem: {
+ flagged: false,
+ importUserId: "123",
+ loginName: "max_mus",
+ firstName: "Max",
+ lastName: "Mustermann",
+ roleNames: [ImportUserResponseRoleNamesEnum.Student],
+ classNames: ["6a"],
+ externalRoleNames: ["student-external"],
+ },
+ isDialog: true,
+ ldapSource: "ldap-external",
+ isNbc: false,
+ };
+ return {
+ setupTestProps,
+ };
+ };
+
+ it("should not contain any text for external role", () => {
+ const { setupTestProps } = setup();
+ const wrapper = getWrapper(setupTestProps);
+
+ const editedItemElement = wrapper
+ .find("[data-testid=edited-item]")
+ .html();
+
+ expect(editedItemElement).not.toContain(
+ `common.labels.role ${setupTestProps.ldapSource}`
+ );
+ });
+ });
+
+ describe("when the theme is NBC", () => {
+ describe("when the external role is 'Lern' (Student)", () => {
+ const setup = () => {
+ const adminTestProps = {
+ editedItem: {
+ flagged: false,
+ importUserId: "123",
+ loginName: "max_mus",
+ firstName: "Max",
+ lastName: "Mustermann",
+ roleNames: [ImportUserResponseRoleNamesEnum.Student],
+ classNames: ["6a"],
+ externalRoleNames: ["Lern"],
+ },
+ isDialog: true,
+ ldapSource: "moin.schule",
+ isNbc: true,
+ };
+ return {
+ adminTestProps,
+ };
+ };
+
+ it("should correctly show the external role of the user", () => {
+ const { adminTestProps } = setup();
+ const wrapper = getWrapper(adminTestProps);
+
+ const editedItemElement = wrapper
+ .find("[data-testid=edited-item]")
+ .html();
+
+ expect(editedItemElement).toContain("Max");
+ expect(editedItemElement).toContain("Mustermann");
+ expect(editedItemElement).toContain("common.roleName.student");
+ expect(editedItemElement).toContain(
+ `common.labels.role ${adminTestProps.ldapSource}: ` +
+ "components.molecules.importUsersMatch.externalRoleName.schulconnex.student)"
+ );
+ });
+ });
+ describe("when the external role is 'Lehr' (Teacher)", () => {
+ const setup = () => {
+ const adminTestProps = {
+ editedItem: {
+ flagged: false,
+ importUserId: "123",
+ loginName: "max_mus",
+ firstName: "Max",
+ lastName: "Mustermann",
+ roleNames: [ImportUserResponseRoleNamesEnum.Teacher],
+ classNames: ["6a"],
+ externalRoleNames: ["Lehr"],
+ },
+ isDialog: true,
+ ldapSource: "moin.schule",
+ isNbc: true,
+ };
+ return {
+ adminTestProps,
+ };
+ };
+
+ it("should correctly show the external role of the user", () => {
+ const { adminTestProps } = setup();
+ const wrapper = getWrapper(adminTestProps);
+
+ const editedItemElement = wrapper
+ .find("[data-testid=edited-item]")
+ .html();
+
+ expect(editedItemElement).toContain("Max");
+ expect(editedItemElement).toContain("Mustermann");
+ expect(editedItemElement).toContain("common.roleName.teacher");
+ expect(editedItemElement).toContain(
+ `common.labels.role ${adminTestProps.ldapSource}: ` +
+ "components.molecules.importUsersMatch.externalRoleName.schulconnex.teacher)"
+ );
+ });
+ });
+ describe("when the external role is 'Leit' (Management)", () => {
+ const setup = () => {
+ const adminTestProps = {
+ editedItem: {
+ flagged: false,
+ importUserId: "123",
+ loginName: "max_mus",
+ firstName: "Max",
+ lastName: "Mustermann",
+ roleNames: [ImportUserResponseRoleNamesEnum.Admin],
+ classNames: ["6a"],
+ externalRoleNames: ["Leit"],
+ },
+ isDialog: true,
+ ldapSource: "moin.schule",
+ isNbc: true,
+ };
+ return {
+ adminTestProps,
+ };
+ };
+
+ it("should correctly show the external role of the user", () => {
+ const { adminTestProps } = setup();
+ const wrapper = getWrapper(adminTestProps);
+
+ const editedItemElement = wrapper
+ .find("[data-testid=edited-item]")
+ .html();
+
+ expect(editedItemElement).toContain("Max");
+ expect(editedItemElement).toContain("Mustermann");
+ expect(editedItemElement).toContain("common.roleName.administrator");
+ expect(editedItemElement).toContain(
+ `common.labels.role ${adminTestProps.ldapSource}: ` +
+ "components.molecules.importUsersMatch.externalRoleName.schulconnex.manager)"
+ );
+ });
+ });
+ describe("when the external role is 'OrgAdmin' (Admin)", () => {
+ const setup = () => {
+ const adminTestProps = {
+ editedItem: {
+ flagged: false,
+ importUserId: "123",
+ loginName: "max_mus",
+ firstName: "Max",
+ lastName: "Mustermann",
+ roleNames: [ImportUserResponseRoleNamesEnum.Admin],
+ classNames: ["6a"],
+ externalRoleNames: ["OrgAdmin"],
+ },
+ isDialog: true,
+ ldapSource: "moin.schule",
+ isNbc: true,
+ };
+ return {
+ adminTestProps,
+ };
+ };
+
+ it("should correctly show the external role of the user", () => {
+ const { adminTestProps } = setup();
+ const wrapper = getWrapper(adminTestProps);
+
+ const editedItemElement = wrapper
+ .find("[data-testid=edited-item]")
+ .html();
+
+ expect(editedItemElement).toContain("Max");
+ expect(editedItemElement).toContain("Mustermann");
+ expect(editedItemElement).toContain("common.roleName.administrator");
+ expect(editedItemElement).toContain(
+ `common.labels.role ${adminTestProps.ldapSource}: ` +
+ "components.molecules.importUsersMatch.externalRoleName.schulconnex.orgAdmin)"
+ );
+ });
+ });
+
+ describe("when externalRoleNames prop is empty", () => {
+ const setup = () => {
+ const setupTestProps = {
+ editedItem: {
+ flagged: false,
+ importUserId: "123",
+ loginName: "max_mus",
+ firstName: "Max",
+ lastName: "Mustermann",
+ roleNames: [ImportUserResponseRoleNamesEnum.Student],
+ classNames: ["6a"],
+ externalRoleNames: [],
+ },
+ isDialog: true,
+ ldapSource: "moin.schule",
+ isNbc: true,
+ };
+ return {
+ setupTestProps,
+ };
+ };
+
+ it("should show that the role is not available", () => {
+ const { setupTestProps } = setup();
+ const wrapper = getWrapper(setupTestProps);
+
+ const editedItemElement = wrapper
+ .find("[data-testid=edited-item]")
+ .html();
+
+ expect(editedItemElement).toContain("Max");
+ expect(editedItemElement).toContain("Mustermann");
+ expect(editedItemElement).toContain("common.roleName.student");
+ expect(editedItemElement).toContain(
+ "components.molecules.importUsersMatch.externalRoleName.none"
+ );
+ });
+ });
+ });
});
diff --git a/src/components/molecules/vImportUsersMatchSearch.vue b/src/components/molecules/vImportUsersMatchSearch.vue
index 94a8656d39..e8dad88f0c 100644
--- a/src/components/molecules/vImportUsersMatchSearch.vue
+++ b/src/components/molecules/vImportUsersMatchSearch.vue
@@ -44,6 +44,7 @@
{{ mapRoleNames(editedItem.roleNames) }}
+ {{ isNbc ? externalRoleText : "" }}