Loading client/src/components/History/CurrentHistory/HistoryOperations/SelectionOperations.test.js +71 −28 Original line number Diff line number Diff line Loading @@ -25,8 +25,13 @@ const TASKS_CONFIG = { }; const getMenuSelectorFor = (option) => `[data-description="${option} option"]`; const getPurgedContentSelection = () => new Map([["FAKE_ID", { purged: true }]]); const getNonPurgedContentSelection = () => new Map([["FAKE_ID", { purged: false }]]); const getPurgedSelection = () => new Map([["FAKE_ID", { purged: true }]]); const getNonPurgedSelection = () => new Map([["FAKE_ID", { purged: false }]]); const getVisibleSelection = () => new Map([["FAKE_ID", { visible: true }]]); const getHiddenSelection = () => new Map([["FAKE_ID", { visible: false }]]); const getDeletedSelection = () => new Map([["FAKE_ID", { deleted: true }]]); const getActiveSelection = () => new Map([["FAKE_ID", { deleted: false }]]); async function mountSelectionOperationsWrapper(config) { const wrapper = shallowMount( Loading Loading @@ -76,32 +81,62 @@ describe("History Selection Operations", () => { expect(wrapper.find('[data-description="selected count"]').text()).toContain("10"); }); it("should display 'hide' option only on visible items", async () => { it("should display 'hide' option on visible items", async () => { const option = getMenuSelectorFor("hide"); expect(wrapper.find(option).exists()).toBe(true); await wrapper.setProps({ filterText: "visible:true" }); expect(wrapper.find(option).exists()).toBe(true); }); it("should display 'hide' option when visible and hidden items are mixed", async () => { const option = getMenuSelectorFor("hide"); expect(wrapper.find(option).exists()).toBe(true); await wrapper.setProps({ filterText: "visible:any" }); expect(wrapper.find(option).exists()).toBe(true); }); it("should not display 'hide' option when only hidden items are selected", async () => { const option = getMenuSelectorFor("hide"); expect(wrapper.find(option).exists()).toBe(true); await wrapper.setProps({ filterText: "visible:any", contentSelection: getHiddenSelection() }); expect(wrapper.find(option).exists()).toBe(false); await wrapper.setProps({ filterText: "visible:false" }); expect(wrapper.find(option).exists()).toBe(false); }); it("should display 'unhide' option on hidden items", async () => { const option = getMenuSelectorFor("unhide"); expect(wrapper.find(option).exists()).toBe(false); await wrapper.setProps({ filterText: "visible:false" }); expect(wrapper.find(option).exists()).toBe(true); }); it("should display 'unhide' option when hidden and visible items are mixed", async () => { const option = getMenuSelectorFor("unhide"); expect(wrapper.find(option).exists()).toBe(false); await wrapper.setProps({ filterText: "visible:any" }); expect(wrapper.find(option).exists()).toBe(true); }); it("should not display 'unhide' option when only visible items are selected", async () => { const option = getMenuSelectorFor("unhide"); await wrapper.setProps({ filterText: "visible:any", contentSelection: getVisibleSelection(), }); expect(wrapper.find(option).exists()).toBe(false); }); it("should display 'delete' option on non-deleted items", async () => { const option = getMenuSelectorFor("delete"); expect(wrapper.find(option).exists()).toBe(true); await wrapper.setProps({ filterText: "deleted:true" }); expect(wrapper.find(option).exists()).toBe(false); await wrapper.setProps({ filterText: "deleted:false" }); expect(wrapper.find(option).exists()).toBe(true); }); it("should display 'delete' option on non-deleted items", async () => { const option = getMenuSelectorFor("delete"); expect(wrapper.find(option).exists()).toBe(true); await wrapper.setProps({ filterText: "deleted:false" }); expect(wrapper.find(option).exists()).toBe(true); }); it("should display 'delete' option when non-deleted and deleted items are mixed", async () => { Loading @@ -110,10 +145,17 @@ describe("History Selection Operations", () => { expect(wrapper.find(option).exists()).toBe(true); }); it("should not display 'delete' option when only deleted items are selected", async () => { const option = getMenuSelectorFor("delete"); expect(wrapper.find(option).exists()).toBe(true); await wrapper.setProps({ filterText: "deleted:any", contentSelection: getDeletedSelection() }); expect(wrapper.find(option).exists()).toBe(false); }); it("should display 'permanently delete' option always", async () => { const option = getMenuSelectorFor("purge"); expect(wrapper.find(option).exists()).toBe(true); await wrapper.setProps({ filterText: "deleted:true" }); await wrapper.setProps({ filterText: "deleted:any visible:any" }); expect(wrapper.find(option).exists()).toBe(true); }); Loading @@ -122,7 +164,7 @@ describe("History Selection Operations", () => { expect(wrapper.find(option).exists()).toBe(false); await wrapper.setProps({ filterText: "deleted:true", contentSelection: getNonPurgedContentSelection(), contentSelection: getNonPurgedSelection(), }); expect(wrapper.find(option).exists()).toBe(true); }); Loading @@ -131,16 +173,24 @@ describe("History Selection Operations", () => { const option = getMenuSelectorFor("undelete"); await wrapper.setProps({ filterText: "deleted:any", contentSelection: getNonPurgedContentSelection(), contentSelection: getNonPurgedSelection(), }); expect(wrapper.find(option).exists()).toBe(true); }); it("should not display 'undelete' when is manual selection mode and all selected items are purged", async () => { it("should not display 'undelete' when only non-deleted items are selected", async () => { const option = getMenuSelectorFor("undelete"); await wrapper.setProps({ filterText: "deleted:true", contentSelection: getPurgedContentSelection(), filterText: "deleted:any", contentSelection: getActiveSelection(), }); expect(wrapper.find(option).exists()).toBe(false); }); it("should not display 'undelete' when only purged items are selected", async () => { const option = getMenuSelectorFor("undelete"); await wrapper.setProps({ contentSelection: getPurgedSelection(), isQuerySelection: false, }); expect(wrapper.find(option).exists()).toBe(false); Loading @@ -151,7 +201,7 @@ describe("History Selection Operations", () => { // In query selection mode we don't know if some items may not be purged, so we allow to undelete await wrapper.setProps({ filterText: "deleted:true", contentSelection: getPurgedContentSelection(), contentSelection: getPurgedSelection(), isQuerySelection: true, }); expect(wrapper.find(option).exists()).toBe(true); Loading @@ -160,33 +210,26 @@ describe("History Selection Operations", () => { it("should display 'undelete' option when is query selection mode and filtering by any deleted state", async () => { const option = getMenuSelectorFor("undelete"); // In query selection mode we don't know if some items may not be purged, so we allow to undelete await wrapper.setProps({ filterText: "deleted:any", contentSelection: getPurgedContentSelection(), isQuerySelection: true, }); await wrapper.setProps({ filterText: "deleted:any", isQuerySelection: true }); expect(wrapper.find(option).exists()).toBe(true); }); it("should display collection building options only on visible and non-deleted items", async () => { it("should display collection building options only on active (non-deleted) items", async () => { const buildListOption = '[data-description="build list"]'; const buildPairOption = '[data-description="build pair"]'; const buildListOfPairsOption = '[data-description="build list of pairs"]'; await wrapper.setProps({ filterText: "visible:true deleted:false" }); expect(wrapper.find(buildListOption).exists()).toBe(true); expect(wrapper.find(buildPairOption).exists()).toBe(true); expect(wrapper.find(buildListOfPairsOption).exists()).toBe(true); await wrapper.setProps({ filterText: "visible:false" }); expect(wrapper.find(buildListOption).exists()).toBe(false); expect(wrapper.find(buildPairOption).exists()).toBe(false); expect(wrapper.find(buildListOfPairsOption).exists()).toBe(false); await wrapper.setProps({ filterText: "deleted:true" }); expect(wrapper.find(buildListOption).exists()).toBe(false); expect(wrapper.find(buildPairOption).exists()).toBe(false); expect(wrapper.find(buildListOfPairsOption).exists()).toBe(false); await wrapper.setProps({ filterText: "visible:any" }); expect(wrapper.find(buildListOption).exists()).toBe(false); expect(wrapper.find(buildPairOption).exists()).toBe(false); expect(wrapper.find(buildListOfPairsOption).exists()).toBe(false); await wrapper.setProps({ filterText: "visible:any deleted:false" }); expect(wrapper.find(buildListOption).exists()).toBe(true); expect(wrapper.find(buildPairOption).exists()).toBe(true); expect(wrapper.find(buildListOfPairsOption).exists()).toBe(true); await wrapper.setProps({ filterText: "deleted:any" }); expect(wrapper.find(buildListOption).exists()).toBe(false); expect(wrapper.find(buildPairOption).exists()).toBe(false); Loading Loading
client/src/components/History/CurrentHistory/HistoryOperations/SelectionOperations.test.js +71 −28 Original line number Diff line number Diff line Loading @@ -25,8 +25,13 @@ const TASKS_CONFIG = { }; const getMenuSelectorFor = (option) => `[data-description="${option} option"]`; const getPurgedContentSelection = () => new Map([["FAKE_ID", { purged: true }]]); const getNonPurgedContentSelection = () => new Map([["FAKE_ID", { purged: false }]]); const getPurgedSelection = () => new Map([["FAKE_ID", { purged: true }]]); const getNonPurgedSelection = () => new Map([["FAKE_ID", { purged: false }]]); const getVisibleSelection = () => new Map([["FAKE_ID", { visible: true }]]); const getHiddenSelection = () => new Map([["FAKE_ID", { visible: false }]]); const getDeletedSelection = () => new Map([["FAKE_ID", { deleted: true }]]); const getActiveSelection = () => new Map([["FAKE_ID", { deleted: false }]]); async function mountSelectionOperationsWrapper(config) { const wrapper = shallowMount( Loading Loading @@ -76,32 +81,62 @@ describe("History Selection Operations", () => { expect(wrapper.find('[data-description="selected count"]').text()).toContain("10"); }); it("should display 'hide' option only on visible items", async () => { it("should display 'hide' option on visible items", async () => { const option = getMenuSelectorFor("hide"); expect(wrapper.find(option).exists()).toBe(true); await wrapper.setProps({ filterText: "visible:true" }); expect(wrapper.find(option).exists()).toBe(true); }); it("should display 'hide' option when visible and hidden items are mixed", async () => { const option = getMenuSelectorFor("hide"); expect(wrapper.find(option).exists()).toBe(true); await wrapper.setProps({ filterText: "visible:any" }); expect(wrapper.find(option).exists()).toBe(true); }); it("should not display 'hide' option when only hidden items are selected", async () => { const option = getMenuSelectorFor("hide"); expect(wrapper.find(option).exists()).toBe(true); await wrapper.setProps({ filterText: "visible:any", contentSelection: getHiddenSelection() }); expect(wrapper.find(option).exists()).toBe(false); await wrapper.setProps({ filterText: "visible:false" }); expect(wrapper.find(option).exists()).toBe(false); }); it("should display 'unhide' option on hidden items", async () => { const option = getMenuSelectorFor("unhide"); expect(wrapper.find(option).exists()).toBe(false); await wrapper.setProps({ filterText: "visible:false" }); expect(wrapper.find(option).exists()).toBe(true); }); it("should display 'unhide' option when hidden and visible items are mixed", async () => { const option = getMenuSelectorFor("unhide"); expect(wrapper.find(option).exists()).toBe(false); await wrapper.setProps({ filterText: "visible:any" }); expect(wrapper.find(option).exists()).toBe(true); }); it("should not display 'unhide' option when only visible items are selected", async () => { const option = getMenuSelectorFor("unhide"); await wrapper.setProps({ filterText: "visible:any", contentSelection: getVisibleSelection(), }); expect(wrapper.find(option).exists()).toBe(false); }); it("should display 'delete' option on non-deleted items", async () => { const option = getMenuSelectorFor("delete"); expect(wrapper.find(option).exists()).toBe(true); await wrapper.setProps({ filterText: "deleted:true" }); expect(wrapper.find(option).exists()).toBe(false); await wrapper.setProps({ filterText: "deleted:false" }); expect(wrapper.find(option).exists()).toBe(true); }); it("should display 'delete' option on non-deleted items", async () => { const option = getMenuSelectorFor("delete"); expect(wrapper.find(option).exists()).toBe(true); await wrapper.setProps({ filterText: "deleted:false" }); expect(wrapper.find(option).exists()).toBe(true); }); it("should display 'delete' option when non-deleted and deleted items are mixed", async () => { Loading @@ -110,10 +145,17 @@ describe("History Selection Operations", () => { expect(wrapper.find(option).exists()).toBe(true); }); it("should not display 'delete' option when only deleted items are selected", async () => { const option = getMenuSelectorFor("delete"); expect(wrapper.find(option).exists()).toBe(true); await wrapper.setProps({ filterText: "deleted:any", contentSelection: getDeletedSelection() }); expect(wrapper.find(option).exists()).toBe(false); }); it("should display 'permanently delete' option always", async () => { const option = getMenuSelectorFor("purge"); expect(wrapper.find(option).exists()).toBe(true); await wrapper.setProps({ filterText: "deleted:true" }); await wrapper.setProps({ filterText: "deleted:any visible:any" }); expect(wrapper.find(option).exists()).toBe(true); }); Loading @@ -122,7 +164,7 @@ describe("History Selection Operations", () => { expect(wrapper.find(option).exists()).toBe(false); await wrapper.setProps({ filterText: "deleted:true", contentSelection: getNonPurgedContentSelection(), contentSelection: getNonPurgedSelection(), }); expect(wrapper.find(option).exists()).toBe(true); }); Loading @@ -131,16 +173,24 @@ describe("History Selection Operations", () => { const option = getMenuSelectorFor("undelete"); await wrapper.setProps({ filterText: "deleted:any", contentSelection: getNonPurgedContentSelection(), contentSelection: getNonPurgedSelection(), }); expect(wrapper.find(option).exists()).toBe(true); }); it("should not display 'undelete' when is manual selection mode and all selected items are purged", async () => { it("should not display 'undelete' when only non-deleted items are selected", async () => { const option = getMenuSelectorFor("undelete"); await wrapper.setProps({ filterText: "deleted:true", contentSelection: getPurgedContentSelection(), filterText: "deleted:any", contentSelection: getActiveSelection(), }); expect(wrapper.find(option).exists()).toBe(false); }); it("should not display 'undelete' when only purged items are selected", async () => { const option = getMenuSelectorFor("undelete"); await wrapper.setProps({ contentSelection: getPurgedSelection(), isQuerySelection: false, }); expect(wrapper.find(option).exists()).toBe(false); Loading @@ -151,7 +201,7 @@ describe("History Selection Operations", () => { // In query selection mode we don't know if some items may not be purged, so we allow to undelete await wrapper.setProps({ filterText: "deleted:true", contentSelection: getPurgedContentSelection(), contentSelection: getPurgedSelection(), isQuerySelection: true, }); expect(wrapper.find(option).exists()).toBe(true); Loading @@ -160,33 +210,26 @@ describe("History Selection Operations", () => { it("should display 'undelete' option when is query selection mode and filtering by any deleted state", async () => { const option = getMenuSelectorFor("undelete"); // In query selection mode we don't know if some items may not be purged, so we allow to undelete await wrapper.setProps({ filterText: "deleted:any", contentSelection: getPurgedContentSelection(), isQuerySelection: true, }); await wrapper.setProps({ filterText: "deleted:any", isQuerySelection: true }); expect(wrapper.find(option).exists()).toBe(true); }); it("should display collection building options only on visible and non-deleted items", async () => { it("should display collection building options only on active (non-deleted) items", async () => { const buildListOption = '[data-description="build list"]'; const buildPairOption = '[data-description="build pair"]'; const buildListOfPairsOption = '[data-description="build list of pairs"]'; await wrapper.setProps({ filterText: "visible:true deleted:false" }); expect(wrapper.find(buildListOption).exists()).toBe(true); expect(wrapper.find(buildPairOption).exists()).toBe(true); expect(wrapper.find(buildListOfPairsOption).exists()).toBe(true); await wrapper.setProps({ filterText: "visible:false" }); expect(wrapper.find(buildListOption).exists()).toBe(false); expect(wrapper.find(buildPairOption).exists()).toBe(false); expect(wrapper.find(buildListOfPairsOption).exists()).toBe(false); await wrapper.setProps({ filterText: "deleted:true" }); expect(wrapper.find(buildListOption).exists()).toBe(false); expect(wrapper.find(buildPairOption).exists()).toBe(false); expect(wrapper.find(buildListOfPairsOption).exists()).toBe(false); await wrapper.setProps({ filterText: "visible:any" }); expect(wrapper.find(buildListOption).exists()).toBe(false); expect(wrapper.find(buildPairOption).exists()).toBe(false); expect(wrapper.find(buildListOfPairsOption).exists()).toBe(false); await wrapper.setProps({ filterText: "visible:any deleted:false" }); expect(wrapper.find(buildListOption).exists()).toBe(true); expect(wrapper.find(buildPairOption).exists()).toBe(true); expect(wrapper.find(buildListOfPairsOption).exists()).toBe(true); await wrapper.setProps({ filterText: "deleted:any" }); expect(wrapper.find(buildListOption).exists()).toBe(false); expect(wrapper.find(buildPairOption).exists()).toBe(false); Loading