Skip to content

Commit 9108f33

Browse files
Merge pull request #1958 from cfpb/ans_ds_search_fix
Fix search
2 parents edefc67 + e868cdb commit 9108f33

File tree

3 files changed

+31
-8
lines changed

3 files changed

+31
-8
lines changed

docs/_includes/search-scripts.html

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<script>
2+
(function() {
3+
4+
25
{% assign variations_count = 0 %}
36
// This is an inline script attached to the window so that we can utilize
47
// jekyll's liquid variables, such as site.pages.
@@ -19,20 +22,20 @@
1922

2023
{% for variation in variation_group.variations %}
2124
'variation_name{{ forloop.index }}': '{{ variation.variation_name | escape }}',
22-
'variation_description{{ forloop.index }}': {{ variation.variation_description | markdownify | strip_html | jsonify }},
25+
'variation_description{{ forloop.index }}': {{ variation.variation_description | markdownify | strip_html | url_encode | jsonify }},
2326
'variation_code_snippet{{ forloop.index }}': `{{ variation.variation_code_snippet | escape }}`,
2427
{% endfor %}
2528
{% endfor %}
2629

2730

2831
'title': '{{ page.title | escape }}',
29-
'description': {{ page.description | markdownify | strip_html | jsonify }},
30-
'use_cases': {{ page.use_cases | markdownify | strip_html | jsonify }},
31-
'guidelines': {{ page.guidelines | markdownify | strip_html | jsonify }},
32-
'behavior': {{ page.behavior | markdownify | strip_html | jsonify }},
33-
'accessibility': {{ page.accessibility | markdownify | strip_html | jsonify }},
34-
'research': {{ page.research | markdownify | strip_html | jsonify }},
35-
'related_items': {{ page.related_items | markdownify | strip_html | jsonify }},
32+
'description': {{ page.description | markdownify | strip_html | url_encode | jsonify }},
33+
'use_cases': {{ page.use_cases | markdownify | strip_html | url_encode | jsonify }},
34+
'guidelines': {{ page.guidelines | markdownify | strip_html | url_encode | jsonify }},
35+
'behavior': {{ page.behavior | markdownify | strip_html | url_encode | jsonify }},
36+
'accessibility': {{ page.accessibility | markdownify | strip_html | url_encode | jsonify }},
37+
'research': {{ page.research | markdownify | strip_html | url_encode | jsonify }},
38+
'related_items': {{ page.related_items | markdownify | strip_html | url_encode | jsonify }},
3639
'url': '{{ page.url | escape }}'
3740
}
3841
{% unless forloop.last %},{% endunless %}
@@ -58,5 +61,6 @@
5861
{% unless forloop.last %},{% endunless %}
5962
{% endfor %}
6063
];
64+
})();
6165
</script>
6266
<script src="{{ site.baseurl }}/dist/js/search.js"></script>

docs/assets/css/search.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#search-results {
22
list-style: none;
3+
padding-left: 0;
34
}
45

56
#search-results li {

test/cypress/e2e/docs/search.cy.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
describe('The search feature', () => {
2+
beforeEach(() => {
3+
cy.visit('/search/');
4+
});
5+
6+
it('should show no search results', () => {
7+
cy.get('#search-results').should(
8+
'contain',
9+
"No search results found for ''.",
10+
);
11+
});
12+
13+
it('should show search results', () => {
14+
cy.get('#search-box').type('button');
15+
cy.get('#search-form button').click();
16+
cy.get('#search-results').find('li').its('length').should('be.gte', 1);
17+
});
18+
});

0 commit comments

Comments
 (0)