-
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.
Spec out tests, implement bundle dir
- Loading branch information
Showing
20 changed files
with
510 additions
and
57 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
## Tests | ||
|
||
- `TEST_BINARY=../target/release/pagefind cargo test --release` | ||
- `TEST_BINARY=../target/release/pagefind cargo test --release --test cucumber -- -c 16 --tags "not @skip"` | ||
- `TEST_BINARY=../target/release/pagefind cargo test --release --test cucumber -- --name "<test>"` |
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 |
---|---|---|
@@ -1,29 +1,32 @@ | ||
Feature: Base Tests | ||
Background: | ||
Given I have a "public/index.html" file with the content: | ||
""" | ||
<p data-url> | ||
</p> | ||
""" | ||
|
||
Scenario: Search for a word | ||
Given I have a "public/index.html" file with the content: | ||
""" | ||
<p data-url> | ||
</p> | ||
""" | ||
Given I have a "public/cat/index.html" file with the content: | ||
""" | ||
<body> | ||
<h1>world</h1> | ||
</body> | ||
""" | ||
When I run my program | ||
Then DEBUG 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"); | ||
let results = await pagefind.search("world"); | ||
let data = await results[0].data(); | ||
document.querySelector('[data-url]').innerText = data.url; | ||
} | ||
""" | ||
Then The selector "[data-url]" should contain "/cat/" | ||
Scenario: Search for a word | ||
Given I have a "public/cat/index.html" file with the content: | ||
""" | ||
<body> | ||
<h1>world</h1> | ||
</body> | ||
""" | ||
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"); | ||
let results = await pagefind.search("world"); | ||
let data = await results[0].data(); | ||
document.querySelector('[data-url]').innerText = data.url; | ||
} | ||
""" | ||
Then The selector "[data-url]" should contain "/cat/" |
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,75 @@ | ||
Feature: Build Options | ||
|
||
@skip | ||
Scenario: Settings can be pulled from configuration files | ||
|
||
@skip | ||
Scenario: Settings can be pulled from commandline flags | ||
|
||
@skip | ||
Scenario: Settings can be pulled from environment variables | ||
|
||
Scenario: Source folder can be configured | ||
Given I have a "my_website/index.html" file with the content: | ||
""" | ||
<p data-url> | ||
</p> | ||
""" | ||
Given I have a "my_website/cat/index.html" file with the content: | ||
""" | ||
<body> | ||
<h1>world</h1> | ||
</body> | ||
""" | ||
When I run my program with the flags: | ||
| --source my_website | | ||
Then I should see "Running Pagefind" in stdout | ||
Then I should see the file "my_website/_pagefind/pagefind.js" | ||
When I serve the "my_website" directory | ||
When I load "/" | ||
When I evaluate: | ||
""" | ||
async function() { | ||
let pagefind = await import("/_pagefind/pagefind.js"); | ||
let results = await pagefind.search("world"); | ||
let data = await results[0].data(); | ||
document.querySelector('[data-url]').innerText = data.url; | ||
} | ||
""" | ||
Then The selector "[data-url]" should contain "/cat/" | ||
|
||
Scenario: Output path can be configured | ||
Given I have a "public/index.html" file with the content: | ||
""" | ||
<p data-url> | ||
</p> | ||
""" | ||
Given I have a "public/cat/index.html" file with the content: | ||
""" | ||
<body> | ||
<h1>world</h1> | ||
</body> | ||
""" | ||
When I run my program with the flags: | ||
| --bundle_dir _search | | ||
Then I should see "Running Pagefind" in stdout | ||
Then I should see the file "public/_search/pagefind.js" | ||
When I serve the "public" directory | ||
When I load "/" | ||
When I evaluate: | ||
""" | ||
async function() { | ||
let pagefind = await import("/_search/pagefind.js"); | ||
let results = await pagefind.search("world"); | ||
let data = await results[0].data(); | ||
document.querySelector('[data-url]').innerText = data.url; | ||
} | ||
""" | ||
Then The selector "[data-url]" should contain "/cat/" | ||
|
||
@skip | ||
Scenario: Selector used for indexing can be configured |
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 |
---|---|---|
@@ -1,5 +1,107 @@ | ||
@skip | ||
Feature: Exact Phrase Matching | ||
Background: | ||
Given I have a "public/index.html" file with the content: | ||
""" | ||
<p data-count></p> | ||
<p data-result></p> | ||
""" | ||
|
||
Scenario: Searching in quotes will return pages with exact matches | ||
Scenario: Exact matches will be discouraged across sentence boundaries | ||
Given I have a "public/cat/index.html" file with the content: | ||
""" | ||
<body> | ||
<h1>Happy post about cats</h1> | ||
</body> | ||
""" | ||
Given I have a "public/dog/index.html" file with the content: | ||
""" | ||
<body> | ||
<h1>A post about how cats do not like dogs</h1> | ||
</body> | ||
""" | ||
When I run my program | ||
Then I should see "Running Pagefind" in stdout | ||
When I serve the "public" directory | ||
When I load "/" | ||
When I evaluate: | ||
""" | ||
async function() { | ||
let pagefind = await import("/_pagefind/pagefind.js"); | ||
let results = await pagefind.search(`"about cats"`); | ||
document.querySelector('[data-count]').innerText = `${results.length} result(s)`; | ||
let data = await results[0].data(); | ||
document.querySelector('[data-result]').innerText = data.url; | ||
} | ||
""" | ||
Then The selector "[data-count]" should contain "1 result(s)" | ||
Then The selector "[data-result]" should contain "/cat/" | ||
|
||
Scenario: Exact matches will be discouraged across element boundaries | ||
Given I have a "public/catone/index.html" file with the content: | ||
""" | ||
<body> | ||
<p>Happy post</p> | ||
<p>about cats</p> | ||
</body> | ||
""" | ||
Given I have a "public/cattwo/index.html" file with the content: | ||
""" | ||
<body> | ||
<p>Happy post about cats</p> | ||
</body> | ||
""" | ||
When I run my program | ||
Then I should see "Running Pagefind" in stdout | ||
When I serve the "public" directory | ||
When I load "/" | ||
When I evaluate: | ||
""" | ||
async function() { | ||
let pagefind = await import("/_pagefind/pagefind.js"); | ||
let results = await pagefind.search(`"post about"`); | ||
document.querySelector('[data-count]').innerText = `${results.length} result(s)`; | ||
let data = await results[0].data(); | ||
document.querySelector('[data-result]').innerText = data.url; | ||
} | ||
""" | ||
Then The selector "[data-count]" should contain "1 result(s)" | ||
Then The selector "[data-result]" should contain "/cattwo/" | ||
|
||
Scenario: Exact matches will match across stop words | ||
Given I have a "public/cat/index.html" file with the content: | ||
""" | ||
<body> | ||
<h1>Happy post about the cats</h1> | ||
</body> | ||
""" | ||
# This file will _also_ match, due to our stop word culling | ||
Given I have a "public/dog/index.html" file with the content: | ||
""" | ||
<body> | ||
<h1>A post not about happy cats</h1> | ||
</body> | ||
""" | ||
When I run my program | ||
Then I should see "Running Pagefind" in stdout | ||
When I serve the "public" directory | ||
When I load "/" | ||
When I evaluate: | ||
""" | ||
async function() { | ||
let pagefind = await import("/_pagefind/pagefind.js"); | ||
let results = await pagefind.search(`"about the cats"`); | ||
document.querySelector('[data-count]').innerText = `${results.length} result(s)`; | ||
let data = await Promise.all(results.map(result => result.data())); | ||
document.querySelector('[data-result]').innerText = data.map(d => d.url).join(', '); | ||
} | ||
""" | ||
Then The selector "[data-count]" should contain "2 result(s)" | ||
Then The selector "[data-result]" should contain "/cat/, /dog/" | ||
|
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,36 @@ | ||
@skip | ||
Feature: Exclusions | ||
|
||
Scenario: Elements within search regions can be excluded from indexing and excerpts | ||
Given I have a "public/index.html" file with the content: | ||
""" | ||
<p data-search-one></p> | ||
<p data-search-two></p> | ||
""" | ||
Given I have a "public/cat/index.html" file with the content: | ||
""" | ||
<body> | ||
<p>Hello World, from Pagefind</p> | ||
<p data-pagefind-ignore>Goodbye</p> | ||
<p>Huzzah!</p> | ||
</body> | ||
""" | ||
When I run my program | ||
Then I should see "Running Pagefind" in stdout | ||
When I serve the "public" directory | ||
When I load "/" | ||
When I evaluate: | ||
""" | ||
async function() { | ||
let pagefind = await import("/_pagefind/pagefind.js"); | ||
let searchone = await pagefind.search("hello"); | ||
let searchonedata = await searchone[0].data(); | ||
document.querySelector('[search-one]').innerText = searchonedata.content; | ||
let searchtwo = await pagefind.search("goodbye"); | ||
document.querySelector('[search-two]').innerText = `${searchtwo.length} result(s)`; | ||
} | ||
""" | ||
Then The selector "[data-search-one]" should contain "Hello World, from Pagefind\nHuzzah!" | ||
Then The selector "[data-search-two]" should contain "0 result(s)" |
Oops, something went wrong.