Skip to content

Commit

Permalink
fix: pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
lauramargar committed Sep 20, 2023
1 parent 2bd880f commit bea7000
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
16 changes: 11 additions & 5 deletions packages/x-components/src/x-modules/facets/wiring.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { Facet } from '@empathyco/x-types';
import { UrlParams } from '../../types/url-params';
import { createRawFilters } from '../../utils/filters';
import { wireCommit, wireService, wireServiceWithoutPayload } from '../../wiring/wires.factory';
import { wireService, wireServiceWithoutPayload } from '../../wiring/wires.factory';
import { filter, mapWire } from '../../wiring/wires.operators';
import { createWiring } from '../../wiring/wiring.utils';
import { namespacedWireCommit, XEventPayload } from '../../wiring/index';
import {
namespacedWireCommit,
namespacedWireCommitWithoutPayload,
XEventPayload
} from '../../wiring/index';
import { DefaultFacetsService } from './service/facets.service';

/**
Expand All @@ -14,12 +18,14 @@ import { DefaultFacetsService } from './service/facets.service';
*/
const moduleName = 'facets';

const wireCommitWithoutPayload = namespacedWireCommitWithoutPayload(moduleName);

/**
* WireCommit for {@link SearchXModule}.
*
* @internal
*/
const wireCommitModule = namespacedWireCommit(moduleName);
const wireCommit = namespacedWireCommit(moduleName);

/**
* Wires factory for {@link DefaultFacetsService}.
Expand Down Expand Up @@ -139,7 +145,7 @@ const setQuery = wireFacetsService('setQuery');
* @internal
*/
const clearStickyFilters = filter<XEventPayload<'SearchResponseChanged'>>(
wireCommit('x/facets/clearStickyFilters'),
wireCommitWithoutPayload('clearStickyFilters'),
({ eventPayload }) => {
return eventPayload.totalResults === 0;
}
Expand All @@ -150,7 +156,7 @@ const clearStickyFilters = filter<XEventPayload<'SearchResponseChanged'>>(
*
* @public
*/
export const setSelectedFiltersFromPreview = wireCommitModule(
export const setSelectedFiltersFromPreview = wireCommit(
'setFilters',
({ eventPayload: { filters } }) => (filters ? createRawFilters(filters) : [])
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ import { QueryPreviewInfo } from '../../store/index';
import { getXComponentXModuleName, isXComponent } from '../../../../components/index';

function renderQueryPreviewButton({
queryPreviewInfo = { query: 'milk', extraParams: { store: 'Magrathea' } },
queryPreviewInfo = {
query: 'milk',
extraParams: { store: 'Magrathea' },
filters: ['fit:regular']
},
template = `<QueryPreviewButton v-bind="$attrs" />`
}: RenderQueryPreviewButtonOptions = {}): RenderQueryPreviewButtonAPI {
const localVue = createLocalVue();
Expand Down Expand Up @@ -98,7 +102,8 @@ describe('query preview button', () => {
query: 'milk',
extraParams: {
store: 'Magrathea'
}
},
filters: ['fit:regular']
});

await updateExtraParams({ warehouse: 42 });
Expand All @@ -110,7 +115,8 @@ describe('query preview button', () => {
extraParams: {
store: 'Magrathea',
warehouse: 42
}
},
filters: ['fit:regular']
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/x-components/src/x-modules/search/wiring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from '../../wiring/namespaced-wires.factory';
import { WirePayload } from '../../wiring/wiring.types';
import { createWiring } from '../../wiring/wiring.utils';
import { createRawFilters } from '../../utils/index';
import { createRawFilters } from '../../utils/filters';
import { InternalSearchRequest } from './types';

/**
Expand Down

0 comments on commit bea7000

Please sign in to comment.