-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add dialog for common cartridge export options
* remove download options * add download modal * fix import * add download popup * adjust download modal * Add control dialog for download modal * add tests and adjust download Dialog * adjust downloadModal and tests * adjust & add unittest for download modal * UX changes * reimplement export Dialog * dialog info corrected * add unit test and bug fix * add language translation * repare open/close Dialog and style * Adjust Dialog Style and Tests * add modal unit tests * update dialog Width * fix Typo * add unitest when feature flag is false * rename imscc to common cartridge * rename cc Export * Typo CommonCartridge correction
- Loading branch information
1 parent
7a7ad60
commit 28665a9
Showing
15 changed files
with
698 additions
and
34 deletions.
There are no files selected for viewing
156 changes: 156 additions & 0 deletions
156
src/components/molecules/CommonCartridgeExportModal.unit.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
import CommonCartridgeExportModule from "@/store/common-cartridge-export"; | ||
import NotifierModule from "@/store/notifier"; | ||
import RoomsModule from "@/store/rooms"; | ||
import { | ||
COMMON_CARTRIDGE_EXPORT_MODULE_KEY, | ||
NOTIFIER_MODULE_KEY, | ||
ROOM_MODULE_KEY, | ||
} from "@/utils/inject"; | ||
import { createModuleMocks } from "@/utils/mock-store-module"; | ||
import { | ||
createTestingI18n, | ||
createTestingVuetify, | ||
} from "@@/tests/test-utils/setup"; | ||
import { mount } from "@vue/test-utils"; | ||
import { VDialog } from "vuetify/lib/components/index.mjs"; | ||
import CommonCartridgeExportModal from "@/components/molecules/CommonCartridgeExportModal.vue"; | ||
|
||
describe("@/components/molecules/CommonCartridgeExportModal", () => { | ||
let exportModuleMock: CommonCartridgeExportModule; | ||
const setup = () => { | ||
exportModuleMock = createModuleMocks(CommonCartridgeExportModule, { | ||
getIsExportModalOpen: true, | ||
getVersion: "1.1.0", | ||
startExport: jest.fn(), | ||
resetExportFlow: jest.fn(), | ||
}); | ||
const wrapper = mount(CommonCartridgeExportModal, { | ||
global: { | ||
plugins: [createTestingVuetify(), createTestingI18n()], | ||
provide: { | ||
[COMMON_CARTRIDGE_EXPORT_MODULE_KEY.valueOf()]: exportModuleMock, | ||
[NOTIFIER_MODULE_KEY.valueOf()]: createModuleMocks(NotifierModule), | ||
[ROOM_MODULE_KEY.valueOf()]: createModuleMocks(RoomsModule), | ||
}, | ||
}, | ||
}); | ||
return wrapper; | ||
}; | ||
|
||
it("should render CommonCartridgeExportModal component", () => { | ||
const wrapper = setup(); | ||
expect(wrapper.exists()).toBe(true); | ||
}); | ||
|
||
describe("when getIsExportModalOpen is true", () => { | ||
it("should open the Dialog", async () => { | ||
const wrapper = setup(); | ||
const dialog = wrapper.findComponent(VDialog); | ||
expect(dialog.props("modelValue")).toBe(true); | ||
}); | ||
}); | ||
|
||
describe("onCancel / onCloseDialog", () => { | ||
it("should close dialog when cancel button clicked", async () => { | ||
const wrapper = setup(); | ||
const closeBtn = wrapper.findComponent( | ||
'[data-testid="dialog-cancel-btn"]' | ||
); | ||
await closeBtn.trigger("click"); | ||
const emit = wrapper.emitted(); | ||
expect(emit).toHaveProperty("dialog-closed"); | ||
}); | ||
}); | ||
|
||
describe("onNext", () => { | ||
it("should move to step 2 Dialog and have export button", async () => { | ||
const wrapper = setup(); | ||
const nextBtn = wrapper.findComponent("[data-testid='dialog-next-btn']"); | ||
await nextBtn.trigger("click"); | ||
const emit = wrapper.findComponent("[data-testid='dialog-export-btn']"); | ||
|
||
expect(emit.exists()).toBe(true); | ||
}); | ||
}); | ||
|
||
describe("onBack", () => { | ||
it("should move to step 1 and have next button", async () => { | ||
const wrapper = setup(); | ||
const nextBtn = wrapper.findComponent("[data-testid='dialog-next-btn']"); | ||
await nextBtn.trigger("click"); | ||
const backBtn = wrapper.findComponent("[data-testid='dialog-back-btn']"); | ||
await backBtn.trigger("click"); | ||
const emit = wrapper.findComponent("[data-testid='dialog-next-btn']"); | ||
|
||
expect(emit.exists()).toBe(true); | ||
}); | ||
}); | ||
|
||
describe("onExport", () => { | ||
it("should call startExport and confirm then close the dialog", async () => { | ||
const wrapper = setup(); | ||
const nextBtn = wrapper.findComponent("[data-testid='dialog-next-btn']"); | ||
await nextBtn.trigger("click"); | ||
const exportBtn = wrapper.findComponent( | ||
'[data-testid="dialog-export-btn"]' | ||
); | ||
await exportBtn.trigger("click"); | ||
const emit = wrapper.emitted(); | ||
expect(emit).toHaveProperty("dialog-confirmed"); | ||
expect(emit).toHaveProperty("dialog-closed"); | ||
|
||
exportModuleMock.startExport("1.1.0"); | ||
|
||
expect(exportBtn.exists()).toBe(false); | ||
expect(exportModuleMock.startExport).toHaveBeenCalled(); | ||
}); | ||
}); | ||
|
||
describe("toggleAllTopics", () => { | ||
it("should start with true and change the value when click", async () => { | ||
const wrapper = setup(); | ||
const nextBtn = wrapper.findComponent('[data-testid="dialog-next-btn"]'); | ||
await nextBtn.trigger("click"); | ||
|
||
const allTopics = wrapper.findComponent( | ||
'[data-testid="all-topics-checkbox"]' | ||
); | ||
expect( | ||
allTopics | ||
.findAll("input") | ||
.some((input) => input.attributes("value") === "true") | ||
).toBe(true); | ||
|
||
await allTopics.trigger("click"); | ||
expect( | ||
allTopics | ||
.findAll("input") | ||
.some((input) => input.attributes("value") === "false") | ||
).toBe(false); | ||
}); | ||
}); | ||
|
||
describe("toggleAllTasks", () => { | ||
it("should start with true and change the value when click", async () => { | ||
const wrapper = setup(); | ||
const nextBtn = wrapper.findComponent('[data-testid="dialog-next-btn"]'); | ||
await nextBtn.trigger("click"); | ||
|
||
const allTasks = wrapper.findComponent( | ||
'[data-testid="all-tasks-checkbox"]' | ||
); | ||
expect( | ||
allTasks | ||
.findAll("input") | ||
.some((input) => input.attributes("value") === "true") | ||
).toBe(true); | ||
|
||
await allTasks.trigger("click"); | ||
expect( | ||
allTasks | ||
.findAll("input") | ||
.some((input) => input.attributes("value") === "false") | ||
).toBe(false); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.