-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #502 from CloudCannon/feat/highlight-polish
Final polish for the highlighting feature
- Loading branch information
Showing
16 changed files
with
352 additions
and
264 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
pagefind/features/highlighting/highlighting_search.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
Feature: Highlighting Search Tests | ||
|
||
Background: | ||
Given I have the environment variables: | ||
| PAGEFIND_SITE | public | | ||
Given I have a "public/index.html" file with the body: | ||
""" | ||
<p data-url>Nothing</p> | ||
""" | ||
Given I have a "public/a/index.html" file with the body: | ||
""" | ||
<p>Hello World</p> | ||
""" | ||
Given I have a "public/b/index.html" file with the body: | ||
""" | ||
<h2 id="second">Second</h2> | ||
<p>Second Page</p> | ||
""" | ||
|
||
Scenario: Query parameters can be inserted through the JS API | ||
When I run my program | ||
Then I should see "Running Pagefind" in stdout | ||
Then I should see the file "public/pagefind/pagefind.js" | ||
When I serve the "public" directory | ||
When I load "/" | ||
When I evaluate: | ||
""" | ||
async function() { | ||
let pagefind = await import("/pagefind/pagefind.js"); | ||
await pagefind.options({ highlightParam: "hi" }); | ||
let search = await pagefind.search("world"); | ||
let data = await search.results[0].data(); | ||
document.querySelector('[data-url]').innerText = data.url; | ||
} | ||
""" | ||
Then There should be no logs | ||
Then The selector "[data-url]" should contain "/a/?hi=world" | ||
|
||
Scenario: Multiple query parameters are inserted through the JS API | ||
When I run my program | ||
Then I should see "Running Pagefind" in stdout | ||
Then I should see the file "public/pagefind/pagefind.js" | ||
When I serve the "public" directory | ||
When I load "/" | ||
When I evaluate: | ||
""" | ||
async function() { | ||
let pagefind = await import("/pagefind/pagefind.js"); | ||
await pagefind.options({ highlightParam: "hi" }); | ||
let search = await pagefind.search("hello world"); | ||
let data = await search.results[0].data(); | ||
document.querySelector('[data-url]').innerText = data.url; | ||
} | ||
""" | ||
Then There should be no logs | ||
Then The selector "[data-url]" should contain "/a/?hi=hello&hi=world" | ||
|
||
Scenario: Query parameters don't conflict with subresult anchors | ||
When I run my program | ||
Then I should see "Running Pagefind" in stdout | ||
Then I should see the file "public/pagefind/pagefind.js" | ||
When I serve the "public" directory | ||
When I load "/" | ||
When I evaluate: | ||
""" | ||
async function() { | ||
let pagefind = await import("/pagefind/pagefind.js"); | ||
await pagefind.options({ highlightParam: "hi" }); | ||
let search = await pagefind.search("second"); | ||
let data = await search.results[0].data(); | ||
document.querySelector('[data-url]').innerText = data.sub_results[0].url; | ||
} | ||
""" | ||
Then There should be no logs | ||
Then The selector "[data-url]" should contain "/b/?hi=second#second" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.