mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 01:17:37 -02:30
add test for Lookup clearing QS params
This commit is contained in:
@@ -186,7 +186,7 @@ class Lookup extends React.Component {
|
|||||||
const { history } = this.props;
|
const { history } = this.props;
|
||||||
const parts = history.location.search.replace(/^\?/, '').split('&');
|
const parts = history.location.search.replace(/^\?/, '').split('&');
|
||||||
const ns = this.qsConfig.namespace;
|
const ns = this.qsConfig.namespace;
|
||||||
const otherParts = parts.filter(param => !param.startsWith(`${ns}.`))
|
const otherParts = parts.filter(param => !param.startsWith(`${ns}.`));
|
||||||
history.push(`${history.location.pathname}?${otherParts.join('&')}`);
|
history.push(`${history.location.pathname}?${otherParts.join('&')}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -359,4 +359,33 @@ describe('<Lookup />', () => {
|
|||||||
expect(getItems).toHaveBeenCalledTimes(2);
|
expect(getItems).toHaveBeenCalledTimes(2);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should clear its query params when closed', async () => {
|
||||||
|
mockData = [{ name: 'foo', id: 1, isChecked: false }];
|
||||||
|
const history = createMemoryHistory({
|
||||||
|
initialEntries: ['/organizations/add?inventory.name=foo&bar=baz'],
|
||||||
|
});
|
||||||
|
wrapper = mountWithContexts(
|
||||||
|
<_Lookup
|
||||||
|
multiple
|
||||||
|
name="foo"
|
||||||
|
lookupHeader="Foo Bar"
|
||||||
|
onLookupSave={() => {}}
|
||||||
|
value={mockData}
|
||||||
|
columns={mockColumns}
|
||||||
|
sortedColumnKey="name"
|
||||||
|
getItems={() => {}}
|
||||||
|
location={{ history }}
|
||||||
|
history={history}
|
||||||
|
qsNamespace="inventory"
|
||||||
|
i18n={{ _: val => val.toString() }}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
wrapper
|
||||||
|
.find('InputGroup Button')
|
||||||
|
.at(0)
|
||||||
|
.invoke('onClick')();
|
||||||
|
wrapper.find('Modal').invoke('onClose')();
|
||||||
|
expect(history.location.search).toEqual('?bar=baz');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user