Skip to content

Commit 711b60a

Browse files
cooperkaTom Smyth
authored andcommitted
9402: Add integration test for advanced search
1 parent b8ff7b6 commit 711b60a

File tree

4 files changed

+31
-3
lines changed

4 files changed

+31
-3
lines changed

app/javascript/components/search/AdvancedSearchFilter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class AdvancedSearchFilter extends React.Component {
2424
type="text"
2525
value={advancedSearchText} />
2626
<Button
27-
className="btn-apply"
27+
className="btn-apply btn-advanced-search"
2828
onClick={onSubmit}>
2929
{I18n.t("common.search")}
3030
</Button>

spec/javascript/components/search/Filters.test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ describe("integration", () => {
3131
const wrapper = mount(<Component {...defaultProps} />);
3232
unsuppressAllErrors();
3333

34+
beforeEach(() => window.location.assign.mockClear());
35+
3436
it("navigates on apply form filter", () => {
3537
wrapper.find("Button.btn-form-filter").simulate("click");
3638
const overlay = shallow(wrapper.find("OverlayTrigger").prop("overlay"));
@@ -40,4 +42,12 @@ describe("integration", () => {
4042
overlay.find("Button.btn-apply").simulate("click");
4143
expect(window.location.assign).toMatchSnapshot();
4244
});
45+
46+
it("navigates on apply advanced search", () => {
47+
wrapper.find("#search_str").simulate("change", {target: {value: "something else"}});
48+
49+
expect(window.location.assign).toMatchSnapshot();
50+
wrapper.find("Button.btn-advanced-search").simulate("click");
51+
expect(window.location.assign).toMatchSnapshot();
52+
});
4353
});

spec/javascript/components/search/__snapshots__/AdvancedSearchFilter.test.js.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ exports[`renders as expected (with query param) 1`] = `
4141
value="query"
4242
/>
4343
<Button
44-
className="btn-apply"
44+
className="btn-apply btn-advanced-search"
4545
onClick={[MockFunction]}
4646
>
4747
Search
@@ -68,7 +68,7 @@ exports[`renders as expected (without query param) 1`] = `
6868
value="query"
6969
/>
7070
<Button
71-
className="btn-apply"
71+
className="btn-apply btn-advanced-search"
7272
onClick={[MockFunction]}
7373
>
7474
Search

spec/javascript/components/search/__snapshots__/Filters.test.js.snap

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`integration navigates on apply advanced search 1`] = `[MockFunction]`;
4+
5+
exports[`integration navigates on apply advanced search 2`] = `
6+
[MockFunction] {
7+
"calls": Array [
8+
Array [
9+
"?search=form%3A(%22Two%22)%20something%20else",
10+
],
11+
],
12+
"results": Array [
13+
Object {
14+
"isThrow": false,
15+
"value": undefined,
16+
},
17+
],
18+
}
19+
`;
20+
321
exports[`integration navigates on apply form filter 1`] = `[MockFunction]`;
422

523
exports[`integration navigates on apply form filter 2`] = `

0 commit comments

Comments
 (0)