Commit 792ec452 authored by Andrew Fontaine's avatar Andrew Fontaine

Merge branch '343281-reset-filters-disappearing' into 'master'

Global Search - Fix reset filters button

See merge request gitlab-org/gitlab!72627
parents d372e6a1 026fe78e
...@@ -13,9 +13,9 @@ export default { ...@@ -13,9 +13,9 @@ export default {
ConfidentialityFilter, ConfidentialityFilter,
}, },
computed: { computed: {
...mapState(['query', 'sidebarDirty']), ...mapState(['urlQuery', 'sidebarDirty']),
showReset() { showReset() {
return this.query.state || this.query.confidential; return this.urlQuery.state || this.urlQuery.confidential;
}, },
}, },
methods: { methods: {
......
...@@ -20,7 +20,7 @@ describe('GlobalSearchSidebar', () => { ...@@ -20,7 +20,7 @@ describe('GlobalSearchSidebar', () => {
const createComponent = (initialState) => { const createComponent = (initialState) => {
const store = new Vuex.Store({ const store = new Vuex.Store({
state: { state: {
query: MOCK_QUERY, urlQuery: MOCK_QUERY,
...initialState, ...initialState,
}, },
actions: actionSpies, actions: actionSpies,
...@@ -84,7 +84,7 @@ describe('GlobalSearchSidebar', () => { ...@@ -84,7 +84,7 @@ describe('GlobalSearchSidebar', () => {
describe('ResetLinkButton', () => { describe('ResetLinkButton', () => {
describe('with no filter selected', () => { describe('with no filter selected', () => {
beforeEach(() => { beforeEach(() => {
createComponent({ query: {} }); createComponent({ urlQuery: {} });
}); });
it('does not render', () => { it('does not render', () => {
...@@ -94,10 +94,20 @@ describe('GlobalSearchSidebar', () => { ...@@ -94,10 +94,20 @@ describe('GlobalSearchSidebar', () => {
describe('with filter selected', () => { describe('with filter selected', () => {
beforeEach(() => { beforeEach(() => {
createComponent(); createComponent({ urlQuery: MOCK_QUERY });
}); });
it('does render when a filter selected', () => { it('does render', () => {
expect(findResetLinkButton().exists()).toBe(true);
});
});
describe('with filter selected and user updated query back to default', () => {
beforeEach(() => {
createComponent({ urlQuery: MOCK_QUERY, query: {} });
});
it('does render', () => {
expect(findResetLinkButton().exists()).toBe(true); expect(findResetLinkButton().exists()).toBe(true);
}); });
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment