diff --git a/src/components/feature-board-file-element/upload/FileUpload.unit.ts b/src/components/feature-board-file-element/upload/FileUpload.unit.ts index 873e6d46c0..fd1a50e4c4 100644 --- a/src/components/feature-board-file-element/upload/FileUpload.unit.ts +++ b/src/components/feature-board-file-element/upload/FileUpload.unit.ts @@ -55,6 +55,18 @@ describe(FileUpload.name, () => { expect(wrapper.text()).toContain(testSlot); }); + + it("should not show notification on page unload", async () => { + setup(); + + const beforeUnloadEvent = new Event("beforeunload"); + const preventDefaultSpy = jest.fn(); + + beforeUnloadEvent.preventDefault = preventDefaultSpy; + window.dispatchEvent(beforeUnloadEvent); + + expect(preventDefaultSpy).not.toHaveBeenCalled(); + }); }); describe("when file gets picked", () => { @@ -82,6 +94,23 @@ describe(FileUpload.name, () => { const progressLinear = wrapper.find("v-progress-linear-stub"); expect(progressLinear.exists()).toBe(true); }); + + it("should show notification on page unload", async () => { + const { wrapper } = setup(); + + const filePicker = wrapper.findComponent(FilePicker); + expect(filePicker.exists()).toBe(true); + + filePicker.vm.$emit("update:file", { fileName: "Test.jpg" }); + + const beforeUnloadEvent = new Event("beforeunload"); + const preventDefaultSpy = jest.fn(); + + beforeUnloadEvent.preventDefault = preventDefaultSpy; + window.dispatchEvent(beforeUnloadEvent); + + expect(preventDefaultSpy).toHaveBeenCalled(); + }); }); }); diff --git a/src/components/feature-board-file-element/upload/FileUpload.vue b/src/components/feature-board-file-element/upload/FileUpload.vue index 3ba5fec8e6..183e5a5d86 100644 --- a/src/components/feature-board-file-element/upload/FileUpload.vue +++ b/src/components/feature-board-file-element/upload/FileUpload.vue @@ -17,7 +17,7 @@