Skip to content
Open
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,6 @@ export default defineComponent({
notifierModule.show({
text: this.$t("pages.content.notification.lernstoreNotAvailable"),
status: "error",
timeout: 5000,
});
}
},
Expand Down
1 change: 0 additions & 1 deletion src/components/molecules/CommonCartridgeExportModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,6 @@ async function onExport(): Promise<void> {
notifier.show({
text: t("common.words.export"),
status: "success",
timeout: 5000,
});

const topicIds: string[] = allTopics.value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,6 @@ const save = async () => {
notifierModule.show({
text: t("pages.administration.school.index.generalSettings.save.success"),
status: "success",
timeout: 5000,
});

if (updatedSchool.logo) {
Expand Down
1 change: 0 additions & 1 deletion src/components/organisms/administration/SchoolPolicy.vue
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ const deleteFile = async () => {
notifierModule.show({
text: t("pages.administration.school.index.schoolPolicy.delete.success"),
status: "success",
timeout: 5000,
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ const submit = async () => {
notifierModule.show({
text: t("pages.administration.school.index.schoolPolicy.success"),
status: "success",
timeout: 5000,
});

resetForm();
Expand Down
1 change: 0 additions & 1 deletion src/components/organisms/administration/SchoolTerms.vue
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ const deleteFile = async () => {
notifierModule.show({
text: t("pages.administration.school.index.termsOfUse.delete.success"),
status: "success",
timeout: 5000,
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ export default defineComponent({
notifierModule.show({
text: t("pages.administration.school.index.termsOfUse.success"),
status: "success",
timeout: 5000,
});

resetForm();
Expand Down
12 changes: 9 additions & 3 deletions src/components/organisms/vCustomDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@
<script setup lang="ts">
import { ModelRef, PropType } from "vue";

export type VCustomDialogButton =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check if other usages of VCustomDialog need to be refactored to this type, too.

| "back"
| "edit"
| "cancel"
| "confirm"
| "close"
| "next";

const props = defineProps({
size: {
type: Number,
Expand Down Expand Up @@ -110,9 +118,7 @@ const props = defineProps({
type: Boolean,
},
buttons: {
type: Array as PropType<
("back" | "edit" | "cancel" | "confirm" | "close" | "next")[]
>,
type: Array as PropType<VCustomDialogButton[]>,
default: () => ["cancel", "confirm"],
},
});
Expand Down
3 changes: 0 additions & 3 deletions src/components/share/ImportFlow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ const showFailureBackend = (name: string) => {
name,
}),
status: "error",
timeout: 5000,
});
closeModals();
};
Expand All @@ -123,7 +122,6 @@ const showFailureInvalidToken = () => {
notifier.show({
text: t("components.molecules.import.options.failure.invalidToken"),
status: "error",
timeout: 5000,
});
closeModals();
};
Expand All @@ -132,7 +130,6 @@ const showFailurePermission = () => {
notifier.show({
text: t("components.molecules.import.options.failure.permissionError"),
status: "error",
timeout: 5000,
});
closeModals();
};
Expand Down
64 changes: 46 additions & 18 deletions src/components/share/ShareModal.unit.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import vCustomDialog from "@/components/organisms/vCustomDialog.vue";
import ShareModalOptionsForm from "@/components/share/ShareModalOptionsForm.vue";
import ShareModalResult from "@/components/share/ShareModalResult.vue";
import { ShareTokenBodyParamsParentTypeEnum } from "@/serverApi/v3";
Expand All @@ -12,6 +11,8 @@ import {
} from "@@/tests/test-utils/setup";
import { mount } from "@vue/test-utils";
import ShareModal from "./ShareModal.vue";
import { VDialog } from "vuetify/components/VDialog";
import { nextTick } from "vue";

describe("@/components/share/ShareModal", () => {
let shareModuleMock: ShareModule;
Expand All @@ -25,6 +26,7 @@ describe("@/components/share/ShareModal", () => {
[SHARE_MODULE_KEY.valueOf()]: shareModuleMock,
[NOTIFIER_MODULE_KEY.valueOf()]: notifierModuleMock,
},
stubs: { UseFocusTrap: true },
},
props: {
type: ShareTokenBodyParamsParentTypeEnum.Courses,
Expand Down Expand Up @@ -57,40 +59,65 @@ describe("@/components/share/ShareModal", () => {

it("should have the correct title", () => {
const { wrapper } = setup();
const title = wrapper.vm.$refs.textTitle as HTMLElement;
const title = wrapper.findComponent({ name: "v-card-title" });

expect(title.textContent).toContain(
"components.molecules.share.options.title"
);
expect(title.text()).toContain("components.molecules.share.options.title");
});

it("should call 'createShareUrl' store method when next button clicked", () => {
const { wrapper } = setup();
const dialog = wrapper.findComponent(vCustomDialog);
const dialog = wrapper.findComponent(VDialog);

const buttons = dialog.findAllComponents({
name: "v-btn",
props: { variant: "flat" },
});
expect(buttons.length).toBe(2);
expect(buttons[0].text()).toBe("common.actions.cancel");
expect(buttons[1].text()).toBe("common.actions.continue");

dialog.vm.$emit("next");
buttons[1].vm.$emit("click");

expect(shareModuleMock.createShareUrl).toHaveBeenCalled();
});

it("should call 'resetShareFlow' store method when dialog closed", () => {
const { wrapper } = setup();
const dialog = wrapper.findComponent(vCustomDialog);
const dialog = wrapper.findComponent(VDialog);

dialog.vm.$emit("dialog-closed");
dialog.vm.$emit("after-leave");

expect(shareModuleMock.resetShareFlow).toHaveBeenCalled();
});

it("should call 'resetShareFlow' store method when sub component emits 'done'", () => {
it("should return the component state to firstStep when dialog closes", () => {
const { wrapper } = setup();
const dialog = wrapper.findComponent(VDialog);

expect((wrapper.vm as unknown as typeof ShareModal).step).toBe("firstStep");

(wrapper.vm as unknown as typeof ShareModal).onNext();
expect((wrapper.vm as unknown as typeof ShareModal).step).toBe(
"secondStep"
);

dialog.vm.$emit("after-leave");
wrapper.vm.$nextTick();
expect((wrapper.vm as unknown as typeof ShareModal).step).toBe("firstStep");
});

it("should call 'resetShareFlow' store method when sub component emits 'done'", async () => {
shareModuleMock = createModuleMocks(ShareModule, {
getIsShareModalOpen: true,
getParentType: ShareTokenBodyParamsParentTypeEnum.Courses,
getShareUrl: "http://example.com",
});
const { wrapper } = setup();
const form = wrapper.findComponent(ShareModalResult);

(wrapper.vm as unknown as typeof ShareModal).step = "secondStep";
await nextTick();

const form = wrapper.findComponent(ShareModalResult);
form.vm.$emit("done");

expect(shareModuleMock.resetShareFlow).toHaveBeenCalled();
Expand All @@ -108,32 +135,33 @@ describe("@/components/share/ShareModal", () => {
).toStrictEqual(payload);
});

it("should call 'onCopy' method when sub component emits 'copied'", async () => {
it("should call 'onCopy' method when 'onNext' is called'", async () => {
shareModuleMock = createModuleMocks(ShareModule, {
getIsShareModalOpen: true,
getParentType: ShareTokenBodyParamsParentTypeEnum.Courses,
getShareUrl: "http://example.com",
});
const { wrapper } = setup();

(wrapper.vm as unknown as typeof ShareModal).onNext();
await wrapper.vm.$nextTick();

const form = wrapper.findComponent(ShareModalResult);

form.vm.$emit("copied");
expect(notifierModuleMock.show).toHaveBeenCalled();
});

describe("ctl tool info", () => {
it("should have the correct title", () => {
it("should have the correct title", async () => {
const { wrapper } = setup();

const dialog = wrapper.findComponent(vCustomDialog);
const cardText = dialog.findComponent({ name: "v-card-text" });

const cardText = wrapper.findComponent({ name: "v-card-text" });
const infotext = cardText.find(
`[data-testid="share-modal-external-tools-info"]`
);

expect(infotext.isVisible()).toBe(true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this invisible-check removed intentionaly?

expect(infotext.text()).toEqual(
expect(infotext.text()).toContain(
"components.molecules.shareImport.options.ctlTools.infoText.unavailable"
);
});
Expand Down
Loading
Loading