From d29c458bd7f870d9577f1f5d14ca06448aa51b88 Mon Sep 17 00:00:00 2001 From: Jannik Stehle Date: Wed, 17 May 2023 11:04:36 +0200 Subject: [PATCH 1/3] Implement fulltext filter on search result page --- .../enhancement-search-fulltext-filter | 6 ++ .../OcFilterChip/OcFilterChip.spec.ts | 18 +++++ .../components/OcFilterChip/OcFilterChip.vue | 41 +++++++++-- .../src/components/Search/List.vue | 23 ++++++- .../tests/unit/components/Search/List.spec.ts | 29 +++++++- .../web-pkg/src/components/ItemFilter.vue | 2 +- .../src/components/ItemFilterToggle.vue | 68 +++++++++++++++++++ .../unit/components/ItemFilterToggle.spec.ts | 56 +++++++++++++++ .../__snapshots__/ItemFilter.spec.ts.snap | 8 +-- 9 files changed, 234 insertions(+), 17 deletions(-) create mode 100644 changelog/unreleased/enhancement-search-fulltext-filter create mode 100644 packages/web-pkg/src/components/ItemFilterToggle.vue create mode 100644 packages/web-pkg/tests/unit/components/ItemFilterToggle.spec.ts diff --git a/changelog/unreleased/enhancement-search-fulltext-filter b/changelog/unreleased/enhancement-search-fulltext-filter new file mode 100644 index 00000000000..819d3c12da4 --- /dev/null +++ b/changelog/unreleased/enhancement-search-fulltext-filter @@ -0,0 +1,6 @@ +Enhancement: Search fulltext filter + +The search result page now has a fulltext filter which can be used to filter the displayed files by their content. + +https://github.com/owncloud/web/pull/9059 +https://github.com/owncloud/web/issues/9058 diff --git a/packages/design-system/src/components/OcFilterChip/OcFilterChip.spec.ts b/packages/design-system/src/components/OcFilterChip/OcFilterChip.spec.ts index 463f381a100..421d656d8bd 100644 --- a/packages/design-system/src/components/OcFilterChip/OcFilterChip.spec.ts +++ b/packages/design-system/src/components/OcFilterChip/OcFilterChip.spec.ts @@ -2,7 +2,10 @@ import { defaultPlugins, mount } from 'web-test-helpers' import OcFilterChip from './OcFilterChip.vue' const selectors = { + filterChipBtn: '.oc-filter-chip-button', filterChipLabel: '.oc-filter-chip-label', + filterChipDrop: '.oc-filter-chip-drop', + filterChipBtnActive: '.oc-filter-chip-button-selected', clearBtn: '.oc-filter-chip-clear' } @@ -22,6 +25,21 @@ describe('OcFilterChip', () => { await wrapper.find(selectors.clearBtn).trigger('click') expect(wrapper.emitted('clearFilter')).toBeTruthy() }) + describe('isToggle is true', () => { + it('does not render a dropdown', () => { + const { wrapper } = getWrapper({ props: { isToggle: true } }) + expect(wrapper.find(selectors.filterChipDrop).exists()).toBeFalsy() + }) + it('marks filter as active when isToggleActive is true', () => { + const { wrapper } = getWrapper({ props: { isToggle: true, isToggleActive: true } }) + expect(wrapper.find(selectors.filterChipBtnActive).exists()).toBeTruthy() + }) + it('emits the "toggleFilter"-event when clicking the button', async () => { + const { wrapper } = getWrapper({ props: { isToggle: true } }) + await wrapper.find(selectors.filterChipBtn).trigger('click') + expect(wrapper.emitted('toggleFilter')).toBeTruthy() + }) + }) }) const getWrapper = ({ props = {} } = {}) => { diff --git a/packages/design-system/src/components/OcFilterChip/OcFilterChip.vue b/packages/design-system/src/components/OcFilterChip/OcFilterChip.vue index d94eda5b994..1e469b08608 100644 --- a/packages/design-system/src/components/OcFilterChip/OcFilterChip.vue +++ b/packages/design-system/src/components/OcFilterChip/OcFilterChip.vue @@ -1,10 +1,11 @@ +