@@ -52,7 +53,7 @@
{{ mdiCheck }}
{{ $t("common.actions.save") }}
-
+
{{ mdiDelete }}
{{ $t("common.actions.remove") }}
-
+
{{ mdiClose }}
{{ $t("common.actions.discard") }}
@@ -83,25 +89,21 @@
diff --git a/src/components/feature-news-form/index.ts b/src/components/feature-news-form/index.ts
new file mode 100644
index 0000000000..6165ac5858
--- /dev/null
+++ b/src/components/feature-news-form/index.ts
@@ -0,0 +1,3 @@
+import FormNews from "./FormNews.vue";
+
+export { FormNews };
diff --git a/src/components/feature-render-html/RenderHTML.unit.ts b/src/components/feature-render-html/RenderHTML.unit.ts
index f9f2d21da3..5c77aa0535 100644
--- a/src/components/feature-render-html/RenderHTML.unit.ts
+++ b/src/components/feature-render-html/RenderHTML.unit.ts
@@ -1,45 +1,56 @@
-import createComponentMocks from "@@/tests/test-utils/componentMocks";
-import { MountOptions, mount, Wrapper } from "@vue/test-utils";
-import Vue from "vue";
+import { mount } from "@vue/test-utils";
import RenderHTML from "./RenderHTML.vue";
+import vueDompurifyHTMLPlugin from "vue-dompurify-html";
+import { default as htmlConfig } from "./config";
describe("RenderHTML", () => {
- let wrapper: Wrapper;
-
const setup = (props: {
html: string;
component?: string;
config?: string;
}) => {
- document.body.setAttribute("data-app", "true");
- wrapper = mount(RenderHTML as MountOptions, {
- ...createComponentMocks({}),
- propsData: props,
+ const wrapper = mount(RenderHTML, {
+ global: {
+ plugins: [
+ [
+ vueDompurifyHTMLPlugin,
+ {
+ namedConfigurations: htmlConfig,
+ },
+ ],
+ ],
+ },
+ props,
});
+
+ return { wrapper };
};
describe("when component is mounted", () => {
it("should render html in tags", () => {
- setup({ html: "test value" });
+ const { wrapper } = setup({ html: "test value" });
expect(wrapper.findComponent(RenderHTML).exists()).toBe(true);
expect(wrapper.find("b").exists()).toBe(true);
});
it("should render with div", () => {
- setup({ html: "test value" });
+ const { wrapper } = setup({ html: "test value" });
expect(wrapper.findComponent(RenderHTML).exists()).toBe(true);
expect(wrapper.element.nodeName).toStrictEqual("DIV");
});
it("should render with span", () => {
- setup({ html: "test value", component: "span" });
+ const { wrapper } = setup({
+ html: "test value",
+ component: "span",
+ });
expect(wrapper.findComponent(RenderHTML).exists()).toBe(true);
expect(wrapper.element.nodeName).toStrictEqual("SPAN");
});
describe("when ck5 config is active", () => {
it("should strip non whitelisted tags", () => {
- setup({
+ const { wrapper } = setup({
html: "test value
",
component: "span",
config: "ck5",
@@ -48,7 +59,7 @@ describe("RenderHTML", () => {
});
it("should allow whitelisted tags", () => {
- setup({
+ const { wrapper } = setup({
html: "test value
",
component: "span",
config: "ck5",
@@ -57,7 +68,7 @@ describe("RenderHTML", () => {
});
it("should strip non whitelisted attributes", () => {
- setup({
+ const { wrapper } = setup({
html: 'test value',
component: "div",
config: "ck5",
@@ -68,7 +79,7 @@ describe("RenderHTML", () => {
});
it("should allow whitelisted attributes", () => {
- setup({
+ const { wrapper } = setup({
html: 'test value',
component: "div",
config: "ck5",
@@ -81,17 +92,23 @@ describe("RenderHTML", () => {
describe("when translations config is active", () => {
it("should strip non whiteltisted tags", () => {
- setup({ html: "test value
", component: "span" });
+ const { wrapper } = setup({
+ html: "test value
",
+ component: "span",
+ });
expect(wrapper.find("h5").exists()).toBe(false);
});
it("should allow whitelisted tags", () => {
- setup({ html: "test value
", component: "span" });
+ const { wrapper } = setup({
+ html: "test value
",
+ component: "span",
+ });
expect(wrapper.find("div").exists()).toBe(false);
});
it("should strip non whitelisted attributes", () => {
- setup({
+ const { wrapper } = setup({
html: 'test value',
component: "span",
});
@@ -101,7 +118,7 @@ describe("RenderHTML", () => {
});
it("should allow whitelisted attributes", () => {
- setup({
+ const { wrapper } = setup({
html: 'test value',
component: "span",
});
diff --git a/src/components/h5p/H5PEditor.unit.ts b/src/components/h5p/H5PEditor.unit.ts
index 20a65127ea..89cfd77e6b 100644
--- a/src/components/h5p/H5PEditor.unit.ts
+++ b/src/components/h5p/H5PEditor.unit.ts
@@ -1,43 +1,35 @@
import { mount } from "@vue/test-utils";
import H5PEditor from "./H5PEditor.vue";
-import { I18N_KEY } from "@/utils/inject";
-import VueI18n from "vue-i18n";
-import createComponentMocks from "@@/tests/test-utils/componentMocks";
import { H5PEditorComponent } from "@lumieducation/h5p-webcomponents";
+import { createTestingI18n } from "@@/tests/test-utils/setup";
+import { nextTick } from "vue";
describe("H5PEditor", () => {
const contentId = "test-content-id";
const parentType = "test-parent-type";
const parentId = "test-parent-id";
- const i18nMock = new VueI18n({
- locale: "en",
- });
-
- const createWrapper = (propsData = {}) => {
+ const createWrapper = (props = {}) => {
return mount(H5PEditor, {
- ...createComponentMocks({
- i18n: true,
- }),
- propsData: {
+ global: {
+ plugins: [createTestingI18n()],
+ },
+ props: {
contentId,
parentType,
parentId,
- ...propsData,
- },
- provide: {
- [I18N_KEY as any]: i18nMock,
+ ...props,
},
});
};
it("renders without errors with standard props", async () => {
const wrapper = createWrapper();
- const h5pEditor = wrapper.findComponent({ ref: "h5pEditorRef" });
+ const h5pEditor = wrapper.find({ ref: "h5pEditorRef" });
expect(wrapper.exists()).toBe(true);
expect(h5pEditor).toBeDefined();
- await wrapper.vm.$nextTick();
+ await nextTick();
const h5pEditorComponent = h5pEditor.element as H5PEditorComponent;
expect(h5pEditorComponent.loadContentCallback).toBeDefined();
expect(h5pEditorComponent.saveContentCallback).toBeDefined();
diff --git a/src/components/h5p/H5PEditor.vue b/src/components/h5p/H5PEditor.vue
index fca5d10a11..7a7bd65e0e 100644
--- a/src/components/h5p/H5PEditor.vue
+++ b/src/components/h5p/H5PEditor.vue
@@ -13,7 +13,6 @@ import {
defineElements,
H5PEditorComponent,
} from "@lumieducation/h5p-webcomponents";
-import { I18N_KEY, injectStrict } from "@/utils/inject";
import { defineComponent, ref, watch, PropType } from "vue";
import {
H5PContentParentType,
@@ -22,6 +21,7 @@ import {
PostH5PContentCreateParams,
} from "@/h5pEditorApi/v3";
import { $axios } from "@/utils/api";
+import { useI18n } from "vue-i18n";
defineElements("h5p-editor");
@@ -46,8 +46,8 @@ export default defineComponent({
const h5pEditorRef = ref();
const h5pEditorApi = H5pEditorApiFactory(undefined, "v3", $axios);
- const i18n = injectStrict(I18N_KEY);
- const language = i18n.locale as LanguageType;
+ const i18n = useI18n();
+ const language = i18n.locale.value as LanguageType;
const loadContent = async (id?: string) => {
try {
diff --git a/src/components/h5p/H5PPlayer.unit.ts b/src/components/h5p/H5PPlayer.unit.ts
index 6e7b1d9343..626af5d14c 100644
--- a/src/components/h5p/H5PPlayer.unit.ts
+++ b/src/components/h5p/H5PPlayer.unit.ts
@@ -1,38 +1,33 @@
import { mount } from "@vue/test-utils";
import H5PPlayer from "./H5PPlayer.vue";
-import { I18N_KEY } from "@/utils/inject";
-import VueI18n from "vue-i18n";
-import createComponentMocks from "@@/tests/test-utils/componentMocks";
import { H5PPlayerComponent } from "@lumieducation/h5p-webcomponents";
+import {
+ createTestingI18n,
+ createTestingVuetify,
+} from "@@/tests/test-utils/setup";
+import { nextTick } from "vue";
describe("H5PPlayer", () => {
const contentId = "test-content-id";
- const i18nMock = new VueI18n({
- locale: "en",
- });
-
- const createWrapper = (propsData = {}) => {
+ const createWrapper = (props = {}) => {
return mount(H5PPlayer, {
- ...createComponentMocks({
- i18n: true,
- }),
- propsData: {
- contentId,
- ...propsData,
+ global: {
+ plugins: [createTestingVuetify(), createTestingI18n()],
},
- provide: {
- [I18N_KEY as any]: i18nMock,
+ props: {
+ contentId,
+ ...props,
},
});
};
it("renders without errors with standard props", async () => {
const wrapper = createWrapper();
- const h5pPlayer = wrapper.findComponent({ ref: "h5pPlayerRef" });
+ const h5pPlayer = wrapper.find({ ref: "h5pPlayerRef" });
expect(wrapper.exists()).toBe(true);
expect(h5pPlayer).toBeDefined();
- await wrapper.vm.$nextTick();
+ await nextTick();
const h5pPlayerComponent = h5pPlayer.element as H5PPlayerComponent;
expect(h5pPlayerComponent.loadContentCallback).toBeDefined();
});
diff --git a/src/components/icons/custom/index.ts b/src/components/icons/custom/index.ts
index cb972d37a1..0aede3f9fc 100644
--- a/src/components/icons/custom/index.ts
+++ b/src/components/icons/custom/index.ts
@@ -1,6 +1,11 @@
import brb from "./brb.vue";
import classIcon from "./class.vue";
import dBildungscloud from "./dBildungscloud.vue";
+import filePdfOutline from "./file-pdf-outline.vue";
+import folderOpenCoursesOutline from "./folder_open_courses_outline.vue";
+import folderOpenSharedOutline from "./folder_open_shared_outline.vue";
+import folderOpenTeamsOutline from "./folder_open_teams_outline.vue";
+import folderOpenUserOutline from "./folder_open_user_outline.vue";
import hourglassDisabled from "./hourglass-disabled.vue";
import icCollection from "./ic_collection.vue";
import icDefaultCircle from "./ic_default-circle.vue";
@@ -24,11 +29,6 @@ import langIconEs from "./lang-icon-es.vue";
import langIconUk from "./lang-icon-uk.vue";
import lernstoreOutline from "./lernstore_outline.vue";
import n21 from "./n21.vue";
-import filePdfOutline from "./file-pdf-outline.vue";
-import folderOpenCoursesOutline from "./folder_open_courses_outline.vue";
-import folderOpenSharedOutline from "./folder_open_shared_outline.vue";
-import folderOpenTeamsOutline from "./folder_open_teams_outline.vue";
-import folderOpenUserOutline from "./folder_open_user_outline.vue";
import schoolOutline from "./school_outline.vue";
import taskDoneFilled from "./task-done-filled.vue";
import taskDone from "./task-done.vue";
@@ -40,130 +40,57 @@ import tasks from "./tasks.vue";
import teacher from "./teacher.vue";
import thr from "./thr.vue";
-const customIcons = {
- brb: {
- component: brb,
- },
- class: {
- component: classIcon,
- },
- dBildungscloud: {
- component: dBildungscloud,
- },
- file_pdf_outline: {
- component: filePdfOutline,
- },
- folder_open_courses_outline: {
- component: folderOpenCoursesOutline,
- },
- folder_open_shared_outline: {
- component: folderOpenSharedOutline,
- },
- folder_open_teams_outline: {
- component: folderOpenTeamsOutline,
- },
- folder_open_user_outline: {
- component: folderOpenUserOutline,
- },
- hourglassDisabled: {
- component: hourglassDisabled,
- },
- ic_collection: {
- component: icCollection,
- },
- "ic_default-circle": {
- component: icDefaultCircle,
- },
- ic_default: {
- component: icDefault,
- },
- "ic_image-circle": {
- component: icImageCircle,
- },
- ic_image: {
- component: icImage,
- },
- "ic_link-circle": {
- component: icLinkCircle,
- },
- ic_link: {
- component: icLink,
- },
- "ic_move-to": {
- component: icMoveTo,
- },
- "ic_pdf-circle": {
- component: icPdfCircle,
- },
- ic_pdf: {
- component: icPdf,
- },
- "ic_sound-circle": {
- component: icSoundCircle,
- },
- ic_sound: {
- component: icSound,
- },
- "ic_video-circle": {
- component: icVideoCircle,
- },
- ic_video: {
- component: icVideo,
- },
- "ic_word-circle": {
- component: icWordCircle,
- },
- ic_word: {
- component: icWord,
- },
- langIconDe: {
- component: langIconDe,
- },
- langIconEn: {
- component: langIconEn,
- },
- langIconEs: {
- component: langIconEs,
- },
- langIconUk: {
- component: langIconUk,
- },
- lernstore_outline: {
- component: lernstoreOutline,
- },
- n21: {
- component: n21,
- },
- school_outline: {
- component: schoolOutline,
- },
- taskDoneFilled: {
- component: taskDoneFilled,
- },
- taskDone: {
- component: taskDone,
- },
- taskDraft: {
- component: taskDraft,
- },
- taskMissedFilled: {
- component: taskMissedFilled,
- },
- taskMissed: {
- component: taskMissed,
- },
- taskOpenFilled: {
- component: taskOpenFilled,
- },
- tasks: {
- component: tasks,
- },
- teacher: {
- component: teacher,
- },
- thr: {
- component: thr,
- },
+const customAliases: Record = {
+ brb: brb,
+ class: classIcon,
+ dBildungscloud: dBildungscloud,
+ file_pdf_outline: filePdfOutline,
+ folder_open_courses_outline: folderOpenCoursesOutline,
+ folder_open_shared_outline: folderOpenSharedOutline,
+ folder_open_teams_outline: folderOpenTeamsOutline,
+ folder_open_user_outline: folderOpenUserOutline,
+ hourglassDisabled: hourglassDisabled,
+ ic_collection: icCollection,
+ "ic_default-circle": icDefaultCircle,
+ ic_default: icDefault,
+ "ic_image-circle": icImageCircle,
+ ic_image: icImage,
+ "ic_link-circle": icLinkCircle,
+ ic_link: icLink,
+ "ic_move-to": icMoveTo,
+ "ic_pdf-circle": icPdfCircle,
+ ic_pdf: icPdf,
+ "ic_sound-circle": icSoundCircle,
+ ic_sound: icSound,
+ "ic_video-circle": icVideoCircle,
+ ic_video: icVideo,
+ "ic_word-circle": icWordCircle,
+ ic_word: icWord,
+ langIconDe: langIconDe,
+ langIconEn: langIconEn,
+ langIconEs: langIconEs,
+ langIconUk: langIconUk,
+ lernstore_outline: lernstoreOutline,
+ n21: n21,
+ school_outline: schoolOutline,
+ taskDoneFilled: taskDoneFilled,
+ taskDone: taskDone,
+ taskDraft: taskDraft,
+ taskMissedFilled: taskMissedFilled,
+ taskMissed: taskMissed,
+ taskOpenFilled: taskOpenFilled,
+ tasks: tasks,
+ teacher: teacher,
+ thr: thr,
};
-export default customIcons;
+// const customSet: IconSet = {
+// component: (props: IconProps) =>
+// h(props.tag, [
+// h(customAliases[props.icon as string], {
+// class: "v-icon__svg",
+// }),
+// ]),
+// };
+
+export { customAliases };
diff --git a/src/components/icons/material/index.ts b/src/components/icons/material/index.ts
index ac10a82e6f..4bf0e26f5e 100644
--- a/src/components/icons/material/index.ts
+++ b/src/components/icons/material/index.ts
@@ -4,8 +4,11 @@ import {
mdiAccountGroupOutline,
mdiAccountOffOutline,
mdiAccountOutline,
+ mdiAccountPlus,
mdiAccountSchoolOutline,
mdiAccountSearch,
+ mdiAccountSwitch,
+ mdiAccountSwitchOutline,
mdiAlert,
mdiAlertCircle,
mdiArchiveOutline,
@@ -60,6 +63,7 @@ import {
mdiImage,
mdiInformation,
mdiLightbulbOnOutline,
+ mdiLock,
mdiLockOutline,
mdiLogin,
mdiMagnify,
@@ -98,14 +102,17 @@ import {
mdiViewListOutline,
} from "@mdi/js";
-const materialIcons = {
+export {
mdiAccountBoxOutline,
mdiAccountCircleOutline,
mdiAccountGroupOutline,
mdiAccountOffOutline,
mdiAccountOutline,
+ mdiAccountPlus,
mdiAccountSchoolOutline,
mdiAccountSearch,
+ mdiAccountSwitch,
+ mdiAccountSwitchOutline,
mdiAlert,
mdiAlertCircle,
mdiArchiveOutline,
@@ -160,6 +167,7 @@ const materialIcons = {
mdiImage,
mdiInformation,
mdiLightbulbOnOutline,
+ mdiLock,
mdiLockOutline,
mdiLogin,
mdiMagnify,
@@ -197,5 +205,3 @@ const materialIcons = {
mdiViewGridOutline,
mdiViewListOutline,
};
-
-export default materialIcons;
diff --git a/src/components/legacy/NavigationBar.unit.js b/src/components/legacy/NavigationBar.unit.js
index edf2ee7105..191f80e214 100644
--- a/src/components/legacy/NavigationBar.unit.js
+++ b/src/components/legacy/NavigationBar.unit.js
@@ -2,6 +2,10 @@ import NavigationBar from "./NavigationBar";
import { envConfigModule } from "@/store";
import setupStores from "@@/tests/test-utils/setupStores";
import EnvConfigModule from "@/store/env-config";
+import {
+ createTestingI18n,
+ createTestingVuetify,
+} from "@@/tests/test-utils/setup";
const navbarLinks = [
{
@@ -20,8 +24,11 @@ const navbarLinks = [
const getWrapper = () => {
return mount(NavigationBar, {
- ...createComponentMocks({ i18n: true }),
- propsData: {
+ global: {
+ plugins: [createTestingVuetify(), createTestingI18n()],
+ stubs: ["base-link"],
+ },
+ props: {
links: navbarLinks,
img: "@/assets/img/logo/logo-dBildungscloud.svg",
buttons: true,
diff --git a/src/components/legacy/NavigationBar.vue b/src/components/legacy/NavigationBar.vue
index a958f93ff0..05622c292f 100644
--- a/src/components/legacy/NavigationBar.vue
+++ b/src/components/legacy/NavigationBar.vue
@@ -10,7 +10,7 @@
-
+
{{ mdiLogin }}
{{ $t("common.labels.login") }}
-
+
{{ $t("common.labels.register") }}
@@ -81,6 +86,7 @@ export default {
diff --git a/src/components/legacy/TheSidebar.unit.js b/src/components/legacy/TheSidebar.unit.js
deleted file mode 100644
index efe65a382c..0000000000
--- a/src/components/legacy/TheSidebar.unit.js
+++ /dev/null
@@ -1,91 +0,0 @@
-import TheSidebar from "./TheSidebar";
-import { createLocalVue } from "@vue/test-utils";
-import VueRouter from "vue-router";
-
-const localVue = createLocalVue();
-localVue.use(VueRouter);
-
-describe("@/components/legacy/TheSidebar", () => {
- it("Render with empty routes", () => {
- const router = new VueRouter([{ path: "home" }]);
-
- const wrapper = shallowMount(TheSidebar, {
- localVue,
- router,
- });
-
- expect(wrapper.find('[data-testid="routesListTest"]')).toBeDefined();
- });
-
- it("Render with one route", async () => {
- const router = new VueRouter([{ path: "home" }]);
-
- const testRoutes = [
- {
- title: "common.labels.room",
- to: "home",
- icon: "test",
- testId: "testId",
- activeForUrls: ["home"],
- },
- ];
- const wrapper = shallowMount(TheSidebar, {
- propsData: {
- routes: testRoutes,
- },
- localVue,
- router,
- });
- expect(wrapper.findAll("li")).toHaveLength(testRoutes.length);
- expect(wrapper.find("v-icon").exists()).toBe(true);
- });
-
- it("Render with more routes mixing to and href", () => {
- const router = new VueRouter([{ path: "home" }]);
-
- const testRoutes = [
- {
- title: "common.labels.status",
- to: "home",
- active: true,
- icon: "test",
- testId: "testId",
- activeForUrls: ["home"],
- },
- {
- title: "common.labels.search",
- href: "https://www.bing.com",
- active: false,
- icon: "test",
- testId: "testId",
- activeForUrls: [],
- },
- {
- title: "common.labels.title",
- to: "away",
- active: false,
- icon: "away",
- testId: "testId",
- activeForUrls: ["away"],
- },
- {
- title: "common.labels.teacher",
- href: "https://www.google.com",
- active: true,
- icon: "test",
- testId: "testId",
- activeForUrls: [],
- },
- ];
- const wrapper = shallowMount(TheSidebar, {
- propsData: {
- routes: testRoutes,
- },
- localVue,
- router,
- });
- expect(wrapper.findAll("li")).toHaveLength(testRoutes.length);
- expect(wrapper.findAll("v-icon")).toHaveLength(4);
- expect(wrapper.findAll(".side-bar-title").at(0).text()).toBe("Status");
- });
-});
diff --git a/src/components/legacy/TheSidebar.unit.ts b/src/components/legacy/TheSidebar.unit.ts
new file mode 100644
index 0000000000..69813d8533
--- /dev/null
+++ b/src/components/legacy/TheSidebar.unit.ts
@@ -0,0 +1,96 @@
+import { shallowMount } from "@vue/test-utils";
+import TheSidebar from "./TheSidebar.vue";
+import {
+ createTestingI18n,
+ createTestingVuetify,
+} from "@@/tests/test-utils/setup";
+
+import { RouteLocationNormalizedLoaded, useRoute } from "vue-router";
+import { reactive } from "vue";
+import { SidebarItemList } from "@/utils/sidebar-base-items";
+jest.mock("vue-router");
+
+const useRouteMock = >>(
+ useRoute
+);
+
+describe("@/components/legacy/TheSidebar", () => {
+ const setup = (testRoutes: SidebarItemList) => {
+ useRouteMock.mockImplementation(() => reactive({ path: "home" }));
+
+ const wrapper = shallowMount(TheSidebar, {
+ props: {
+ routes: testRoutes,
+ },
+ global: {
+ plugins: [createTestingVuetify(), createTestingI18n()],
+ },
+ });
+
+ return { wrapper };
+ };
+
+ it("Render with empty routes", () => {
+ const { wrapper } = setup([]);
+
+ expect(wrapper.find('[data-testid="routesListTest"]')).toBeDefined();
+ });
+
+ it("Render with one route", async () => {
+ const testRoutes: SidebarItemList = [
+ {
+ title: "common.labels.room",
+ to: "home",
+ icon: "test",
+ testId: "testId",
+ activeForUrls: ["home"],
+ },
+ ];
+
+ const { wrapper } = setup(testRoutes);
+
+ expect(wrapper.findAll("li")).toHaveLength(testRoutes.length);
+ expect(wrapper.findComponent({ name: "v-icon" }).exists()).toBe(true);
+ });
+
+ it("Render with more routes mixing to and href", () => {
+ const testRoutes: SidebarItemList = [
+ {
+ title: "common.labels.status",
+ to: "home",
+ icon: "test",
+ testId: "testId",
+ activeForUrls: ["home"],
+ },
+ {
+ title: "common.labels.search",
+ href: "https://www.bing.com",
+ icon: "test",
+ testId: "testId",
+ activeForUrls: ["home"],
+ },
+ {
+ title: "common.labels.title",
+ to: "away",
+ icon: "away",
+ testId: "testId",
+ activeForUrls: ["home"],
+ },
+ {
+ title: "common.labels.teacher",
+ href: "https://www.google.com",
+ icon: "test",
+ testId: "testId",
+ activeForUrls: ["home"],
+ },
+ ];
+
+ const { wrapper } = setup(testRoutes);
+
+ expect(wrapper.findAll("li")).toHaveLength(testRoutes.length);
+ expect(wrapper.findAllComponents({ name: "v-icon" })).toHaveLength(4);
+ expect(wrapper.findAll(".side-bar-title").at(0)?.text()).toBe(
+ "common.labels.status"
+ );
+ });
+});
diff --git a/src/components/legacy/TheSidebar.vue b/src/components/legacy/TheSidebar.vue
index ae52e8170d..169b770940 100644
--- a/src/components/legacy/TheSidebar.vue
+++ b/src/components/legacy/TheSidebar.vue
@@ -71,8 +71,8 @@
class="icon"
:color="
isActive(child.title)
- ? 'var(--v-primary-base)'
- : 'var(--v-secondary-base)'
+ ? 'rgba(var(--v-theme-primary))'
+ : 'rgba(var(--v-theme-secondary))'
"
>{{ child.icon }}
@@ -96,7 +96,7 @@ import {
SidebarItemList,
SidebarItemRouterLink,
} from "@/utils/sidebar-base-items";
-import { useRoute } from "vue-router/composables";
+import { useRoute } from "vue-router";
export default defineComponent({
name: "TheSidebar",
@@ -152,8 +152,8 @@ export default defineComponent({
const getIconColor = (route: SidebarItem | SidebarCategoryItem) => {
return isActive(route.title) || isChildActive(route.title)
- ? "var(--v-primary-base)"
- : "var(--v-secondary-base)";
+ ? "rgba(var(--v-theme-primary))"
+ : "rgba(var(--v-theme-secondary))";
};
const hasChildren = (
@@ -191,7 +191,7 @@ export default defineComponent({
diff --git a/src/components/lern-store/ContentCard.unit.js b/src/components/lern-store/ContentCard.unit.js
new file mode 100644
index 0000000000..2cfb99a60c
--- /dev/null
+++ b/src/components/lern-store/ContentCard.unit.js
@@ -0,0 +1,123 @@
+import ContentCard from "./ContentCard";
+import { Resource } from "@@/tests/test-utils/mockDataResource";
+import { Collection } from "@@/tests/test-utils/mockDataCollection";
+import {
+ createTestingI18n,
+ createTestingVuetify,
+} from "@@/tests/test-utils/setup";
+import AuthModule from "@/store/auth";
+import ContentModule from "@/store/content";
+import BaseInput from "@/components/base/BaseInput/BaseInput.vue";
+import { RouterLinkStub } from "@vue/test-utils";
+import setupStores from "@@/tests/test-utils/setupStores";
+
+describe("@/components/organisms/ContentCard", () => {
+ beforeEach(() => {
+ setupStores({
+ authModule: AuthModule,
+ contentModule: ContentModule,
+ });
+ });
+
+ const setup = (resource = Resource) => {
+ const wrapper = mount(ContentCard, {
+ global: {
+ plugins: [createTestingVuetify(), createTestingI18n()],
+ mocks: {
+ $route: { query: { course: "Kurs" } },
+ },
+ components: {
+ "base-input": BaseInput,
+ "router-link": RouterLinkStub,
+ },
+ },
+ props: { resource },
+ });
+ return { wrapper };
+ };
+
+ it("Sets inline attribute to query when the prop is set to true", () => {
+ const { wrapper } = setup();
+
+ wrapper.setProps({ inline: true });
+ wrapper.vm.$nextTick(() => {
+ expect(wrapper.vm.inline).toBe(true);
+ expect(wrapper.vm.query).toMatchObject({ inline: 1 });
+ });
+ });
+
+ it("Renders head of contentCard as a link", () => {
+ const { wrapper } = setup();
+ expect(wrapper.find(".title-link").exists()).toBe(true);
+ });
+
+ it("Renders contentCard img", () => {
+ const { wrapper } = setup();
+
+ expect(wrapper.find(".content__img-thumbnail").exists()).toBe(true);
+ expect(wrapper.find(".content__img-thumbnail").attributes("src")).toBe(
+ Resource.preview.url
+ );
+ expect(wrapper.find(".content__img-thumbnail").attributes("alt")).toBe("");
+ });
+
+ it("Renders title of content Card", () => {
+ const { wrapper } = setup();
+
+ expect(wrapper.find(".content__title").exists()).toBe(true);
+ expect(wrapper.find(".content__title").text()).toBe(
+ "Technik der Dotierung"
+ );
+ });
+
+ it("Renders footer of content Card for single elements", () => {
+ const { wrapper } = setup();
+
+ expect(wrapper.find(".footer").exists()).toBe(true);
+ expect(wrapper.find(".footer__icon-container").exists()).toBe(true);
+ });
+
+ describe("@/components/organisms/ContentCard Collection", () => {
+ it("Renders head of contentCard as a link", () => {
+ const { wrapper } = setup(Collection);
+ expect(wrapper.find(".title-link").exists()).toBe(true);
+ });
+
+ it("Renders contentCard img", () => {
+ const { wrapper } = setup(Collection);
+
+ expect(wrapper.find(".content__img-thumbnail").exists()).toBe(true);
+ expect(wrapper.find(".content__img-thumbnail").attributes("src")).toBe(
+ Collection.preview.url
+ );
+ expect(wrapper.find(".content__img-thumbnail").attributes("alt")).toBe(
+ ""
+ );
+ });
+
+ it("Renders collection icon", () => {
+ const { wrapper } = setup(Collection);
+
+ const cardTag = wrapper.get(".card-tag");
+ const collectionIcon = cardTag.getComponent({ name: "v-icon" });
+
+ expect(collectionIcon.props("icon")).toBe("$ic_collection");
+ });
+
+ it("Renders title of content Card", () => {
+ const { wrapper } = setup(Collection);
+
+ expect(wrapper.find(".content__title").exists()).toBe(true);
+ expect(wrapper.find(".content__title").text()).toBe(
+ "heimische Singvögel"
+ );
+ });
+
+ it("Renders footer of content Card for single elements", () => {
+ const { wrapper } = setup(Collection);
+
+ expect(wrapper.find(".footer").exists()).toBe(true);
+ expect(wrapper.find(".footer__icon-container").exists()).toBe(true);
+ });
+ });
+});
diff --git a/src/components/organisms/ContentCard.vue b/src/components/lern-store/ContentCard.vue
similarity index 89%
rename from src/components/organisms/ContentCard.vue
rename to src/components/lern-store/ContentCard.vue
index 8cfa2c72ec..e82485012f 100644
--- a/src/components/organisms/ContentCard.vue
+++ b/src/components/lern-store/ContentCard.vue
@@ -20,7 +20,10 @@
:label="resource.title"
:label-hidden="true"
class="select"
- style="color: var(--v-white-base); margin: -1px 8px 4px -4px"
+ style="
+ color: rgba(var(--v-theme-white));
+ margin: -1px 8px 4px -4px;
+ "
/>
@@ -33,9 +36,10 @@
/>
{{ $t("pages.content.card.collection") }}
-
- $ic_collection
-
+