Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/src/search-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ export class SearchaliciousBar extends SuggestionSelectionMixin(
this.selectedOption = undefined;
this.query = ''; // not sure if we should instead put the value of remaining input
} else {
this.resetFacets(false);
this.query = this.selectedOption?.value || '';
this.blurInput();
}
Expand Down
32 changes: 32 additions & 0 deletions frontend/src/test/search-bar_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,36 @@ suite('searchalicious-bar', () => {
'boost_phrase=true&index_id=foo&langs=en&page_size=10&q=test'
);
});

test('submitSuggestion resets facets on direct text submit', async () => {
// create search bar qnad get it
const el = await fixture(html` <searchalicious-bar></searchalicious-bar>`);
const bar = el as SearchaliciousBar;
Comment thread
alexgarel marked this conversation as resolved.

let resetFacetsCalled = false;
const originalResetFacets = (bar as any).resetFacets.bind(bar);
(bar as any).resetFacets = (launchSearch: boolean) => {
resetFacetsCalled = true;
assert.equal(launchSearch, false);
originalResetFacets(launchSearch);
};

// mock search API
(bar as any).search = () => {};
Comment thread
alexgarel marked this conversation as resolved.

// mimic option selection
(bar as any).selectedOption = {
Comment thread
alexgarel marked this conversation as resolved.
value: 'categories:pastas',
label: 'categories:pastas',
id: '--direct-suggestion--categories:pastas',
input: 'categories:pastas',
};
bar.submitSuggestion(false);

assert.isTrue(
resetFacetsCalled,
'resetFacets should be called when submitting a non-suggestion query'
);
assert.equal(bar.query, 'categories:pastas');
});
});