diff --git a/pagefind/features/anchors.feature b/pagefind/features/anchors.feature deleted file mode 100644 index 8221841b..00000000 --- a/pagefind/features/anchors.feature +++ /dev/null @@ -1,175 +0,0 @@ -Feature: Anchors - - Background: - Given I have the environment variables: - | PAGEFIND_SITE | public | - Given I have a "public/index.html" file with the body: - """ -

Nothing

- """ - Given I have a "public/cat/index.html" file with the body: - """ -

Outer Heading

-
-

PageOne, from Pagefind

-

Cats

- -

Pagefind

-

PageOne, again, from Pagefind

-
-

Outer Content

- """ - Given I have a "public/dog/index.html" file with the body: - """ -
-

PageTwo, from Pagefind

-

Some text nested under the h1

- -

Words in spans should be extracted

-

Some text nested under the p with spans

- -

Links should be extracted

-

Some text nested under the h2

- - Text that is bold or italic should be extracted -

Some text nested under the span

- -

Text containing nested IDs should extract both

-

Some text nested under the p with IDs

- -
Divs containing
💀 he he he 💀
divs should only take from the top level
-

Some text nested under the divs

-
- """ - Given I have a "public/repr/index.html" file with the body: - """ -
-

My Redacted Heading about Symbiosis

-
- """ - When I run my program - Then I should see "Running Pagefind" in stdout - When I serve the "public" directory - When I load "/" - - Scenario: Pagefind returns all word locations in the fragment - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let search = await pagefind.search("pageone"); - let searchdata = await search.results[0].data(); - document.querySelector('[data-search]').innerText = searchdata.locations.join(', '); - } - """ - Then There should be no logs - Then The selector "[data-search]" should contain "0, 9" - - Scenario: Pagefind returns full content without anchors - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let search = await pagefind.search("pageone"); - let searchdata = await search.results[0].data(); - document.querySelector('[data-search]').innerText = searchdata.content; - } - """ - Then There should be no logs - Then The selector "[data-search]" should contain "PageOne, from Pagefind. Cats. Cheeka. Ali. Theodore. Smudge. Pagefind. PageOne, again, from Pagefind." - - Scenario: Pagefind returns all page anchors in the fragment - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let search = await pagefind.search("pageone"); - let searchdata = await search.results[0].data(); - document.querySelector('[data-search]').innerText = searchdata.anchors.map(a => `${a.element}#${a.id}: ${a.location}`).join(', '); - } - """ - Then There should be no logs - Then The selector "[data-search]" should contain "h2#cats: 3, ul#list: 4, li#ali: 5, h2#pagefind: 8" - - Scenario: Pagefind returns page anchor content in the fragment - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let search = await pagefind.search("pageone"); - let searchdata = await search.results[0].data(); - document.querySelector('[data-search]').innerText = searchdata.anchors.map(a => `#${a.id}: '${a.text}'`).join(', '); - } - """ - Then There should be no logs - Then The selector "[data-search]" should contain "#cats: 'Cats', #list: '', #ali: 'Ali', #pagefind: 'Pagefind'" - - Scenario: Pagefind extracts page anchor text where it makes sense - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let search = await pagefind.search("pagetwo"); - let searchdata = await search.results[0].data(); - document.querySelector('[data-search]').innerHTML = ` - - `; - } - """ - Then There should be no logs - Then The selector "[data-search]>ul>li:nth-of-type(1)" should contain "#h1: 'PageTwo, from Pagefind'" - Then The selector "[data-search]>ul>li:nth-of-type(2)" should contain "#p_spans: 'Words in spans should be extracted'" - Then The selector "[data-search]>ul>li:nth-of-type(3)" should contain "#h2_hrefs: 'Links should be extracted'" - Then The selector "[data-search]>ul>li:nth-of-type(4)" should contain "#span_formatted: 'Text that is bold or italic should be extracted'" - Then The selector "[data-search]>ul>li:nth-of-type(5)" should contain "#p_nested_ids: 'Text containing nested IDs should extract both'" - Then The selector "[data-search]>ul>li:nth-of-type(6)" should contain "#span_nested: 'nested IDs'" - Then The selector "[data-search]>ul>li:nth-of-type(7)" should contain "#double_div: 'Divs containing divs should only take from the top level'" - - Scenario: Pagefind returns subresults based on headings - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let search = await pagefind.search("extracted"); - let searchdata = await search.results[0].data(); - document.querySelector('[data-search]').innerHTML = ` - - `; - } - """ - Then There should be no logs - Then The selector "[data-search]>ul>li:nth-of-type(1)" should contain "/dog/#h1: PageTwo, from Pagefind / 'PageTwo, from Pagefind. Some text nested under the h1. Words in spans should be extracted. Some text nested under the p with spans.'" - Then The selector "[data-search]>ul>li:nth-of-type(2)" should contain "/dog/#h2_hrefs: Links should be extracted / 'should be extracted. Some text nested under the h2. Text that is bold or italic should be extracted Some text nested under the span. Text containing nested IDs should extract'" - - Scenario: Pagefind respects data-pagefind-ignore inside anchors - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let search = await pagefind.search("symbiosis"); - let searchdata = await search.results[0].data(); - document.querySelector('[data-search]').innerHTML = ` - - `; - } - """ - Then There should be no logs - Then The selector "[data-search]>ul>li:nth-of-type(1)" should contain "/repr/#repr-heading: My Heading about Symbiosis / 'My Heading about Symbiosis.'" diff --git a/pagefind/features/anchors_example.feature b/pagefind/features/anchors_example.feature deleted file mode 100644 index 2b2ba32c..00000000 --- a/pagefind/features/anchors_example.feature +++ /dev/null @@ -1,54 +0,0 @@ -Feature: Anchors Example - - Background: - Given I have the environment variables: - | PAGEFIND_SITE | public | - Given I have a "public/index.html" file with the body: - """ -

Nothing

- """ - Given I have a "public/installation/index.html" file with the body: - """ -
-

Installing and running Pagefind

-

Pagefind is a static binary with no dynamic dependencies, so in most cases will be simple to install and run. Pagefind is currently supported on Windows, macOS, and x86-64 Linux distributions.

- -

Running via npx

-

Pagefind publishes a wrapper package through npm, which is the easiest way to get started. This package will download the correct binary of the latest release from GitHub for your platform and run it.

-

Specific versions can be run by passing a version tag.

-

Running Pagefind via npx will download the pagefind_extended release, which includes specialized support for indexing Chinese and Japanese pages.

- - -

Downloading a precompiled binary

-

If you prefer to install the tool yourself, you can download a precompiled release from GitHub and run the binary directly.

-

We publish two releases, with one being extended. The extended release is a larger binary, but includes specialized support for indexing Chinese and Japanese pages.

- -

Building from source

-

You can run cargo install pagefind to build from source.

-
- """ - When I run my program - Then I should see "Running Pagefind" in stdout - When I serve the "public" directory - When I load "/" - - Scenario: Pagefind returns subresults for an example page - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - await pagefind.options({ excerptLength: 5 }); - let search = await pagefind.search("pagefind"); - let searchdata = await search.results[0].data(); - document.querySelector('[data-search]').innerHTML = ` - - `; - } - """ - Then There should be no logs - Then The selector "[data-search]>ul>li:nth-of-type(1)" should contain "/installation/: Installing and running Pagefind / 'and running Pagefind. Pagefind is'" - Then The selector "[data-search]>ul>li:nth-of-type(2)" should contain "/installation/#running-via-npx: Running via npx / 'via npx. Pagefind publishes a'" - Then The selector "[data-search]>ul>li:nth-of-type(3)" should contain "/installation/#building-from-source: Building from source / 'run cargo install pagefind to'" diff --git a/pagefind/features/base.feature b/pagefind/features/base.feature deleted file mode 100644 index 54a43942..00000000 --- a/pagefind/features/base.feature +++ /dev/null @@ -1,81 +0,0 @@ -Feature: Base Tests - Background: - Given I have the environment variables: - | PAGEFIND_SITE | public | - Given I have a "public/index.html" file with the body: - """ -

Nothing

- """ - - Scenario: Search for a word - Given I have a "public/cat/index.html" file with the body: - """ -

world

- """ - 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 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 "/cat/" - - Scenario: Preload indexes then search for a word - Given I have a "public/cat/index.html" file with the body: - """ -

world

- """ - 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.preload("wo"); - 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 "/cat/" - - Scenario: Return all results - Given I have a "public/cat/index.html" file with the body: - """ -

world

- """ - 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 search = await pagefind.search(null); - - let pages = await Promise.all(search.results.map(r => r.data())); - document.querySelector('[data-url]').innerText = pages.map(p => p.url).sort().join(", "); - } - """ - Then There should be no logs - Then The selector "[data-url]" should contain "/, /cat/" diff --git a/pagefind/features/build_options.feature b/pagefind/features/build_options.feature deleted file mode 100644 index 70621a39..00000000 --- a/pagefind/features/build_options.feature +++ /dev/null @@ -1,231 +0,0 @@ -Feature: Build Options - Background: - Given I have the environment variables: - | PAGEFIND_SITE | public | - - Scenario: Source folder can be configured - Given I have a "my_website/index.html" file with the body: - """ -

Nothing

- """ - Given I have a "my_website/cat/index.html" file with the body: - """ -

world

- """ - When I run my program with the flags: - | --site 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 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 "/cat/" - - Scenario: Output path can be configured - Given I have a "public/index.html" file with the body: - """ -

Nothing

- """ - Given I have a "public/cat/index.html" file with the body: - """ -

world

- """ - When I run my program with the flags: - | --output-subdir _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 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 "/cat/" - - Scenario: Output path can be configured with an absolute path - Given I have a "public/index.html" file with the body: - """ -

Nothing

- """ - Given I have a "public/cat/index.html" file with the body: - """ -

world

- """ - # {{humane_temp_dir}} will be replaced with an absolute path here, - # making the output-subdir value absolute - When I run my program with the flags: - | --output-subdir {{humane_temp_dir}}/other/_search | - Then I should see "Running Pagefind" in stdout - Then I should see the file "other/_search/pagefind.js" - When I serve the "." directory - When I load "/public/" - When I evaluate: - """ - async function() { - let pagefind = await import("/other/_search/pagefind.js"); - - 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 "/cat/" - - Scenario: Output path can be configured relative to cwd - Given I have a "public/index.html" file with the body: - """ -

Nothing

- """ - Given I have a "public/cat/index.html" file with the body: - """ -

world

- """ - When I run my program with the flags: - | --output-path misc/_search | - Then I should see "Running Pagefind" in stdout - Then I should see the file "misc/_search/pagefind.js" - When I serve the "." directory - When I load "/public/" - When I evaluate: - """ - async function() { - let pagefind = await import("/misc/_search/pagefind.js"); - - 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 "/cat/" - - Scenario: Root selector can be configured - Given I have a "public/index.html" file with the body: - """ -

Nothing

- """ - Given I have a "public/cat/index.html" file with the body: - """ -

Ignored

-
-

Hello

-
-

Also ignored

- """ - When I run my program with the flags: - | --root-selector "body > .content" | - 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 search = await pagefind.search("hello"); - - let data = await search.results[0].data(); - document.querySelector('[data-url]').innerText = `${data.meta.title}, ${data.content} Ignored is ${data.meta.ignored}.`; - } - """ - Then There should be no logs - Then The selector "[data-url]" should contain "Hello, Hello. Ignored is undefined." - - Scenario: File glob can be configured - Given I have a "public/index.html" file with the body: - """ -

Nothing

- """ - Given I have a "public/cat/index.htm" file with the body: - """ -

world

- """ - Given I have a "pagefind.yml" file with the content: - """ - glob: "**/*.{htm,html}" - """ - 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 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 "/cat/index.htm" - - Scenario: Complex exclusionary file glob can be configured - Given I have a "public/index.html" file with the body: - """ -

Nothing

- """ - Given I have a "public/cat/index.htm" file with the body: - """ -

cat index

- """ - Given I have a "public/cat/cat.html" file with the body: - """ -

cat cat

- """ - Given I have a "public/kitty/cat/index.html" file with the body: - """ -

kitty cat index

- """ - Given I have a "public/cat.html" file with the body: - """ -

cat

- """ - Given I have a "pagefind.yml" file with the content: - """ - glob: "{cat/index.htm,kitty/**/*.html,cat.html}" - """ - 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 search = await pagefind.search("cat"); - - let pages = await Promise.all(search.results.map(r => r.data())); - document.querySelector('[data-result]').innerText = pages.map(p => p.url).sort().join(", "); - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "/cat.html, /cat/index.htm, /kitty/cat/" diff --git a/pagefind/features/characters.feature b/pagefind/features/characters.feature deleted file mode 100644 index 6be5c3cb..00000000 --- a/pagefind/features/characters.feature +++ /dev/null @@ -1,281 +0,0 @@ -Feature: Character Tests - Background: - Given I have the environment variables: - | PAGEFIND_SITE | public | - Given I have a "public/index.html" file with the body: - """ -

Nothing

- """ - - Scenario: Pagefind matches special characters - Given I have a "public/apiary/index.html" file with the body: - """ -

Béës

- """ - 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 search = await pagefind.search("Béës"); - - let pages = await Promise.all(search.results.map(r => r.data())); - document.querySelector('[data-result]').innerText = pages.map(p => p.url).join(", "); - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "/apiary/" - - Scenario: Pagefind matches emoji - Given I have a "public/fam-separate/index.html" file with the body: - """ -

Fam 👨‍👩‍👧‍👦

- """ - Given I have a "public/fam-middled/index.html" file with the body: - """ -

F👨‍👩‍👧‍👦am

- """ - 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 search = await pagefind.search("👨‍👩‍👧‍👦"); - - let pages = await Promise.all(search.results.map(r => r.data())); - document.querySelector('[data-result]').innerText = pages.map(p => p.url).sort().join(", "); - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "/fam-middled/, /fam-separate/" - - Scenario: Pagefind doesn't match HTML entities as their text - Given I have a "public/apiary/index.html" file with the body: - """ -

The "bees"

- """ - 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 search = await pagefind.search("bees"); - - let pages = await Promise.all(search.results.map(r => r.data())); - document.querySelector('[data-result]').innerText = pages.map(p => p.content).join(", "); - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain 'The "bees"' - - Scenario: Pagefind handles HTML entities in meta - Given I have a "public/apiary/index.html" file with the body: - """ -

The "bees"

- """ - 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 search = await pagefind.search("bees"); - - let pages = await Promise.all(search.results.map(r => r.data())); - document.querySelector('[data-result]').innerText = pages.map(p => p.meta.title).join(", "); - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain 'The "bees"' - - Scenario: Pagefind can search for a hyphenated phrase - Given I have a "public/ds/index.html" file with the body: - """ -

The beet-root

- """ - 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 search = await pagefind.search("beet-root"); - - let pages = await Promise.all(search.results.map(r => r.data())); - document.querySelector('[data-result]').innerText = pages.map(p => p.url).join(", "); - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain '/ds/' - - Scenario: Pagefind does not return results for queries that normalize to nothing - Given I have a "public/bundaberg/index.html" file with the body: - """ -

Invert can before opening

- """ - 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"); - - // Preload some pages that Pagefind might then return as "all pages" - await pagefind.preload("can"); - let search = await pagefind.search("*"); - - let pages = await Promise.all(search.results.map(r => r.data())); - document.querySelector('[data-result]').innerText = `[${pages.length}]`; - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain '[0]' - - Scenario: Punctuated compound words are indexed per word - Given I have a "public/hyphen/index.html" file with the body: - """ -

beet-root

- """ - Given I have a "public/period/index.html" file with the body: - """ -

image.png

- """ - Given I have a "public/camel/index.html" file with the body: - """ -

WKWebVIEWComponent

- """ - Given I have a "public/underscore/index.html" file with the body: - """ -

Word_Boundaries

- """ - Given I have a "public/slash/index.html" file with the body: - """ -

sandwich/salad

- """ - Given I have a "public/comma/index.html" file with the body: - """ -

Cloud,Cannon

- """ - 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 pages = [ - ...(await Promise.all((await pagefind.search("beet")).results.map(r => r.data()))), - ...(await Promise.all((await pagefind.search("root")).results.map(r => r.data()))), - ]; - - document.querySelector('[data-result]').innerText = pages.map(p => p.url).join(", "); - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain '/hyphen/, /hyphen/' - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let pages = [ - ...(await Promise.all((await pagefind.search("image")).results.map(r => r.data()))), - ...(await Promise.all((await pagefind.search("png")).results.map(r => r.data()))), - ]; - - document.querySelector('[data-result]').innerText = pages.map(p => p.url).join(", "); - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain '/period/, /period/' - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let pages = [ - ...(await Promise.all((await pagefind.search("WkWebVIEWComponent")).results.map(r => r.data()))), - ...(await Promise.all((await pagefind.search("web")).results.map(r => r.data()))), - ...(await Promise.all((await pagefind.search("component")).results.map(r => r.data()))), - ]; - - document.querySelector('[data-result]').innerText = pages.map(p => p.url).join(", "); - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain '/camel/, /camel/, /camel/' - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let pages = [ - ...(await Promise.all((await pagefind.search("word")).results.map(r => r.data()))), - ...(await Promise.all((await pagefind.search("bound")).results.map(r => r.data()))), - ]; - - document.querySelector('[data-result]').innerText = pages.map(p => p.url).join(", "); - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain '/underscore/, /underscore/' - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let pages = [ - ...(await Promise.all((await pagefind.search("sandwich")).results.map(r => r.data()))), - ...(await Promise.all((await pagefind.search("salad")).results.map(r => r.data()))), - ]; - - document.querySelector('[data-result]').innerText = pages.map(p => p.url).join(", "); - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain '/slash/, /slash/' - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let pages = [ - ...(await Promise.all((await pagefind.search("CloudCannon")).results.map(r => r.data()))), - ...(await Promise.all((await pagefind.search("cloud")).results.map(r => r.data()))), - ...(await Promise.all((await pagefind.search("cannon")).results.map(r => r.data()))), - ]; - - document.querySelector('[data-result]').innerText = pages.map(p => p.url).join(", "); - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain '/comma/, /comma/, /comma/' diff --git a/pagefind/features/compound_filtering.feature b/pagefind/features/compound_filtering.feature deleted file mode 100644 index 634479a2..00000000 --- a/pagefind/features/compound_filtering.feature +++ /dev/null @@ -1,237 +0,0 @@ -Feature: Filtering - Background: - Given I have the environment variables: - | PAGEFIND_SITE | public | - Given I have a "public/index.html" file with the body: - """ -

Nothing

- """ - Given I have a "public/cheeka/index.html" file with the body: - """ - Black - White -

Cat

- """ - Given I have a "public/theodore/index.html" file with the body: - """ - Zen - Orange -

Cat

- """ - Given I have a "public/ali/index.html" file with the body: - """ - Angry -

Ali Cat

- """ - Given I have a "public/smudge/index.html" file with the body: - """ - Boisterous - Mischievous - Black - White -

Cat

- """ - Given I have a "public/grey/index.html" file with the body: - """ - Nervous - Pining - Grey -

Cat

- """ - Given I have a "public/treacle/index.html" file with the body: - """ - Lazy - Black - White - Orange -

Cat

- """ - 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() { - window.pagefind = await import("/pagefind/pagefind.js"); - - window.test = async function(pagefind_incantation) { - let search = await pagefind_incantation; - let data = await Promise.all(search.results.map(result => result.data())); - - document.querySelector('[data-results]').innerText = data.map(d => d.url).sort().join(', '); - } - } - """ - - Scenario: Filtering to any of a single filter - When I evaluate: - """ - async function() { - await test(pagefind.search("Cat", { - filters: { - color: { - any: ["Black", "Orange"] - } - } - })); - } - """ - Then There should be no logs - Then The selector "[data-results]" should contain "/cheeka/, /smudge/, /theodore/, /treacle/" - - Scenario: Filtering to any of a set of values and another filter - When I evaluate: - """ - async function() { - await test(pagefind.search("Cat", { - filters: { - color: { - any: ["Black", "Orange"] - }, - mood: "Lazy" - } - })); - } - """ - Then There should be no logs - Then The selector "[data-results]" should contain "/cheeka/, /treacle/" - When I evaluate: - """ - async function() { - await test(pagefind.search("Cat", { - filters: { - color: { - any: ["Black", "Orange"] - }, - mood: "Zen" - } - })); - } - """ - Then There should be no logs - Then The selector "[data-results]" should contain "/theodore/" - - Scenario: Filtering to any of a set of values or another filter - When I evaluate: - """ - async function() { - await test(pagefind.search("Cat", { - filters: { - any: { - color: { - any: ["Black", "Orange"] - }, - mood: "Angry" - } - } - })); - } - """ - Then There should be no logs - Then The selector "[data-results]" should contain "/ali/, /cheeka/, /smudge/, /theodore/, /treacle/" - - Scenario: Filtering to a complex nested filter - When I evaluate: - """ - async function() { - await test(pagefind.search("Cat", { - filters: { - any: [{ - color: { - any: [{ - any: ["Tabby"] - }, { - all: ["Black", "White", "Orange"] - }] - } - }, { - mood: { - all: ["Nervous", "Pining"] - } - }] - } - })); - } - """ - Then There should be no logs - Then The selector "[data-results]" should contain "/ali/, /grey/, /treacle/" - - Scenario: Filtering with an exclusion - When I evaluate: - """ - async function() { - await test(pagefind.search("Cat", { - filters: { - color: { - any: ["Black", "Orange"] - }, - mood: { - not: "Lazy" - } - } - })); - } - """ - Then There should be no logs - Then The selector "[data-results]" should contain "/smudge/, /theodore/" - - Scenario: Filtering with nested exclusions - When I evaluate: - """ - async function() { - await test(pagefind.search("Cat", { - filters: { - all: [ - { - all: [ - { - color: { - any: ["Orange", "White"] - }, - mood: { - any: ["Lazy", "Zen"] - } - }, - { - not: { - color: "Black" - } - } - ] - }, - { - mood: { - none: ["Lazy", "Nervous"] - } - } - ], - } - })); - } - """ - Then There should be no logs - Then The selector "[data-results]" should contain "/theodore/" - - Scenario: Filtering with top-level exclusion - When I evaluate: - """ - async function() { - await test(pagefind.search("Cat", { - filters: { - none: [ - { - color: { - any: ["Orange", "White"] - } - }, - { - mood: "Angry" - } - ] - } - })); - } - """ - Then There should be no logs - Then The selector "[data-results]" should contain "/grey/" diff --git a/pagefind/features/config_sources.feature b/pagefind/features/config_sources.feature deleted file mode 100644 index 75c6371c..00000000 --- a/pagefind/features/config_sources.feature +++ /dev/null @@ -1,79 +0,0 @@ -Feature: Config Sources - - Scenario: Settings can be pulled from TOML configuration files - Given I have a "public/index.html" file with the body: - """ -

Hello.

- """ - Given I have a "pagefind.toml" file with the content: - """ - site = "public" - """ - When I run my program - Then I should see "Running Pagefind" in stdout - Then I should see the file "public/pagefind/pagefind.js" - - Scenario: Settings can be pulled from YAML configuration files - Given I have a "public/index.html" file with the body: - """ -

Hello.

- """ - Given I have a "pagefind.yml" file with the content: - """ - site: public - """ - When I run my program - Then I should see "Running Pagefind" in stdout - Then I should see the file "public/pagefind/pagefind.js" - - Scenario: Settings can be pulled from JSON configuration files - Given I have a "public/index.html" file with the body: - """ -

Hello.

- """ - Given I have a "pagefind.json" file with the content: - """ - { - "site": "public" - } - """ - When I run my program - Then I should see "Running Pagefind" in stdout - Then I should see the file "public/pagefind/pagefind.js" - - Scenario: Settings can be pulled from command-line flags - Given I have a "public/index.html" file with the body: - """ -

Hello.

- """ - When I run my program with the flags: - | --site public | - Then I should see "Running Pagefind" in stdout - Then I should see the file "public/pagefind/pagefind.js" - - Scenario: Settings can be pulled from environment variables - Given I have a "public/index.html" file with the body: - """ -

Hello.

- """ - Given I have the environment variables: - | PAGEFIND_SITE | public | - When I run my program - Then I should see "Running Pagefind" in stdout - Then I should see the file "public/pagefind/pagefind.js" - - Scenario: Settings can be pulled from multiple sources - Given I have a "public/index.html" file with the body: - """ -

Hello.

- """ - Given I have a "pagefind.json" file with the content: - """ - { - "site": "public" - } - """ - When I run my program with the flags: - | --output-subdir _out | - Then I should see "Running Pagefind" in stdout - Then I should see the file "public/_out/pagefind.js" diff --git a/pagefind/features/debounce.feature b/pagefind/features/debounce.feature deleted file mode 100644 index fd6e5e9d..00000000 --- a/pagefind/features/debounce.feature +++ /dev/null @@ -1,75 +0,0 @@ -Feature: Debounced Searches - Background: - Given I have the environment variables: - | PAGEFIND_SITE | public | - Given I have a "public/index.html" file with the body: - """ -

Nothing

-

Nothing

- """ - - Scenario: Debounce repeated search calls - Given I have a "public/cat/index.html" file with the body: - """ -

world

- """ - 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 Promise.all([ - pagefind.debouncedSearch("a"), - pagefind.debouncedSearch("w"), - pagefind.debouncedSearch("wo"), - pagefind.debouncedSearch("wor"), - pagefind.debouncedSearch("worl") - ]); - - document.querySelector('[data-types]').innerText = results.map(r => (r === null ? "null" : r.results.length)).join(', '); - - let pages = await Promise.all(results[4].results.map(r => r.data())); - document.querySelector('[data-last]').innerText = pages.map(p => p.url).sort().join(", "); - } - """ - Then There should be no logs - Then The selector "[data-types]" should contain "null, null, null, null, 1" - Then The selector "[data-last]" should contain "/cat/" - - Scenario: Debounce with options - Given I have a "public/cat/index.html" file with the body: - """ -

world

- """ - 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 Promise.all([ - pagefind.debouncedSearch("a", { filters: {} }), - pagefind.debouncedSearch("w", { filters: {} }), - pagefind.debouncedSearch("wo", { filters: {} }), - pagefind.debouncedSearch("wor", { filters: {} }), - pagefind.debouncedSearch("worl", { filters: {} }) - ]); - - document.querySelector('[data-types]').innerText = results.map(r => (r === null ? "null" : r.results.length)).join(', '); - - let pages = await Promise.all(results[4].results.map(r => r.data())); - document.querySelector('[data-last]').innerText = pages.map(p => p.url).sort().join(", "); - } - """ - Then There should be no logs - Then The selector "[data-types]" should contain "null, null, null, null, 1" - Then The selector "[data-last]" should contain "/cat/" diff --git a/pagefind/features/edge_cases.feature b/pagefind/features/edge_cases.feature deleted file mode 100644 index 04ebb05e..00000000 --- a/pagefind/features/edge_cases.feature +++ /dev/null @@ -1,229 +0,0 @@ -Feature: Graceful Pagefind Errors - Background: - Given I have the environment variables: - | PAGEFIND_SITE | public | - Given I have a "public/index.html" file with the body: - """ -

Nothing

- """ - - Scenario: Pagefind doesn't error on parsing ambiguities - Given I have a "public/cat/index.html" file with the body: - """ -

hello world

- """ - Given I have a "public/dog/index.html" file with the body: - """ -

hello world

- - """ - 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 search = await pagefind.search("world"); - let results = await Promise.all(search.results.map(r => r.data())); - - document.querySelector('[data-url]').innerText = results.map(r => r.url).sort().join(', '); - } - """ - Then There should be no logs - Then The selector "[data-url]" should contain "/cat/, /dog/" - - Scenario: Pagefind finds a data-pagefind-body when elements sit outside of the main html element - Given I have a "public/dog/index.html" file with the body: - """ -

should not be indexed, no data-pagefind-body

- """ - Given I have a "public/cat/index.html" file with the content: - """ - - - - - - -

hello world

- - - - - - """ - When I run my program - Then I should see "Running Pagefind" in stdout - Then I should see "Found a data-pagefind-body element on the site" 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 search = await pagefind.search("world"); - let results = await Promise.all(search.results.map(r => r.data())); - - document.querySelector('[data-url]').innerText = results.map(r => r.url).sort().join(', '); - } - """ - Then There should be no logs - Then The selector "[data-url]" should contain "/cat/" - - Scenario: Pagefind handles non-breaking spaces in segmented language pages - Given I have a "public/index.html" file with the content: - """ - - - -

Nothing

- - - """ - Given I have a "public/ja/index.html" file with the content: - """ - - - -

Hello 👋

- - - """ - 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 search = await pagefind.search("👋"); - let results = await Promise.all(search.results.map(r => r.data())); - - document.querySelector('[data-url]').innerText = results.map(r => r.url).sort().join(', '); - } - """ - Then There should be no logs - Then The selector "[data-url]" should contain "/ja/" - - # Previously, headings that didn't match \w would be filtered out - Scenario: Pagefind multilingual sub-results - Given I have a "public/index.html" file with the content: - """ - - - -

Nothing

- - - """ - Given I have a "public/test/index.html" file with the content: - """ - - - -

چامه - آصف آشنا

-

هزار سال پس از ماجرای گمشدنت

- -

RTL ID

-

از پیاله‌ای چای سیاه پررنگ

- -

بیرون نه می‌روی از من

-

بیرون نه می‌روی از من

- - - """ - 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 search = await pagefind.search("از"); - let results = await Promise.all(search.results.map(r => r.data())); - let result = results[0]; - - let subs = result.sub_results.map(s => s.url).sort().join(', '); - - document.querySelector('[data-url]').innerText = subs; - } - """ - Then There should be no logs - Then The selector "[data-url]" should contain "/test/#%D8%A7%D8%B2, /test/#_top, /test/#rtl-content" - - Scenario: Anchors do not leak through metadata - Given I have a "public/index.html" file with the content: - """ - - - -

Nothing

-

Nothing

-

Nothing

-

Nothing

- - - """ - Given I have a "public/test/index.html" file with the content: - """ - - - -

- Heading text -

-

- Second meta text -

-

- Extra meta text -

-

- Extra filter text -

- - - """ - 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 search = await pagefind.search("text"); - let results = await Promise.all(search.results.map(r => r.data())); - let result = results[0]; - - document.querySelector('[data-title]').innerText = result.meta.title; - - let subs = result.sub_results.map(s => s.title).sort().join(', '); - document.querySelector('[data-subs]').innerText = subs; - - document.querySelector('[data-meta]').innerText = result.meta.extra_meta; - - let filters = await pagefind.filters(); - - document.querySelector('[data-filter]').innerText = Object.keys(filters.extra_filter).join(", "); - } - """ - Then There should be no logs - Then The selector "[data-title]" should contain "Heading text" - Then The selector "[data-subs]" should contain "Heading text, Second meta text" - Then The selector "[data-meta]" should contain "Extra meta text" - Then The selector "[data-filter]" should contain "Extra filter text" diff --git a/pagefind/features/exact_phrase.feature b/pagefind/features/exact_phrase.feature deleted file mode 100644 index 545cb294..00000000 --- a/pagefind/features/exact_phrase.feature +++ /dev/null @@ -1,70 +0,0 @@ -Feature: Exact Phrase Matching - Background: - Given I have the environment variables: - | PAGEFIND_SITE | public | - Given I have a "public/index.html" file with the body: - """ -

Nothing

-

Nothing

- """ - - Scenario: Searching in quotes will return pages with exact matches - Given I have a "public/cat/index.html" file with the body: - """ -

Happy post about cats

- """ - Given I have a "public/dog/index.html" file with the body: - """ -

A post about how cats do not like dogs

- """ - 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 search = await pagefind.search(`"about cats"`); - - document.querySelector('[data-count]').innerText = `${search.results.length} result(s)`; - let data = await search.results[0]?.data(); - document.querySelector('[data-result]').innerText = data?.url; - } - """ - Then There should be no logs - Then The selector "[data-count]" should contain "1 result(s)" - Then The selector "[data-result]" should contain "/cat/" - - @skip - Scenario: Exact matches will be discouraged across element boundaries - Given I have a "public/catone/index.html" file with the body: - """ -

Happy post

-

about cats

- """ - Given I have a "public/cattwo/index.html" file with the body: - """ -

Happy post about cats

- """ - 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 search = await pagefind.search(`"post about"`); - - document.querySelector('[data-count]').innerText = `${search.results.length} result(s)`; - let data = await search.results[0].data(); - document.querySelector('[data-result]').innerText = data.url; - } - """ - Then There should be no logs - Then The selector "[data-count]" should contain "1 result(s)" - Then The selector "[data-result]" should contain "/cattwo/" diff --git a/pagefind/features/exclusions.feature b/pagefind/features/exclusions.feature deleted file mode 100644 index 02656cc0..00000000 --- a/pagefind/features/exclusions.feature +++ /dev/null @@ -1,165 +0,0 @@ -Feature: Exclusions - - Background: - Given I have the environment variables: - | PAGEFIND_SITE | public | - - Scenario: Elements within search regions can be excluded from indexing and excerpts - Given I have a "public/index.html" file with the body: - """ -

Nothing

-

Nothing

- """ - Given I have a "public/cat/index.html" file with the body: - """ -

Hello World, from not Pagefind

-

Goodbye

-
-

Nested content

-
-

Huzzah!

- """ - 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.results[0].data(); - document.querySelector('[data-search-one]').innerText = searchonedata.content; - - let searchtwo = await pagefind.search("goodbye"); - document.querySelector('[data-search-two]').innerText = `${searchtwo.results.length} result(s)`; - } - """ - Then There should be no logs - Then The selector "[data-search-one]" should contain "Hello World, from Pagefind. Huzzah!" - Then The selector "[data-search-two]" should contain "0 result(s)" - - Scenario: Some elements are excluded automatically - Given I have a "public/index.html" file with the body: - """ -

-

- """ - Given I have a "public/cat/index.html" file with the body: - """ -

Hello World, from Pagefind

- - goodbye -
- -
-

Hooray!

- - """ - 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.results[0].data(); - document.querySelector('[data-search-one]').innerText = searchonedata.content; - - let searchtwo = await pagefind.search("goodbye"); - document.querySelector('[data-search-two]').innerText = `${searchtwo.results.length} result(s)`; - } - """ - Then There should be no logs - Then The selector "[data-search-one]" should contain "Hello World, from Pagefind. Hooray!" - Then The selector "[data-search-two]" should contain "0 result(s)" - - Scenario: Tagged elements inside ignored elements can be ignored - Given I have a "public/index.html" file with the body: - """ -

Nothing

- """ - Given I have a "public/cat/index.html" file with the body: - """ -

Hello World, from Pagefind

-
-

Nested content

-
-
-

Nested content

-
-
-

Nested content

-
- """ - 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 search = await pagefind.search("hello"); - let searchdata = await search.results[0].data(); - document.querySelector('[data-search]').innerText = [ - searchdata.meta?.elided || "None", - searchdata.meta?.index || "None", - searchdata.meta?.all || "None", - ].join(' — '); - } - """ - Then There should be no logs - Then The selector "[data-search]" should contain "Nested content — Nested content — None" - - Scenario: Custom selectors can be excluded as an option - Given I have a "public/index.html" file with the body: - """ -

-

- """ - Given I have a "public/cat/index.html" file with the body: - """ -

Hello World, from Pagefind

-
-

Goodbye World!

-
-
-
Hoorah!
-

Hooray!

🙂

-
- """ - Given I have a "pagefind.yml" file with the content: - """ - exclude_selectors: - - '[id^="g"]' - - 'div > div' - """ - 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.results[0].data(); - document.querySelector('[data-search-one]').innerText = searchonedata.content; - - let searchtwo = await pagefind.search("goodbye"); - document.querySelector('[data-search-two]').innerText = `${searchtwo.results.length} result(s)`; - } - """ - Then There should be no logs - Then The selector "[data-search-one]" should contain "Hello World, from Pagefind. Hooray! 🙂" - Then The selector "[data-search-two]" should contain "0 result(s)" diff --git a/pagefind/features/filtering.feature b/pagefind/features/filtering.feature deleted file mode 100644 index be2ef257..00000000 --- a/pagefind/features/filtering.feature +++ /dev/null @@ -1,317 +0,0 @@ -Feature: Filtering - Background: - Given I have the environment variables: - | PAGEFIND_SITE | public | - Given I have a "public/index.html" file with the body: - """ -

Nothing

- """ - Given I have a "public/cheeka/index.html" file with the body: - """ - Black - White -

Cat

- """ - Given I have a "public/theodore/index.html" file with the body: - """ - Orange -

Cat

- """ - Given I have a "public/ali/index.html" file with the body: - """ - Angry -

Ali Cat

- """ - When I run my program - Then I should see "Running Pagefind" in stdout - When I serve the "public" directory - When I load "/" - - Scenario: Filters can be retrieved - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let filters = await pagefind.filters(); - let strings = Object.entries(filters).map(([filter, values]) => { - values = Object.entries(values).map(([value, count]) => { - return `${value}(${count})`; - }) - return `${filter}:[${values.join(", ")}]`; - }); - - document.querySelector('[data-results]').innerText = strings.join(' '); - } - """ - Then There should be no logs - Then The selector "[data-results]" should contain "color:[Black(1), Orange(1), Tabby(1), White(2)] mood:[Angry(1)]" - - Scenario: All results are returned with no filters - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let search = await pagefind.search("Cat"); - let data = await Promise.all(search.results.map(result => result.data())); - - document.querySelector('[data-results]').innerText = data.map(d => d.url).sort().join(', '); - } - """ - Then There should be no logs - Then The selector "[data-results]" should contain "/ali/, /cheeka/, /theodore/" - - Scenario: Filtering on tagged elements - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let search = await pagefind.search("Cat", { - filters: { - color: "Orange" - } - }); - let data = await Promise.all(search.results.map(result => result.data())); - - document.querySelector('[data-results]').innerText = data.map(d => d.url).sort().join(', '); - } - """ - Then There should be no logs - Then The selector "[data-results]" should contain "/theodore/" - - Scenario: Filtering on tagged values - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let search = await pagefind.search("Cat", { - filters: { - color: "Tabby" - } - }); - let data = await Promise.all(search.results.map(result => result.data())); - - document.querySelector('[data-results]').innerText = data.map(d => d.url).sort().join(', '); - } - """ - Then There should be no logs - Then The selector "[data-results]" should contain "/ali/" - - Scenario: Filtering returns multiple results - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let search = await pagefind.search("Cat", { - filters: { - color: "White" - } - }); - let data = await Promise.all(search.results.map(result => result.data())); - - document.querySelector('[data-results]').innerText = data.map(d => d.url).sort().join(', '); - } - """ - Then There should be no logs - Then The selector "[data-results]" should contain "/cheeka/, /theodore/" - - Scenario: Filtering without search term returns only filter - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let search = await pagefind.search(null, { - filters: { - color: "White" - } - }); - let data = await Promise.all(search.results.map(result => result.data())); - - document.querySelector('[data-results]').innerText = data.map(d => d.url).sort().join(', '); - } - """ - Then There should be no logs - Then The selector "[data-results]" should contain "/cheeka/, /theodore/" - - Scenario: Filtering without search term returns an unprocessed excerpt - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - // Run a search so that some index words are loaded - let unused = await pagefind.search("cat"); - - let search = await pagefind.search(null, { - filters: { - color: ["Black", "White"] - } - }); - let data = await Promise.all(search.results.map(result => result.data())); - - document.querySelector('[data-results]').innerText = data.map(d => d.excerpt).join(', '); - } - """ - Then There should be no logs - Then The selector "[data-results]" should contain "Black White Cat." - - Scenario: Non-existent filters return no results - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let search = await pagefind.search("Cat", { - filters: { - name: "Ali" - } - }); - - document.querySelector('[data-results]').innerText = search.results.length; - } - """ - Then There should be no logs - Then The selector "[data-results]" should contain "0" - - Scenario: Non-existent values return no results - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let search = await pagefind.search("Cat", { - filters: { - color: "Green" - } - }); - - document.querySelector('[data-results]').innerText = search.results.length; - } - """ - Then There should be no logs - Then The selector "[data-results]" should contain "0" - - Scenario: Filtering on a search term with no results returns nothing - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let search = await pagefind.search("Pontification", { - filters: { - color: "Orange" - } - }); - - document.querySelector('[data-results]').innerText = search.results.length; - } - """ - Then There should be no logs - Then The selector "[data-results]" should contain "0" - - Scenario: Filter counts are returned for a given search term - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - await pagefind.filters(); // Load filters - let search = await pagefind.search("Ali"); - let strings = Object.entries(search.filters).map(([filter, values]) => { - values = Object.entries(values).map(([value, count]) => { - return `${value}(${count})`; - }) - return `${filter}:[${values.join(", ")}]`; - }); - - document.querySelector('[data-results]').innerText = strings.join(' '); - } - """ - Then There should be no logs - Then The selector "[data-results]" should contain "color:[Black(0), Orange(0), Tabby(1), White(0)] mood:[Angry(1)]" - - Scenario: Total filter counts are returned for a given search term - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - await pagefind.filters(); // Load filters - let search = await pagefind.search("Cat", { - filters: { - color: "White" - } - }); - let strings = Object.entries(search.totalFilters).map(([filter, values]) => { - values = Object.entries(values).map(([value, count]) => { - return `${value}(${count})`; - }) - return `${filter}:[${values.join(", ")}]`; - }); - - document.querySelector('[data-results]').innerText = strings.join(' '); - } - """ - Then There should be no logs - Then The selector "[data-results]" should contain "color:[Black(1), Orange(1), Tabby(1), White(2)] mood:[Angry(1)]" - - Scenario: Total unfiltered result counts are given for a filtered search term - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - await pagefind.filters(); // Load filters - let search = await pagefind.search("Ali", { - filters: { - color: "Orange" - } - }); - document.querySelector('[data-results]').innerText = `results:${search.results.length} total:${search.unfilteredResultCount}`; - } - """ - Then There should be no logs - Then The selector "[data-results]" should contain "results:0 total:1" - - Scenario: Filtering with an empty array returns all results - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let search = await pagefind.search("Cat", { - filters: { - color: [] - } - }); - let data = await Promise.all(search.results.map(result => result.data())); - - document.querySelector('[data-results]').innerText = data.map(d => d.url).sort().join(', '); - } - """ - Then There should be no logs - Then The selector "[data-results]" should contain "/ali/, /cheeka/, /theodore/" - - Scenario: Filtering with an _empty_ bogus filter does nothing - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let search = await pagefind.search("Cat", { - filters: { - something_nonexistent: [] - } - }); - let data = await Promise.all(search.results.map(result => result.data())); - - document.querySelector('[data-results]').innerText = data.map(d => d.url).sort().join(', '); - } - """ - Then There should be no logs - Then The selector "[data-results]" should contain "/ali/, /cheeka/, /theodore/" diff --git a/pagefind/features/frozen-pre-1.0/base.feature b/pagefind/features/frozen-pre-1.0/base.feature deleted file mode 100644 index 1d86b711..00000000 --- a/pagefind/features/frozen-pre-1.0/base.feature +++ /dev/null @@ -1,67 +0,0 @@ -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -# This file represents a backwards-compatible setup as it existed before 1.0 # -# These tests should remain as a permanent regresison check for older sites # -# It is very unlikely that the tests in this file should be touched # -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # - -Feature: Base Tests - Background: - Given I have the environment variables: - | PAGEFIND_SOURCE | public | - Given I have a "public/index.html" file with the body: - """ -

Nothing

- """ - - Scenario: LEGACY Search for a word - Given I have a "public/cat/index.html" file with the body: - """ - -

world

- """ - When I run my program - Then I should see "Running Pagefind" in stdout - Then I should see "pre-1.0 compatibility mode" in stderr - 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 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 "/cat/" - - Scenario: LEGACY Preload indexes then search for a word - Given I have a "public/cat/index.html" file with the body: - """ - -

world

- """ - When I run my program - Then I should see "Running Pagefind" in stdout - Then I should see "pre-1.0 compatibility mode" in stderr - 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.preload("wo"); - 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 "/cat/" diff --git a/pagefind/features/frozen-pre-1.0/build_options.feature b/pagefind/features/frozen-pre-1.0/build_options.feature deleted file mode 100644 index c44c1fb7..00000000 --- a/pagefind/features/frozen-pre-1.0/build_options.feature +++ /dev/null @@ -1,218 +0,0 @@ -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -# This file represents a backwards-compatible setup as it existed before 1.0 # -# These tests should remain as a permanent regresison check for older sites # -# It is very unlikely that the tests in this file should be touched # -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # - -Feature: Build Options - Background: - Given I have the environment variables: - | PAGEFIND_SOURCE | public | - - Scenario: LEGACY Source folder can be configured - Given I have a "my_website/index.html" file with the body: - """ - -

Nothing

- """ - Given I have a "my_website/cat/index.html" file with the body: - """ -

world

- """ - When I run my program with the flags: - | --source my_website | - Then I should see "Running Pagefind" in stdout - Then I should see "pre-1.0 compatibility mode" in stderr - 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 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 "/cat/" - - Scenario: LEGACY Output path can be configured - Given I have a "public/index.html" file with the body: - """ - -

Nothing

- """ - Given I have a "public/cat/index.html" file with the body: - """ -

world

- """ - 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 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 "/cat/" - - Scenario: LEGACY Output path can be configured with an absolute path - Given I have a "public/index.html" file with the body: - """ - -

Nothing

- """ - Given I have a "public/cat/index.html" file with the body: - """ -

world

- """ - # {{humane_temp_dir}} will be replaced with an absolute path here, - # making the bundle-dir value absolute - When I run my program with the flags: - | --bundle-dir {{humane_temp_dir}}/other/_search | - Then I should see "Running Pagefind" in stdout - Then I should see the file "other/_search/pagefind.js" - When I serve the "." directory - When I load "/public/" - When I evaluate: - """ - async function() { - let pagefind = await import("/other/_search/pagefind.js"); - - 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 "/cat/" - - Scenario: LEGACY Root selector can be configured - Given I have a "public/index.html" file with the body: - """ - -

Nothing

- """ - Given I have a "public/cat/index.html" file with the body: - """ -

Ignored

-
-

Hello

-
-

Also ignored

- """ - When I run my program with the flags: - | --root-selector "body > .content" | - Then I should see "Running Pagefind" in stdout - Then I should see "pre-1.0 compatibility mode" in stderr - 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 search = await pagefind.search("hello"); - - let data = await search.results[0].data(); - document.querySelector('[data-url]').innerText = `${data.meta.title}, ${data.content} Ignored is ${data.meta.ignored}.`; - } - """ - Then There should be no logs - Then The selector "[data-url]" should contain "Hello, Hello. Ignored is undefined." - - Scenario: LEGACY File glob can be configured - Given I have a "public/index.html" file with the body: - """ - -

Nothing

- """ - Given I have a "public/cat/index.htm" file with the body: - """ -

world

- """ - Given I have a "pagefind.yml" file with the content: - """ - glob: "**/*.{htm,html}" - """ - When I run my program - Then I should see "Running Pagefind" in stdout - Then I should see "pre-1.0 compatibility mode" in stderr - 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 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 "/cat/index.htm" - - Scenario: LEGACY Complex exclusionary file glob can be configured - Given I have a "public/index.html" file with the body: - """ -

Nothing

- """ - Given I have a "public/cat/index.htm" file with the body: - """ - -

cat index

- """ - Given I have a "public/cat/cat.html" file with the body: - """ -

cat cat

- """ - Given I have a "public/kitty/cat/index.html" file with the body: - """ -

kitty cat index

- """ - Given I have a "public/cat.html" file with the body: - """ -

cat

- """ - Given I have a "pagefind.yml" file with the content: - """ - glob: "{cat/index.htm,kitty/**/*.html,cat.html}" - """ - When I run my program - Then I should see "Running Pagefind" in stdout - Then I should see "pre-1.0 compatibility mode" in stderr - 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 search = await pagefind.search("cat"); - - let pages = await Promise.all(search.results.map(r => r.data())); - document.querySelector('[data-result]').innerText = pages.map(p => p.url).sort().join(", "); - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "/cat.html, /cat/index.htm, /kitty/cat/" diff --git a/pagefind/features/frozen-pre-1.0/config_sources.feature b/pagefind/features/frozen-pre-1.0/config_sources.feature deleted file mode 100644 index 1fab191d..00000000 --- a/pagefind/features/frozen-pre-1.0/config_sources.feature +++ /dev/null @@ -1,96 +0,0 @@ -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -# This file represents a backwards-compatible setup as it existed before 1.0 # -# These tests should remain as a permanent regresison check for older sites # -# It is very unlikely that the tests in this file should be touched # -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # - -Feature: Config Sources - - Scenario: LEGACY Settings can be pulled from TOML configuration files - Given I have a "public/index.html" file with the body: - """ - -

Hello.

- """ - Given I have a "pagefind.toml" file with the content: - """ - source = "public" - """ - When I run my program - Then I should see "Running Pagefind" in stdout - Then I should see "pre-1.0 compatibility mode" in stderr - Then I should see the file "public/_pagefind/pagefind.js" - - Scenario: LEGACY Settings can be pulled from YAML configuration files - Given I have a "public/index.html" file with the body: - """ - -

Hello.

- """ - Given I have a "pagefind.yml" file with the content: - """ - source: public - """ - When I run my program - Then I should see "Running Pagefind" in stdout - Then I should see "pre-1.0 compatibility mode" in stderr - Then I should see the file "public/_pagefind/pagefind.js" - - Scenario: LEGACY Settings can be pulled from JSON configuration files - Given I have a "public/index.html" file with the body: - """ - -

Hello.

- """ - Given I have a "pagefind.json" file with the content: - """ - { - "source": "public" - } - """ - When I run my program - Then I should see "Running Pagefind" in stdout - Then I should see "pre-1.0 compatibility mode" in stderr - Then I should see the file "public/_pagefind/pagefind.js" - - Scenario: LEGACY Settings can be pulled from command-line flags - Given I have a "public/index.html" file with the body: - """ - -

Hello.

- """ - When I run my program with the flags: - | --source public | - Then I should see "Running Pagefind" in stdout - Then I should see "pre-1.0 compatibility mode" in stderr - Then I should see the file "public/_pagefind/pagefind.js" - - Scenario: LEGACY Settings can be pulled from environment variables - Given I have a "public/index.html" file with the body: - """ - -

Hello.

- """ - Given I have the environment variables: - | PAGEFIND_SOURCE | public | - When I run my program - Then I should see "Running Pagefind" in stdout - Then I should see "pre-1.0 compatibility mode" in stderr - Then I should see the file "public/_pagefind/pagefind.js" - - Scenario: LEGACY Settings can be pulled from multiple sources - Given I have a "public/index.html" file with the body: - """ - -

Hello.

- """ - Given I have a "pagefind.json" file with the content: - """ - { - "source": "public" - } - """ - When I run my program with the flags: - | --bundle-dir _out | - Then I should see "Running Pagefind" in stdout - Then I should see the file "public/_out/pagefind.js" diff --git a/pagefind/features/frozen-pre-1.0/modular_ui/modular_ui_base.feature b/pagefind/features/frozen-pre-1.0/modular_ui/modular_ui_base.feature deleted file mode 100644 index 5007d133..00000000 --- a/pagefind/features/frozen-pre-1.0/modular_ui/modular_ui_base.feature +++ /dev/null @@ -1,67 +0,0 @@ -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -# This file represents a backwards-compatible setup as it existed before 1.0 # -# These tests should remain as a permanent regresison check for older sites # -# It is very unlikely that the tests in this file should be touched # -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # - -Feature: Base Modular UI Tests - Background: - Given I have the environment variables: - | PAGEFIND_SOURCE | public | - Given I have a "public/index.html" file with the body: - """ - -
-
- - - - """ - - Scenario: LEGACY Pagefind Modular UI loads - Given I have a "public/cat/index.html" file with the body: - """ -

world

- """ - When I run my program - Then I should see "Running Pagefind" in stdout - Then I should see "pre-1.0 compatibility mode" in stderr - Then I should see the file "public/_pagefind/pagefind.js" - When I serve the "public" directory - When I load "/" - Then There should be no logs - Then The selector "#search input" should exist - - Scenario: LEGACY Pagefind Modular UI searches - Given I have a "public/cat/index.html" file with the body: - """ -

world

- """ - When I run my program - Then I should see "Running Pagefind" in stdout - Then I should see "pre-1.0 compatibility mode" in stderr - 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 e = new Event('input', {bubbles:true, cancelable:true}); - document.querySelector("#search input").value = "world"; - document.querySelector("#search input").dispatchEvent(e); - await new Promise(r => setTimeout(r, 1500)); // TODO: await el in humane - } - """ - Then There should be no logs - Then The selector ".pagefind-modular-list-link" should contain "world" diff --git a/pagefind/features/frozen-pre-1.0/multilingual.feature b/pagefind/features/frozen-pre-1.0/multilingual.feature deleted file mode 100644 index ce904bbb..00000000 --- a/pagefind/features/frozen-pre-1.0/multilingual.feature +++ /dev/null @@ -1,291 +0,0 @@ -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -# This file represents a backwards-compatible setup as it existed before 1.0 # -# These tests should remain as a permanent regresison check for older sites # -# It is very unlikely that the tests in this file should be touched # -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # - -Feature: Multilingual - Background: - Given I have the environment variables: - | PAGEFIND_SOURCE | public | - Given I have a "public/en/index.html" file with the content: - """ - - - - Document - - - -

I am some English documentation

- - - """ - Given I have a "public/pt-br/index.html" file with the content: - """ - - - - Document - - -

I am a Portuguese document (trust me — quilométricas — see?)

- - - """ - - Scenario: LEGACY Pagefind searches for English with English stemming - Given I have a "public/index.html" file with the content: - """ - - - - Document - - - -

Nothing

- - - """ - When I run my program - Then I should see "Running Pagefind" in stdout - Then I should see "pre-1.0 compatibility mode" in stderr - Then I should see the file "public/_pagefind/pagefind.js" - Then I should see the file "public/_pagefind/wasm.unknown.pagefind" - Then I should see the file "public/_pagefind/wasm.en.pagefind" - Then I should see "en" in "public/_pagefind/pagefind-entry.json" - When I serve the "public" directory - When I load "/" - When I evaluate: - """ - async function() { - let pagefind = await import("/_pagefind/pagefind.js"); - - let search = await pagefind.search("documenting"); - - let data = search.results[0] ? await search.results[0].data() : "None"; - document.querySelector('[data-result]').innerText = `${search.results.length} — ${data.url}`; - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "1 — /en/" - - Scenario: LEGACY Pagefind searches for Portuguese with Portuguese stemming - Given I have a "public/index.html" file with the content: - """ - - - - Document - - -

Nothing

- - - """ - When I run my program - Then I should see "Running Pagefind" in stdout - Then I should see "pre-1.0 compatibility mode" in stderr - Then I should see the file "public/_pagefind/pagefind.js" - Then I should see the file "public/_pagefind/wasm.unknown.pagefind" - Then I should see the file "public/_pagefind/wasm.pt-br.pagefind" - Then I should see "pt-br" in "public/_pagefind/pagefind-entry.json" - When I serve the "public" directory - When I load "/" - When I evaluate: - """ - async function() { - let pagefind = await import("/_pagefind/pagefind.js"); - - let search = await pagefind.search("quilométricos"); - - let data = search.results[0] ? await search.results[0].data() : "None"; - document.querySelector('[data-result]').innerText = `${search.results.length} — ${data.url}`; - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "1 — /pt-br/" - - Scenario: LEGACY Pagefind keeps dialects separate - Given I have a "public/pt-pt/index.html" file with the content: - """ - - - - Document - - -

I am a different Portuguese document (trust me — quilométricas — see?)

- - - """ - Given I have a "public/index.html" file with the content: - """ - - - - Document - - -

Nothing

- - - """ - When I run my program - Then I should see "Running Pagefind" in stdout - Then I should see "pre-1.0 compatibility mode" in stderr - Then I should see the file "public/_pagefind/pagefind.js" - Then I should see the file "public/_pagefind/wasm.unknown.pagefind" - Then I should see the file "public/_pagefind/wasm.pt-pt.pagefind" - Then I should see the file "public/_pagefind/wasm.pt-br.pagefind" - Then I should see "pt-pt" in "public/_pagefind/pagefind-entry.json" - Then I should see "pt-br" in "public/_pagefind/pagefind-entry.json" - When I serve the "public" directory - When I load "/" - When I evaluate: - """ - async function() { - let pagefind = await import("/_pagefind/pagefind.js"); - - let search = await pagefind.search("quilométricos"); - - let data = search.results[0] ? await search.results[0].data() : "None"; - document.querySelector('[data-result]').innerText = `${search.results.length} — ${data.url}`; - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "1 — /pt-br/" - - Scenario: LEGACY Pagefind can be configured to lump all languages together - Given I have a "public/index.html" file with the content: - """ - - - - Document - - -

Nothing

- - - """ - When I run my program with the flags: - | --force-language "en" | - Then I should see "Running Pagefind" in stdout - Then I should see "pre-1.0 compatibility mode" in stderr - Then I should see the file "public/_pagefind/pagefind.js" - Then I should see the file "public/_pagefind/wasm.unknown.pagefind" - Then I should see the file "public/_pagefind/wasm.en.pagefind" - Then I should not see the file "public/_pagefind/wasm.pt-br.pagefind" - When I serve the "public" directory - When I load "/" - When I evaluate: - """ - async function() { - let pagefind = await import("/_pagefind/pagefind.js"); - - let search = await pagefind.search("documenting"); - - let data = await Promise.all(search.results.map(result => result.data())); - document.querySelector('[data-result]').innerText = `${search.results.length} — ${data.map(d => d.url).sort().join(', ')}`; - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "2 — /en/, /pt-br/" - - Scenario: LEGACY Pagefind merges omitted languages into the primary language - Given I have a "public/index.html" file with the content: - """ - - - - Document - - -

Nothing

- - - """ - Given I have a "public/mystery/index.html" file with the content: - """ - - - - Document - - -

I am a mystery document

- - - """ - When I run my program - Then I should see "Running Pagefind" in stdout - Then I should see "pre-1.0 compatibility mode" in stderr - Then I should see the file "public/_pagefind/pagefind.js" - Then I should see the file "public/_pagefind/wasm.unknown.pagefind" - Then I should not see "unknown" in "public/_pagefind/pagefind-entry.json" - When I serve the "public" directory - When I load "/" - When I evaluate: - """ - async function() { - let pagefind = await import("/_pagefind/pagefind.js"); - - let search = await pagefind.search("documenting"); - - let data = await Promise.all(search.results.map(result => result.data())); - document.querySelector('[data-result]').innerText = `${data.map(d => d.url).sort().join(', ')}`; - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "/en/, /mystery/" - - Scenario: LEGACY Pagefind searches for unknown languages with no stemming - Given I have a "public/index.html" file with the content: - """ - - - - Document - - -

Nothing

- - - """ - Given I have a "public/mystery/index.html" file with the content: - """ - - - - Document - - -

I am a documentation

- - - """ - When I run my program - Then I should see "Running Pagefind" in stdout - Then I should see "pre-1.0 compatibility mode" in stderr - Then I should see the file "public/_pagefind/pagefind.js" - Then I should see the file "public/_pagefind/wasm.unknown.pagefind" - Then I should not see the file "public/_pagefind/wasm.my_cool_language.pagefind" - Then I should see "my_cool_language" in "public/_pagefind/pagefind-entry.json" - When I serve the "public" directory - When I load "/" - When I evaluate: - """ - async function() { - let pagefind = await import("/_pagefind/pagefind.js"); - - let search = await pagefind.search("documentation"); - let stem_search = await pagefind.search("documenting"); - - let data = search.results[0] ? await search.results[0].data() : "None"; - document.querySelector('[data-result]').innerText = `${search.results.length} — ${data.url} — ${stem_search.results.length}`; - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "1 — /mystery/ — 0" \ No newline at end of file diff --git a/pagefind/features/frozen-pre-1.0/multisite/multisite_base.feature b/pagefind/features/frozen-pre-1.0/multisite/multisite_base.feature deleted file mode 100644 index ea79ff03..00000000 --- a/pagefind/features/frozen-pre-1.0/multisite/multisite_base.feature +++ /dev/null @@ -1,87 +0,0 @@ -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -# This file represents a backwards-compatible setup as it existed before 1.0 # -# These tests should remain as a permanent regresison check for older sites # -# It is very unlikely that the tests in this file should be touched # -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # - -Feature: Multisite Search - - Background: - Given I have a "root/index.html" file with the body: - """ -

Nothing

- """ - Given I have a "root/website_a/hello/index.html" file with the body: - """ - -

web web world PAGEFIND_ROOT_SELECTOR

- """ - Given I have a "root/website_b/lorem/index.html" file with the body: - """ - -

web ipsum

- """ - - Scenario: LEGACY Pagefind can search across multiple sites - When I run my program with the flags: - | --source root/website_a | - Then I should see "Running Pagefind" in stdout - Then I should see "pre-1.0 compatibility mode" in stderr - Then I should see the file "root/website_a/_pagefind/pagefind.js" - When I run my program with the flags: - | --source root/website_b | - Then I should see "Running Pagefind" in stdout - Then I should see "pre-1.0 compatibility mode" in stderr - Then I should see the file "root/website_b/_pagefind/pagefind.js" - When I serve the "root" directory - When I load "/" - When I evaluate: - """ - async function() { - let pagefind = await import("/website_a/_pagefind/pagefind.js"); - await pagefind.mergeIndex("/website_b/_pagefind/"); - - let search = await pagefind.search("web"); - - let pages = await Promise.all(search.results.map(r => r.data())); - document.querySelector('[data-result]').innerText = pages.map(p => p.url).join(", "); - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "/website_a/hello/, /website_b/lorem/" - - Scenario: LEGACY Pagefind UI can search across multiple sites - Given I have a "root/index.html" file with the body: - """ - - - """ - When I run my program with the flags: - | --source root/website_a | - Then I should see "Running Pagefind" in stdout - Then I should see "pre-1.0 compatibility mode" in stderr - Then I should see the file "root/website_a/_pagefind/pagefind.js" - When I run my program with the flags: - | --source root/website_b | - Then I should see "Running Pagefind" in stdout - Then I should see "pre-1.0 compatibility mode" in stderr - Then I should see the file "root/website_b/_pagefind/pagefind.js" - When I serve the "root" directory - When I load "/" - Then There should be no logs - When I evaluate: - """ - async function() { - let pui = new PagefindUI({ - element: "#search", - mergeIndex: [{ - bundlePath: "/website_b/_pagefind/" - }] - }); - pui.triggerSearch("web"); - await new Promise(r => setTimeout(r, 3500)); // TODO: await el in humane - } - """ - Then There should be no logs - Then The selector ".pagefind-ui__result:nth-of-type(1) .pagefind-ui__result-link" should contain "web web world PAGEFIND_ROOT_SELECTOR" - Then The selector ".pagefind-ui__result:nth-of-type(2) .pagefind-ui__result-link" should contain "web ipsum" diff --git a/pagefind/features/frozen-pre-1.0/sanity.feature b/pagefind/features/frozen-pre-1.0/sanity.feature deleted file mode 100644 index 7b0eee7d..00000000 --- a/pagefind/features/frozen-pre-1.0/sanity.feature +++ /dev/null @@ -1,28 +0,0 @@ -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -# This file represents a backwards-compatible setup as it existed before 1.0 # -# These tests should remain as a permanent regresison check for older sites # -# It is very unlikely that the tests in this file should be touched # -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # - -Feature: Sanity Tests - - Scenario: LEGACY CLI tests are working - Given I have a "public/index.html" file with the body: - """ - -

Nothing

- """ - When I run my program with the flags: - | --source public | - Then I should see "Running Pagefind" in stdout - Then I should see "pre-1.0 compatibility mode" in stderr - Then I should see "The `source` option is deprecated" in stderr - - Scenario: LEGACY Web tests are working - Given I have a "public/index.html" file with the body: - """ -

Hello!

- """ - When I serve the "public" directory - When I load "/" - Then The selector "h1" should contain "Hello!" diff --git a/pagefind/features/frozen-pre-1.0/search_options.feature b/pagefind/features/frozen-pre-1.0/search_options.feature deleted file mode 100644 index d9711253..00000000 --- a/pagefind/features/frozen-pre-1.0/search_options.feature +++ /dev/null @@ -1,105 +0,0 @@ -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -# This file represents a backwards-compatible setup as it existed before 1.0 # -# These tests should remain as a permanent regresison check for older sites # -# It is very unlikely that the tests in this file should be touched # -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # - -Feature: Search Options - - Background: - Given I have the environment variables: - | PAGEFIND_SOURCE | public | - - Scenario: LEGACY Base URL can be configured - Given I have a "public/index.html" file with the body: - """ - -

Nothing

- """ - Given I have a "public/cat/index.html" file with the body: - """ -

world

- """ - When I run my program - Then I should see "Running Pagefind" in stdout - Then I should see "pre-1.0 compatibility mode" in stderr - 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({ - baseUrl: "/docs/" - }); - - 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 "/docs/cat/" - - Scenario: LEGACY Base URL auto-detects the default directory being moved - Given I have a "public/index.html" file with the body: - """ - -

Nothing

- """ - Given I have a "public/cat/index.html" file with the body: - """ -

world

- """ - When I run my program with the flags: - | --bundle-dir blog/_pagefind | - Then I should see "Running Pagefind" in stdout - Then I should see the file "public/blog/_pagefind/pagefind.js" - When I serve the "public" directory - When I load "/" - When I evaluate: - """ - async function() { - let pagefind = await import("/blog/_pagefind/pagefind.js"); - - 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 "/blog/cat/" - - Scenario: LEGACY Keep Index URL can be configured - Given I have a "public/index.html" file with the body: - """ - -

Nothing

- """ - Given I have a "public/cat/index.html" file with the body: - """ -

world

- """ - When I run my program with the flags: - | --bundle-dir blog/_pagefind | - | --keep-index-url | - Then I should see "Running Pagefind" in stdout - Then I should see the file "public/blog/_pagefind/pagefind.js" - When I serve the "public" directory - When I load "/" - When I evaluate: - """ - async function() { - let pagefind = await import("/blog/_pagefind/pagefind.js"); - - 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 "/blog/cat/index.html" diff --git a/pagefind/features/frozen-pre-1.0/ui/ui_base.feature b/pagefind/features/frozen-pre-1.0/ui/ui_base.feature deleted file mode 100644 index 7c1e4339..00000000 --- a/pagefind/features/frozen-pre-1.0/ui/ui_base.feature +++ /dev/null @@ -1,54 +0,0 @@ -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -# This file represents a backwards-compatible setup as it existed before 1.0 # -# These tests should remain as a permanent regresison check for older sites # -# It is very unlikely that the tests in this file should be touched # -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # - -Feature: Base UI Tests - Background: - Given I have the environment variables: - | PAGEFIND_SOURCE | public | - Given I have a "public/index.html" file with the body: - """ - - - - - """ - - Scenario: LEGACY Pagefind UI loads - Given I have a "public/cat/index.html" file with the body: - """ -

world

- """ - When I run my program - Then I should see "Running Pagefind" in stdout - Then I should see "pre-1.0 compatibility mode" in stderr - Then I should see the file "public/_pagefind/pagefind.js" - When I serve the "public" directory - When I load "/" - Then There should be no logs - Then The selector ".pagefind-ui" should exist - - Scenario: LEGACY Pagefind UI searches - Given I have a "public/cat/index.html" file with the body: - """ -

world

- """ - When I run my program - Then I should see "Running Pagefind" in stdout - Then I should see "pre-1.0 compatibility mode" in stderr - Then I should see the file "public/_pagefind/pagefind.js" - When I serve the "public" directory - When I load "/" - When I evaluate: - """ - async function() { - window.pui.triggerSearch("world"); - await new Promise(r => setTimeout(r, 1500)); // TODO: await el in humane - } - """ - Then There should be no logs - Then The selector ".pagefind-ui__result-link" should contain "world" diff --git a/pagefind/features/highlighting/highlighting_results.feature b/pagefind/features/highlighting/highlighting_results.feature deleted file mode 100644 index fdd63ffb..00000000 --- a/pagefind/features/highlighting/highlighting_results.feature +++ /dev/null @@ -1,138 +0,0 @@ -Feature: Highlighting Result Tests - - Background: - Given I have the environment variables: - | PAGEFIND_SITE | public | - Given I have a "public/words/index.html" file with the body: - """ -

Is this highlighted? It should be!

-

This should not be highlighted

-

This should not be highlighted

- - """ - Given I have a "public/single-body/index.html" file with the body: - """ -
-

This should be highlighted

-

This should not be highlighted

-
-

This should not be highlighted

- - """ - Given I have a "public/multiple-bodies/index.html" file with the body: - """ -
-

This should be highlighted

-

This should not be highlighted

-
-

This should not be highlighted

-
-

This should be highlighted

-

This should not be highlighted

-
- - """ - Given I have a "public/options/index.html" file with the body: - """ -
-

This should be highlighted

-

This should not be highlighted

-
-

This should not be highlighted

-
-

This should be highlighted

-

This should not be highlighted

-

This should not be highlighted

-
- - """ - When I run my program - Then I should see "Running Pagefind" in stdout - When I serve the "public" directory - - Scenario: Highlight script is loaded - When I load "/words/" - When I evaluate: - """ - async function() { await new Promise(r => setTimeout(r, 200)); } - """ - Then I should see the file "public/pagefind/pagefind-highlight.js" - Then There should be no logs - - Scenario: Highlight script marks correctly - When I load "/words/?pagefind-highlight=this" - When I evaluate: - """ - async function() { await new Promise(r => setTimeout(r, 200)); } - """ - Then There should be no logs - Then The selector "#has-highlight mark" should contain "this" - Then The selector "#has-highlight mark.pagefind-highlight" should contain "this" - Then The selector "p[data-pagefind-ignore]:not(:has(span))" should contain "This should not be highlighted" - Then The selector "p[data-pagefind-ignore]:has(span)" should contain "This should not be highlighted" - When I load "/words/?pagefind-highlight=this&pagefind-highlight=should" - Then There should be no logs - Then The selector "#has-highlight mark:first-of-type" should contain "this" - Then The selector "#has-highlight mark:nth-of-type(2)" should contain "should" - When I load "/words/?pagefind-highlight=is+this" - Then There should be no logs - Then The selector "#has-highlight mark" should contain "Is this" - Then The selector "p[data-pagefind-ignore]" should contain "This should not be highlighted" - When I load "/words/?pagefind-highlight=highlighted%3F" - Then There should be no logs - Then The selector "#has-highlight mark" should contain "highlighted?" - When I load "/words/?pagefind-highlight=this+highlighted%3F" - Then There should be no logs - Then The selector "#has-highlight mark:first-of-type" should contain "this highlighted?" - - Scenario: Highlight script stays within pagefind-body - When I load "/single-body/?pagefind-highlight=this" - When I evaluate: - """ - async function() { await new Promise(r => setTimeout(r, 200)); } - """ - Then There should be no logs - Then The selector "#has-highlight mark" should contain "This" - Then The selector "p[data-pagefind-ignore]" should contain "This should not be highlighted" - Then The selector "#no-highlight" should contain "This should not be highlighted" - When I load "/multiple-bodies/?pagefind-highlight=this" - Then There should be no logs - Then The selector "#has-highlight mark" should contain "This" - Then The selector "p[data-pagefind-ignore]" should contain "This should not be highlighted" - Then The selector "#no-highlight" should contain "This should not be highlighted" - - Scenario: Highlight script options work - When I load "/options/?custom-name=this" - When I evaluate: - """ - async function() { await new Promise(r => setTimeout(r, 200)); } - """ - Then There should be no logs - Then The selector "#has-highlight mark" should contain "This" - Then The selector "#has-highlight mark.custom-class" should contain "This" - Then The selector "p[data-pagefind-ignore]" should contain "This should not be highlighted" - Then The selector "p.ignore" should contain "This should not be highlighted" - Then The selector "#no-highlight" should contain "This should not be highlighted" - diff --git a/pagefind/features/highlighting/highlighting_search.feature b/pagefind/features/highlighting/highlighting_search.feature deleted file mode 100644 index 1dd57334..00000000 --- a/pagefind/features/highlighting/highlighting_search.feature +++ /dev/null @@ -1,81 +0,0 @@ -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: - """ -

Nothing

- """ - Given I have a "public/a/index.html" file with the body: - """ -

Hello World

- """ - Given I have a "public/b/index.html" file with the body: - """ -

Second

-

Second Page

- """ - - 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" \ No newline at end of file diff --git a/pagefind/features/index_chunking.feature b/pagefind/features/index_chunking.feature deleted file mode 100644 index bda62cb4..00000000 --- a/pagefind/features/index_chunking.feature +++ /dev/null @@ -1,38 +0,0 @@ -Feature: Index Chunking - - Background: - Given I have the environment variables: - | PAGEFIND_SITE | public | - Given I have a "public/index.html" file with the body: - """ - - """ - - # Scenario: Browser only loads chunks needed to search for the target word - # Scenario: Chunk size is configurable - - Scenario: Searches that don't match a chunk will load the closest chunk - Given I have a "public/one/index.html" file with the body: - """ -

Hello World

- """ - 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 search = await pagefind.search("h"); - - let results = await Promise.all(search.results.map(r => r.data())); - document.querySelector('[data-result]').innerText = results.map(r => r.url).join(', '); - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "/one/" diff --git a/pagefind/features/indexing.feature b/pagefind/features/indexing.feature deleted file mode 100644 index 3b85180c..00000000 --- a/pagefind/features/indexing.feature +++ /dev/null @@ -1,86 +0,0 @@ -Feature: Indexing - - Background: - Given I have the environment variables: - | PAGEFIND_SITE | public | - - Scenario: Indexing can be limited to a given element - Given I have a "public/index.html" file with the body: - """ -

Nothing

-

Nothing

- """ - Given I have a "public/cat/index.html" file with the body: - """ -

Outer Content

-
-

Hello World, from Pagefind

-

Huzzah!

-
-

goodbye content

-

Little extra body

-
-

More unindexed content

-
-

Body number 3

-
-

And yet more unindexed content

-
- """ - # The above data-pagefind-body existing on a page should - # exclude all pages that do not include it. - Given I have a "public/dog/index.html" file with the body: - """ -

No selector

-

goodbye content

- """ - 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.results[0].data(); - document.querySelector('[data-search-one]').innerText = searchonedata.content; - - let searchtwo = await pagefind.search("goodbye"); - document.querySelector('[data-search-two]').innerText = `${searchtwo.results.length} result(s)`; - } - """ - Then There should be no logs - Then The selector "[data-search-one]" should contain "Hello World, from Pagefind. Huzzah! Little extra body. Body number 3." - Then The selector "[data-search-two]" should contain "0 result(s)" - - Scenario: HTML attributes can be indexed - Given I have a "public/index.html" file with the body: - """ -

Nothing

- """ - Given I have a "public/cat/index.html" file with the body: - """ -

Page Title

- Alternate Text -

Hello World, from Pagefind

- """ - 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 search = await pagefind.search("Alternate"); - let searchdata = await search.results[0]?.data(); - document.querySelector('[data-search]').innerText = searchdata?.content; - } - """ - Then There should be no logs - Then The selector "[data-search]" should contain "Page Title. Alternate Text. Hello World, from Pagefind." - - diff --git a/pagefind/features/input_quirks.feature b/pagefind/features/input_quirks.feature deleted file mode 100644 index 58bbbc15..00000000 --- a/pagefind/features/input_quirks.feature +++ /dev/null @@ -1,33 +0,0 @@ -Feature: Input Quirk Tests - Background: - Given I have the environment variables: - | PAGEFIND_SITE | public | - | PAGEFIND_verbose | true | - Given I have a "public/index.html" file with the body: - """ -

Nothing

- """ - - Scenario: Index gzipped input files - Given I have a gzipped "public/cat/index.html" file with the body: - """ -

Hello World

- """ - 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 search = await pagefind.search("world"); - - let data = await search.results[0].data(); - document.querySelector('[data-title]').innerText = data.meta.title; - } - """ - Then There should be no logs - Then The selector "[data-title]" should contain "Hello World" diff --git a/pagefind/features/metadata.feature b/pagefind/features/metadata.feature deleted file mode 100644 index 7c0cb265..00000000 --- a/pagefind/features/metadata.feature +++ /dev/null @@ -1,207 +0,0 @@ -Feature: Metadata - Background: - Given I have the environment variables: - | PAGEFIND_SITE | public | - Given I have a "public/index.html" file with the content: - """ - - - -

Nothing

-

Nothing

- - - """ - # Covering all filter and metadata syntaxes - Given I have a "public/cat/index.html" file with the content: - """ - - - - - - -

- Cat Post. -

- cats - cat picture -

A post about the 'felines'

-

This post has some gnarly things to test the fragment formatting.

- cat footer picture - - - """ - # Covering metadata hierarchy - Given I have a "public/dog/index.html" file with the content: - """ - - - - Website | Dogs - - -

Dog Post.

- dog - generic - - - """ - # Covering fallback titles - Given I have a "public/kea/index.html" file with the content: - """ - - - Website | Kea - - -

NZ Kea Post.

- - - """ - Given I have a "public/kaka/index.html" file with the content: - """ - - - Website | Kaka - - -

-

NZ Kaka Post.

- - - """ - 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 "/" - - Scenario: Search results return generic information about the page - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let search = await pagefind.search("cat"); - - let data = await search.results[0].data(); - document.querySelector('[data-result]').innerText = data.meta.title; - document.querySelector('[data-result-two]').innerText = `${data.meta.image} | ${data.meta.image_alt}`; - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "Cat Post." - Then The selector "[data-result-two]" should contain "/cat.png | cat picture" - - Scenario: Search results return nicely formatted content - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let search = await pagefind.search("feline"); - - let data = await search.results[0].data(); - document.querySelector('[data-result]').innerText = data.content; - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "Cat Post. A post about the 'felines'. This post has some gnarly things to test the fragment formatting." - - Scenario: Search results return highlighted search excerpt - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let search = await pagefind.search("feline"); - - let data = await search.results[0].data(); - document.querySelector('[data-result]').innerText = data.excerpt; - } - """ - Then There should be no logs - # NB: The HTML encoding below is a test artifact - Then The selector "[data-result]" should contain "Cat Post. A post about the <mark>'felines'.</mark> This post has some gnarly things to test the fragment formatting." - - Scenario: Search results return tagged filters - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let search = await pagefind.search("cat"); - - let data = await search.results[0].data(); - document.querySelector('[data-result]').innerText = Object.entries(data.filters).map(([f, v]) => `${f}: ${v}`).sort().join(', '); - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "animal: cats, title: Cat Post." - - Scenario: Search results return tagged metadata - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let search = await pagefind.search("cat"); - - let data = await search.results[0].data(); - document.querySelector('[data-result]').innerText = data.meta["social-image"] + " — " + data.meta.adjective; - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "/kitty.jpg — gnarly" - - Scenario: Search results return complex metadata - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let search = await pagefind.search("cat"); - - let data = await search.results[0].data(); - document.querySelector('[data-result]').innerText = data.meta.footer + " — " + data.meta.footer_alt; - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "/cat-footer.png — cat footer picture" - - Scenario: Default metadata can be defined - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let search = await pagefind.search("dog"); - - let data = await search.results[0].data(); - document.querySelector('[data-result]').innerText = [ - data.meta.title, - data.meta.image, - data.meta.animal, - data.meta.vegetable, - data.meta.mineral, - ].join(' | '); - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "Dog Post. | /puppy.jpg | dog | generic | generic" - - Scenario: Title metadata falls back to the title element - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let search = await pagefind.search("NZ"); - - let data = await Promise.all(search.results.map(result => result.data())); - document.querySelector('[data-result]').innerText = data.map(d => d.meta.title).sort().join(', '); - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "Website | Kaka, Website | Kea" diff --git a/pagefind/features/modular_ui/modular_ui_base.feature b/pagefind/features/modular_ui/modular_ui_base.feature deleted file mode 100644 index 5768a3c6..00000000 --- a/pagefind/features/modular_ui/modular_ui_base.feature +++ /dev/null @@ -1,59 +0,0 @@ -Feature: Base Modular UI Tests - Background: - Given I have the environment variables: - | PAGEFIND_SITE | public | - Given I have a "public/index.html" file with the body: - """ - -
-
- - - - """ - - Scenario: Pagefind Modular UI loads - Given I have a "public/cat/index.html" file with the body: - """ -

world

- """ - 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 "/" - Then There should be no logs - Then The selector "#search input" should exist - - Scenario: Pagefind Modular UI searches - Given I have a "public/cat/index.html" file with the body: - """ -

world

- """ - 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 e = new Event('input', {bubbles:true, cancelable:true}); - document.querySelector("#search input").value = "world"; - document.querySelector("#search input").dispatchEvent(e); - await new Promise(r => setTimeout(r, 1500)); // TODO: await el in humane - } - """ - Then There should be no logs - Then The selector ".pagefind-modular-list-link" should contain "world" diff --git a/pagefind/features/multilingual.feature b/pagefind/features/multilingual.feature deleted file mode 100644 index 1a7cea4f..00000000 --- a/pagefind/features/multilingual.feature +++ /dev/null @@ -1,327 +0,0 @@ -Feature: Multilingual - Background: - Given I have the environment variables: - | PAGEFIND_SITE | public | - Given I have a "public/en/index.html" file with the content: - """ - - - - Document - - -

I am some English documentation

- - - """ - Given I have a "public/pt-br/index.html" file with the content: - """ - - - - Document - - -

I am a Portuguese document (trust me — quilométricas — see?)

- - - """ - - Scenario: Pagefind searches for English with English stemming - Given I have a "public/index.html" file with the content: - """ - - - - Document - - -

Nothing

- - - """ - When I run my program - Then I should see "Running Pagefind" in stdout - Then I should see the file "public/pagefind/pagefind.js" - Then I should see the file "public/pagefind/wasm.unknown.pagefind" - Then I should see the file "public/pagefind/wasm.en.pagefind" - Then I should see "en" in "public/pagefind/pagefind-entry.json" - When I serve the "public" directory - When I load "/" - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let search = await pagefind.search("documenting"); - - let data = search.results[0] ? await search.results[0].data() : "None"; - document.querySelector('[data-result]').innerText = `${search.results.length} — ${data.url}`; - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "1 — /en/" - - Scenario: Pagefind searches for Portuguese with Portuguese stemming - Given I have a "public/index.html" file with the content: - """ - - - - Document - - -

Nothing

- - - """ - When I run my program - Then I should see "Running Pagefind" in stdout - Then I should see the file "public/pagefind/pagefind.js" - Then I should see the file "public/pagefind/wasm.unknown.pagefind" - Then I should see the file "public/pagefind/wasm.pt-br.pagefind" - Then I should see "pt-br" in "public/pagefind/pagefind-entry.json" - When I serve the "public" directory - When I load "/" - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let search = await pagefind.search("quilométricos"); - - let data = search.results[0] ? await search.results[0].data() : "None"; - document.querySelector('[data-result]').innerText = `${search.results.length} — ${data.url}`; - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "1 — /pt-br/" - - Scenario: Pagefind keeps dialects separate - Given I have a "public/pt-pt/index.html" file with the content: - """ - - - - Document - - -

I am a different Portuguese document (trust me — quilométricas — see?)

- - - """ - Given I have a "public/index.html" file with the content: - """ - - - - Document - - -

Nothing

- - - """ - When I run my program - Then I should see "Running Pagefind" in stdout - Then I should see the file "public/pagefind/pagefind.js" - Then I should see the file "public/pagefind/wasm.unknown.pagefind" - Then I should see the file "public/pagefind/wasm.pt-pt.pagefind" - Then I should see the file "public/pagefind/wasm.pt-br.pagefind" - Then I should see "pt-pt" in "public/pagefind/pagefind-entry.json" - Then I should see "pt-br" in "public/pagefind/pagefind-entry.json" - When I serve the "public" directory - When I load "/" - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let search = await pagefind.search("quilométricos"); - - let data = search.results[0] ? await search.results[0].data() : "None"; - document.querySelector('[data-result]').innerText = `${search.results.length} — ${data.url}`; - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "1 — /pt-br/" - - Scenario: Pagefind can be configured to lump all languages together - Given I have a "public/index.html" file with the content: - """ - - - - Document - - -

Nothing

- - - """ - When I run my program with the flags: - | --force-language "en" | - Then I should see "Running Pagefind" in stdout - Then I should see the file "public/pagefind/pagefind.js" - Then I should see the file "public/pagefind/wasm.unknown.pagefind" - Then I should see the file "public/pagefind/wasm.en.pagefind" - Then I should not see the file "public/pagefind/wasm.pt-br.pagefind" - When I serve the "public" directory - When I load "/" - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let search = await pagefind.search("documenting"); - - let data = await Promise.all(search.results.map(result => result.data())); - document.querySelector('[data-result]').innerText = `${search.results.length} — ${data.map(d => d.url).sort().join(', ')}`; - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "2 — /en/, /pt-br/" - - Scenario: Pagefind merges omitted languages into the primary language - Given I have a "public/index.html" file with the content: - """ - - - - Document - - -

Nothing

- - - """ - Given I have a "public/mystery/index.html" file with the content: - """ - - - - Document - - -

I am a mystery document

- - - """ - When I run my program - Then I should see "Running Pagefind" in stdout - Then I should see the file "public/pagefind/pagefind.js" - Then I should see the file "public/pagefind/wasm.unknown.pagefind" - Then I should not see "unknown" in "public/pagefind/pagefind-entry.json" - When I serve the "public" directory - When I load "/" - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let search = await pagefind.search("documenting"); - - let data = await Promise.all(search.results.map(result => result.data())); - document.querySelector('[data-result]').innerText = `${data.map(d => d.url).sort().join(', ')}`; - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "/en/, /mystery/" - - Scenario: Pagefind searches for unknown languages with no stemming - Given I have a "public/index.html" file with the content: - """ - - - - Document - - -

Nothing

- - - """ - Given I have a "public/mystery/index.html" file with the content: - """ - - - - Document - - -

I am a documentation

- - - """ - When I run my program - Then I should see "Running Pagefind" in stdout - Then I should see the file "public/pagefind/pagefind.js" - Then I should see the file "public/pagefind/wasm.unknown.pagefind" - Then I should not see the file "public/pagefind/wasm.my_cool_language.pagefind" - Then I should see "my_cool_language" in "public/pagefind/pagefind-entry.json" - When I serve the "public" directory - When I load "/" - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let search = await pagefind.search("documentation"); - let stem_search = await pagefind.search("documenting"); - - let data = search.results[0] ? await search.results[0].data() : "None"; - document.querySelector('[data-result]').innerText = `${search.results.length} — ${data.url} — ${stem_search.results.length}`; - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "1 — /mystery/ — 0" - - Scenario: Pagefind can be destroyed and re-initialized - Given I have a "public/index.html" file with the content: - """ - - - - Generic Page - - -

Nothing

-

Nothing

- - - """ - When I run my program - Then I should see "Running Pagefind" in stdout - Then I should see the file "public/pagefind/pagefind.js" - Then I should see the file "public/pagefind/wasm.unknown.pagefind" - Then I should see the file "public/pagefind/wasm.en.pagefind" - Then I should see the file "public/pagefind/wasm.pt-br.pagefind" - Then I should see "en" in "public/pagefind/pagefind-entry.json" - Then I should see "pt-br" in "public/pagefind/pagefind-entry.json" - When I serve the "public" directory - When I load "/" - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - await pagefind.init(); - let en_search = await pagefind.search("documenting"); - - let en_data = en_search.results[0] ? await en_search.results[0].data() : "None"; - document.querySelector('[data-result-a]').innerText = `${en_search.results.length} — ${en_data.url}`; - - await pagefind.destroy(); - - document.querySelector('html').setAttribute("lang", "pt-br"); - - await pagefind.init(); - let pt_search = await pagefind.search("quilométricos"); - - let pt_data = pt_search.results[0] ? await pt_search.results[0].data() : "None"; - document.querySelector('[data-result-b]').innerText = `${pt_search.results.length} — ${pt_data.url}`; - } - """ - Then There should be no logs - Then The selector "[data-result-a]" should contain "1 — /en/" - Then The selector "[data-result-b]" should contain "1 — /pt-br/" diff --git a/pagefind/features/multisite/multisite_base.feature b/pagefind/features/multisite/multisite_base.feature deleted file mode 100644 index 16336f76..00000000 --- a/pagefind/features/multisite/multisite_base.feature +++ /dev/null @@ -1,151 +0,0 @@ -Feature: Multisite Search - - Background: - Given I have a "root/index.html" file with the body: - """ -

Nothing

- """ - Given I have a "root/website_a/hello/index.html" file with the body: - """ -

web web world web PAGEFIND_ROOT_SELECTOR

- """ - Given I have a "root/website_b/lorem/index.html" file with the body: - """ -

web ipsum

- """ - - Scenario: Pagefind can search across multiple basic sites - When I run my program with the flags: - | --site root/website_a | - Then I should see "Running Pagefind" in stdout - Then I should see the file "root/website_a/pagefind/pagefind.js" - When I run my program with the flags: - | --site root/website_b | - Then I should see "Running Pagefind" in stdout - Then I should see the file "root/website_b/pagefind/pagefind.js" - When I serve the "root" directory - When I load "/" - When I evaluate: - """ - async function() { - let pagefind = await import("/website_a/pagefind/pagefind.js"); - await pagefind.mergeIndex("/website_b/pagefind/"); - - let search = await pagefind.search("web"); - - let pages = await Promise.all(search.results.map(r => r.data())); - document.querySelector('[data-result]').innerText = pages.map(p => p.url).join(", "); - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "/website_a/hello/, /website_b/lorem/" - - Scenario: Pagefind UI can search across multiple sites - Given I have a "root/index.html" file with the body: - """ - - - """ - When I run my program with the flags: - | --site root/website_a | - Then I should see "Running Pagefind" in stdout - Then I should see the file "root/website_a/pagefind/pagefind.js" - When I run my program with the flags: - | --site root/website_b | - Then I should see "Running Pagefind" in stdout - Then I should see the file "root/website_b/pagefind/pagefind.js" - When I serve the "root" directory - When I load "/" - Then There should be no logs - When I evaluate: - """ - async function() { - let pui = new PagefindUI({ - element: "#search", - mergeIndex: [{ - bundlePath: "/website_b/pagefind/" - }] - }); - pui.triggerSearch("web"); - await new Promise(r => setTimeout(r, 3500)); // TODO: await el in humane - } - """ - Then There should be no logs - Then The selector ".pagefind-ui__result:nth-of-type(1) .pagefind-ui__result-link" should contain "web web world web PAGEFIND_ROOT_SELECTOR" - Then The selector ".pagefind-ui__result:nth-of-type(2) .pagefind-ui__result-link" should contain "web ipsum" - - # Tests that Pagefind can assemble URLs correctly. - # Remove the @skip tag to run this test (since it makes an external request) - @skip - Scenario: Pagefind can search across discrete domains - When I run my program with the flags: - | --site root/website_a | - Then I should see "Running Pagefind" in stdout - Then I should see the file "root/website_a/pagefind/pagefind.js" - When I serve the "root" directory - When I load "/" - When I evaluate: - """ - async function() { - let pagefind = await import("/website_a/pagefind/pagefind.js"); - await pagefind.mergeIndex("https://pagefind.app/pagefind/"); - - let search = await pagefind.search("PAGEFIND_ROOT_SELECTOR"); - - let pages = await Promise.all(search.results.map(r => r.data())); - document.querySelector('[data-result]').innerText = pages.map(p => p.url).sort().join(", "); - } - """ - # There will be a log since the versions do not match - # Then There should be no logs - Then The selector "[data-result]" should contain "/website_a/hello/, https://pagefind.app/docs/config-options/" - - # Tests that Pagefind UI can assemble URLs correctly. - # Remove the @skip tag to run this test (since it makes an external request) - @skip - Scenario: Pagefind UI can search across discrete domains - Given I have a "root/index.html" file with the body: - """ - - - """ - When I run my program with the flags: - | --site root/website_a | - Then I should see "Running Pagefind" in stdout - Then I should see the file "root/website_a/pagefind/pagefind.js" - When I serve the "root" directory - When I load "/" - Then There should be no logs - When I evaluate: - """ - async function() { - let pui = new PagefindUI({ - element: "#search", - mergeIndex: [{ - bundlePath: "https://pagefind.app/pagefind/" - }] - }); - pui.triggerSearch("PAGEFIND_ROOT_SELECTOR"); - - let waiting_since = Date.now(); - while (!document.querySelector(".pagefind-ui__result-link:nth-of-type(2)")) { - await new Promise(r => setTimeout(r, 100)); // TODO: await el in humane - if (Date.now() - waiting_since > 10000) { - break; - } - } - - const links = [...document.querySelectorAll(".pagefind-ui__result-link")].map(l => l.getAttribute('href')).sort(); - const expected = ["/website_a/hello/", "https://pagefind.app/docs/config-options/"]; - if (links.length < expected.length) { - throw new Error(`Expected ${expected.length} links, found ${links.length}`); - } - for (let i = 0; i < links.length; i++) { - if (links[i] !== expected[i]) { - throw new Error(`${links[i]} !== ${expected[i]}`); - } - } - } - """ -# There will be a log since the versions do not match -# Then There should be no logs diff --git a/pagefind/features/multisite/multisite_filters.feature b/pagefind/features/multisite/multisite_filters.feature deleted file mode 100644 index 9096f95d..00000000 --- a/pagefind/features/multisite/multisite_filters.feature +++ /dev/null @@ -1,108 +0,0 @@ -Feature: Multisite Filters - - Background: - Given I have a "root/index.html" file with the body: - """ -

Nothing

- """ - Given I have a "root/website_a/hello/index.html" file with the body: - """ -

web world

- apple - red - """ - Given I have a "root/website_b/lorem/index.html" file with the body: - """ -

web ipsum

- banana - happy - """ - When I run my program with the flags: - | --site root/website_a | - Then I should see "Running Pagefind" in stdout - Then I should see the file "root/website_a/pagefind/pagefind.js" - When I run my program with the flags: - | --site root/website_b | - Then I should see "Running Pagefind" in stdout - Then I should see the file "root/website_b/pagefind/pagefind.js" - When I serve the "root" directory - When I load "/" - - Scenario: Pagefind can search across multiple sites with common filters - When I evaluate: - """ - async function() { - let pagefind = await import("/website_a/pagefind/pagefind.js"); - await pagefind.mergeIndex("/website_b/pagefind/"); - - let search = await pagefind.search("web", { - filters: { - fruit: "apple" - } - }); - - let pages = await Promise.all(search.results.map(r => r.data())); - document.querySelector('[data-result]').innerText = pages.map(p => p.url).join(", "); - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "/website_a/hello/" - - Scenario: Pagefind can search across multiple sites with unique filters - When I evaluate: - """ - async function() { - let pagefind = await import("/website_a/pagefind/pagefind.js"); - await pagefind.mergeIndex("/website_b/pagefind/"); - - let search = await pagefind.search("web", { - filters: { - emote: "happy" - } - }); - - let pages = await Promise.all(search.results.map(r => r.data())); - document.querySelector('[data-result]').innerText = pages.map(p => p.url).join(", "); - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "/website_b/lorem/" - - Scenario: Pagefind can search across multiple sites with synthetic filters - When I evaluate: - """ - async function() { - let pagefind = await import("/website_a/pagefind/pagefind.js"); - await pagefind.options({ - mergeFilter: { - site: "A" - } - }); - await pagefind.mergeIndex("/website_b/pagefind/", { - mergeFilter: { - site: ["B", "C"] - } - }); - - let search_a = await pagefind.search("web", { - filters: { - site: "A" - } - }); - let pages_a = await Promise.all(search_a.results.map(r => r.data())); - - let search_b = await pagefind.search("web", { - filters: { - site: "B" - } - }); - let pages_b = await Promise.all(search_b.results.map(r => r.data())); - - document.querySelector('[data-result]').innerText = [ - pages_a.map(p => p.url).join(", "), - pages_b.map(p => p.url).join(", "), - ].join(' — '); - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "/website_a/hello/ — /website_b/lorem/" diff --git a/pagefind/features/multisite/multisite_lang.feature b/pagefind/features/multisite/multisite_lang.feature deleted file mode 100644 index ab4b8630..00000000 --- a/pagefind/features/multisite/multisite_lang.feature +++ /dev/null @@ -1,102 +0,0 @@ -Feature: Multisite Search Languages - - Background: - Given I have a "root/index.html" file with the body: - """ -

Nothing

- """ - Given I have a "root/website_a/en/1/index.html" file with the content: - """ - - - - -

Website site A English

- - - """ - # Make Website B predominantly pt-br - Given I have a "root/website_b/pt/1/index.html" file with the content: - """ - - - - -

Website site B Portuguese

- - - """ - Given I have a "root/website_b/pt/2/index.html" file with the content: - """ - - - - -

Website site B Portuguese

- - - """ - Given I have a "root/website_b/en/1/index.html" file with the content: - """ - - - - -

Website site B English

- - - """ - - Scenario: Pagefind picks the same language across multiple sites - When I run my program with the flags: - | --site root/website_a | - Then I should see "Running Pagefind" in stdout - Then I should see the file "root/website_a/pagefind/pagefind.js" - When I run my program with the flags: - | --site root/website_b | - Then I should see "Running Pagefind" in stdout - Then I should see the file "root/website_b/pagefind/pagefind.js" - When I serve the "root" directory - When I load "/" - When I evaluate: - """ - async function() { - let pagefind = await import("/website_a/pagefind/pagefind.js"); - await pagefind.mergeIndex("/website_b/pagefind/"); - - let search = await pagefind.search("web"); // <-- TODO search for "website" - - let pages = await Promise.all(search.results.map(r => r.data())); - document.querySelector('[data-result]').innerText = pages.map(p => p.url).join(", "); - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "/website_a/en/1/, /website_b/en/1/" - - Scenario: Language of merged indexes can be selected - When I run my program with the flags: - | --site root/website_a | - Then I should see "Running Pagefind" in stdout - Then I should see the file "root/website_a/pagefind/pagefind.js" - When I run my program with the flags: - | --site root/website_b | - Then I should see "Running Pagefind" in stdout - Then I should see the file "root/website_b/pagefind/pagefind.js" - When I serve the "root" directory - When I load "/" - When I evaluate: - """ - async function() { - let pagefind = await import("/website_a/pagefind/pagefind.js"); - await pagefind.mergeIndex("/website_b/pagefind/", { - language: "pt-br" - }); - - let search = await pagefind.search("web"); - - let pages = await Promise.all(search.results.map(r => r.data())); - document.querySelector('[data-result]').innerText = pages.map(p => p.url).sort().join(", "); - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "/website_a/en/1/, /website_b/pt/1/, /website_b/pt/2/" diff --git a/pagefind/features/multisite/multisite_sort.feature b/pagefind/features/multisite/multisite_sort.feature deleted file mode 100644 index 9466baee..00000000 --- a/pagefind/features/multisite/multisite_sort.feature +++ /dev/null @@ -1,81 +0,0 @@ -Feature: Multisite Result Scoring - - Background: - Given I have a "root/index.html" file with the body: - """ -

Nothing

- """ - Given I have a "root/website_a/twowebs/index.html" file with the body: - """ -

my page on the web web

- """ - Given I have a "root/website_a/oneweb/index.html" file with the body: - """ -

my page on the world web

- """ - Given I have a "root/website_a/longdoc/index.html" file with the body: - """ -

Aenean lacinia bibendum nulla sed consectetur. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit.

- """ - Given I have a "root/website_b/threewebs/index.html" file with the body: - """ -

my web web web page

- """ - Given I have a "root/website_b/longdoc/index.html" file with the body: - """ -

Aenean lacinia bibendum nulla sed consectetur. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit.

- """ - - Scenario: Pages are scored correctly across indexes - When I run my program with the flags: - | --site root/website_a | - Then I should see "Running Pagefind" in stdout - Then I should see the file "root/website_a/pagefind/pagefind.js" - When I run my program with the flags: - | --site root/website_b | - Then I should see "Running Pagefind" in stdout - Then I should see the file "root/website_b/pagefind/pagefind.js" - When I serve the "root" directory - When I load "/" - When I evaluate: - """ - async function() { - let pagefind = await import("/website_a/pagefind/pagefind.js"); - await pagefind.mergeIndex("/website_b/pagefind/"); - - let search = await pagefind.search("web"); - - let pages = await Promise.all(search.results.map(r => r.data())); - document.querySelector('[data-result]').innerText = pages.map(p => p.url).join(", "); - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "/website_b/threewebs/, /website_a/twowebs/, /website_a/oneweb/" - - Scenario: Multiple indexes can be weighted separately - When I run my program with the flags: - | --site root/website_a | - Then I should see "Running Pagefind" in stdout - Then I should see the file "root/website_a/pagefind/pagefind.js" - When I run my program with the flags: - | --site root/website_b | - Then I should see "Running Pagefind" in stdout - Then I should see the file "root/website_b/pagefind/pagefind.js" - When I serve the "root" directory - When I load "/" - When I evaluate: - """ - async function() { - let pagefind = await import("/website_b/pagefind/pagefind.js"); - await pagefind.mergeIndex("/website_a/pagefind/", { - indexWeight: 20 - }); - - let search = await pagefind.search("web"); - - let pages = await Promise.all(search.results.map(r => r.data())); - document.querySelector('[data-result]').innerText = pages.map(p => p.url).join(", "); - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "/website_a/twowebs/, /website_a/oneweb/, /website_b/threewebs/" diff --git a/pagefind/features/node_api/node_base.feature b/pagefind/features/node_api/node_base.feature deleted file mode 100644 index 1cb93249..00000000 --- a/pagefind/features/node_api/node_base.feature +++ /dev/null @@ -1,448 +0,0 @@ -Feature: Node API Base Tests - Background: - Given I have a "public/index.html" file with the body: - """ -

Nothing

- """ - Given I have a "public/package.json" file with the content: - """ - { - "name": "test", - "type": "module", - "version": "1.0.0", - "main": "index.js", - "dependencies": { - "pagefind": "file:{{humane_cwd}}/../wrappers/node" - } - } - """ - - @platform-unix - Scenario: Build a synthetic index to disk via the api - Given I have a "public/index.js" file with the content: - """ - import * as pagefind from "pagefind"; - - const run = async () => { - const { index } = await pagefind.createIndex(); - await index.addHTMLFile({sourcePath: "dogs/index.html", content: "

Testing, testing

"}); - await index.writeFiles(); - console.log(`Successfully wrote files`); - } - - run(); - """ - When I run "cd public && npm i && PAGEFIND_BINARY_PATH={{humane_cwd}}/$TEST_BINARY node index.js" - Then I should see "Successfully wrote files" 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 search = await pagefind.search("testing"); - - 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 "/dogs/" - - @platform-unix - Scenario: Build a synthetic index with overridden urls to disk via the api - Given I have a "public/index.js" file with the content: - """ - import * as pagefind from "pagefind"; - - const run = async () => { - const { index } = await pagefind.createIndex(); - await index.addHTMLFile({url: "/my-custom-url/", content: "

Testing, testing

"}); - await index.writeFiles(); - console.log(`Successfully wrote files`); - } - - run(); - """ - When I run "cd public && npm i && PAGEFIND_BINARY_PATH={{humane_cwd}}/$TEST_BINARY node index.js" - Then I should see "Successfully wrote files" 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 search = await pagefind.search("testing"); - - 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 "/my-custom-url/" - - @platform-unix - Scenario: Build a synthetic index to memory via the api - Given I have a "public/index.js" file with the content: - """ - import * as pagefind from "pagefind"; - - const run = async () => { - const { index } = await pagefind.createIndex(); - await index.addHTMLFile({sourcePath: "dogs/index.html", content: "

Testing, testing

"}); - const { files } = await index.getFiles(); - - const jsFile = files.filter(file => file.path.includes("pagefind.js"))[0]; - console.log(jsFile.content.toString()); - - console.log(`JS is at ${jsFile.path}`); - - const fragments = files.filter(file => file.path.includes("fragment")); - console.log(`${fragments.length} fragment(s)`); - } - - run(); - """ - When I run "cd public && npm i && PAGEFIND_BINARY_PATH={{humane_cwd}}/$TEST_BINARY node index.js" - Then I should see "pagefind_version=" in stdout - Then I should see "JS is at pagefind.js" in stdout - Then I should see "1 fragment(s)" in stdout - Then I should not see the file "public/pagefind/pagefind.js" - - @platform-unix - Scenario: Build a true index to disk via the api - Given I have a "public/custom_files/real/index.html" file with the body: - """ -

A testing file that exists on disk

- """ - Given I have a "public/index.js" file with the content: - """ - import * as pagefind from "pagefind"; - - const run = async () => { - const { index } = await pagefind.createIndex(); - await index.addDirectory({path: "custom_files"}); - await index.writeFiles(); - console.log(`Successfully wrote files`); - } - - run(); - """ - When I run "cd public && npm i && PAGEFIND_BINARY_PATH={{humane_cwd}}/$TEST_BINARY node index.js" - Then I should see "Successfully wrote files" 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 search = await pagefind.search("testing"); - - 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 "/real/" - - @platform-unix - Scenario: Build a blended index to memory via the api - Given I have a "public/custom_files/real/index.html" file with the body: - """ -

A testing file that exists on disk

- """ - Given I have a "public/index.js" file with the content: - """ - import * as pagefind from "pagefind"; - import fs from "fs"; - import path from "path"; - - const run = async () => { - const { index } = await pagefind.createIndex(); - await index.addDirectory({ path: "custom_files" }); - await index.addCustomRecord({ - url: "/synth/", - content: "A testing file that doesn't exist.", - language: "en" - }); - const { files } = await index.getFiles(); - - for (const file of files) { - const output_path = path.join("pagefind", file.path); - const dir = path.dirname(output_path); - if (!fs.existsSync(dir)){ - fs.mkdirSync(dir, { recursive: true }); - } - - fs.writeFileSync(output_path, file.content); - } - console.log("Donezo!"); - } - - run(); - """ - When I run "cd public && npm i && PAGEFIND_BINARY_PATH={{humane_cwd}}/$TEST_BINARY node index.js" - Then I should see "Donezo!" 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 search = await pagefind.search("testing"); - - let pages = await Promise.all(search.results.map(r => r.data())); - document.querySelector('[data-url]').innerText = pages.map(p => p.url).sort().join(", "); - } - """ - Then There should be no logs - Then The selector "[data-url]" should contain "/real/, /synth/" - - @platform-unix - Scenario: Build an index to a custom disk location via the api - Given I have a "output/index.html" file with the body: - """ -

Nothing

- """ - Given I have a "public/index.js" file with the content: - """ - import * as pagefind from "pagefind"; - - const run = async () => { - const { index } = await pagefind.createIndex(); - await index.addHTMLFile({sourcePath: "dogs/index.html", content: "

Testing, testing

"}); - await index.writeFiles({ outputPath: "../output/pagefind" }); - console.log(`Successfully wrote files`); - } - - run(); - """ - When I run "cd public && npm i && PAGEFIND_BINARY_PATH={{humane_cwd}}/$TEST_BINARY node index.js" - Then I should see "Successfully wrote files" in stdout - Then I should see the file "output/pagefind/pagefind.js" - When I serve the "output" directory - When I load "/" - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let search = await pagefind.search("testing"); - - 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 "/dogs/" - - @platform-unix - Scenario: An index is not consumed on write - Given I have a "output/index.html" file with the body: - """ -

Nothing

- """ - Given I have a "public/index.js" file with the content: - """ - import * as pagefind from "pagefind"; - - const run = async () => { - const { index } = await pagefind.createIndex(); - await index.addHTMLFile({sourcePath: "dogs/index.html", content: "

Testing, testing

"}); - await index.writeFiles({ outputPath: "../output/pagefind" }); - - await index.addHTMLFile({sourcePath: "rabbits/index.html", content: "

Testing, testing

"}); - const { files } = await index.getFiles(); - - const fragments = files.filter(file => file.path.includes("fragment")); - console.log(`${fragments.length} fragment(s)`); - - await index.addHTMLFile({sourcePath: "cats/index.html", content: "

Testing, testing

"}); - await index.writeFiles({ outputPath: "./pagefind" }); - - console.log(`Successfully wrote files`); - } - - run(); - """ - When I run "cd public && npm i && PAGEFIND_BINARY_PATH={{humane_cwd}}/$TEST_BINARY node index.js" - Then I should see "Successfully wrote files" in stdout - Then I should see "2 fragment(s)" in stdout - Then I should see the file "output/pagefind/pagefind.js" - When I serve the "output" directory - When I load "/" - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let search = await pagefind.search("testing"); - - let pages = await Promise.all(search.results.map(r => r.data())); - document.querySelector('[data-url]').innerText = pages.map(p => p.url).sort().join(", "); - } - """ - Then There should be no logs - Then The selector "[data-url]" should contain "/dogs/" - When I serve the "public" directory - When I load "/" - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let search = await pagefind.search("testing"); - - let pages = await Promise.all(search.results.map(r => r.data())); - document.querySelector('[data-url]').innerText = pages.map(p => p.url).sort().join(", "); - } - """ - Then There should be no logs - Then The selector "[data-url]" should contain "/cats/, /dogs/, /rabbits/" - - @platform-unix - Scenario: Pagefind service config - Given I have a "public/index.js" file with the content: - """ - import * as pagefind from "pagefind"; - - const run = async () => { - const { index } = await pagefind.createIndex({ - rootSelector: "h1", - excludeSelectors: ["span"], - keepIndexUrl: true, - }); - await index.addHTMLFile({sourcePath: "dogs/index.html", content: "

Testing, testing

"}); - await index.writeFiles(); - console.log(`Successfully wrote files`); - } - - run(); - """ - When I run "cd public && npm i && PAGEFIND_BINARY_PATH={{humane_cwd}}/$TEST_BINARY node index.js" - Then I should see "Successfully wrote files" 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 search = await pagefind.search("testing"); - - let data = await search.results[0].data(); - document.querySelector('[data-url]').innerText = `${data.url} • ${data.content}`; - } - """ - Then There should be no logs - Then The selector "[data-url]" should contain "/dogs/index.html • Testing," - - @platform-unix - Scenario: Pagefind error handling - Given I have a "public/index.js" file with the content: - """ - import * as pagefind from "pagefind"; - - const bad = async () => { - const { index } = await pagefind.createIndex(); - await index.deleteIndex(); - const { errors, files } = await index.getFiles(); - console.log(JSON.stringify(errors)); - - try { - const response = await pagefind.createIndex({ - rootSelector: 5 - }); - } catch(e) { - console.log(e.toString()); - } - } - bad(); - """ - When I run "cd public && npm i && PAGEFIND_BINARY_PATH={{humane_cwd}}/$TEST_BINARY node index.js" - Then I should see "invalid type: integer `5`" in stdout - Then I should see "Index has been deleted from the Pagefind service and no longer exists" in stdout - - @platform-unix - Scenario: Pagefind empty index returns assets - Given I have a "public/index.js" file with the content: - """ - import * as pagefind from "pagefind"; - - const run = async () => { - const { index } = await pagefind.createIndex(); - const { errors, files } = await index.getFiles(); - console.log(files.map(f => f.path).join(', ')); - } - run(); - """ - When I run "cd public && npm i && PAGEFIND_BINARY_PATH={{humane_cwd}}/$TEST_BINARY node index.js" - Then I should see "pagefind.js" in stdout - Then I should see "pagefind-ui.js" in stdout - Then I should see "pagefind-ui.css" in stdout - Then I should see "pagefind-modular-ui.js" in stdout - Then I should see "pagefind-modular-ui.css" in stdout - Then I should see "wasm.unknown.pagefind" in stdout - - @platform-unix - Scenario: Close the Pagefind backend - Given I have a "public/index.js" file with the content: - """ - import * as pagefind from "pagefind"; - - const run = async () => { - const { index } = await pagefind.createIndex(); - const { errors, files } = await index.getFiles(); - console.log(files.map(f => f.path).join(', ')); - await pagefind.close(); - const { errors: es } = await index.getFiles(); - console.log(`After close: ${es.join(',')}`); - } - run(); - """ - When I run "cd public && npm i && PAGEFIND_BINARY_PATH={{humane_cwd}}/$TEST_BINARY node index.js" - Then I should see "pagefind.js" in stdout - Then I should see "After close: Invalid index, does not yet exist in the Pagefind service" in stdout - - # https://github.com/CloudCannon/pagefind/issues/551 - @platform-unix - Scenario: Force language takes precedence over records - Given I have a "public/index.js" file with the content: - """ - import * as pagefind from "pagefind"; - import fs from "fs"; - import path from "path"; - - const run = async () => { - const { index } = await pagefind.createIndex({ - forceLanguage: "fr" - }); - await index.addCustomRecord({ - url: "/one/", - content: "Testing file #1", - language: "pt" - }); - await index.addHTMLFile({sourcePath: "two/index.html", content: "

Testing file #2

"}); - await index.writeFiles(); - - console.log("✨!"); - } - - run(); - """ - When I run "cd public && npm i && PAGEFIND_BINARY_PATH={{humane_cwd}}/$TEST_BINARY node index.js" - Then I should see "✨!" in stdout - Then I should see the file "public/pagefind/pagefind.js" - Then I should see the file "public/pagefind/wasm.unknown.pagefind" - Then I should see the file "public/pagefind/wasm.fr.pagefind" - Then I should not see the file "public/pagefind/wasm.pt.pagefind" - Then I should not see the file "public/pagefind/wasm.en.pagefind" diff --git a/pagefind/features/partial_matching.feature b/pagefind/features/partial_matching.feature deleted file mode 100644 index 7400b768..00000000 --- a/pagefind/features/partial_matching.feature +++ /dev/null @@ -1,31 +0,0 @@ -Feature: Partial Matching - - Background: - Given I have the environment variables: - | PAGEFIND_SITE | public | - - @skip - Scenario: Search will return pages that match 2 out of 3 words - Given I have a "public/cat/index.html" file with the body: - """ -

hello world

- """ - 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 search = await pagefind.search("hello there 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 "/cat/" - diff --git a/pagefind/features/sanity.feature b/pagefind/features/sanity.feature deleted file mode 100644 index 1d18c2e6..00000000 --- a/pagefind/features/sanity.feature +++ /dev/null @@ -1,16 +0,0 @@ -Feature: Sanity Tests - - Scenario: CLI tests are working - Given I have a "public/index.html" file - When I run my program with the flags: - | --site public | - Then I should see "Running Pagefind" in stdout - - Scenario: Web tests are working - Given I have a "public/index.html" file with the body: - """ -

Hello!

- """ - When I serve the "public" directory - When I load "/" - Then The selector "h1" should contain "Hello!" diff --git a/pagefind/features/scoring_custom.feature b/pagefind/features/scoring_custom.feature deleted file mode 100644 index 25b3517d..00000000 --- a/pagefind/features/scoring_custom.feature +++ /dev/null @@ -1,238 +0,0 @@ -Feature: Result Scoring - Background: - Given I have the environment variables: - | PAGEFIND_SITE | public | - Given I have a "public/index.html" file with the body: - """ - - """ - # Create dummy pages to allow BM25 calculations to be effective - Given I have a "public/latin-1/index.html" file with the body: - """ -

Maecenas sed diam eget risus varius blandit sit amet non common

- """ - Given I have a "public/latin-2/index.html" file with the body: - """ -

Cras justo odio, common ac facilisis in, egestas eget quam.

- """ - Given I have a "public/latin-3/index.html" file with the body: - """ -

Donec sed odio dui.

- """ - Given I have a "public/latin-4/index.html" file with the body: - """ -

Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.

- """ - Given I have a "public/latin-5/index.html" file with the body: - """ -

Integer posuere erat a ante venenatis dapibus posuere velit aliquet..

- """ - - Scenario: Term similarity ranking can be configured - Given I have a "public/similar-term/index.html" file with the body: - """ -

This post talks about abcdef once

- """ - Given I have a "public/dissimilar-term/index.html" file with the body: - """ -

This post talks about abcdefghijklmnopqrstuv — twice! abcdefghijklmnopqrstuv

- """ - When I run my program - Then I should see "Running Pagefind" in stdout - When I serve the "public" directory - When I load "/" - # The abcdefghijklmnopqrstuv hits should be pretty useless - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let search = await pagefind.search(`abcdef`); - - let data = await Promise.all(search.results.map(result => result.data())); - document.querySelector('[data-result]').innerText = data.map(d => d.url).join(', '); - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "/similar-term/, /dissimilar-term/" - # The abcdefghijklmnopqrstuv hits are just as important, so win due to two of them - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - await pagefind.options({ - ranking: { - termSimilarity: 0.0 - } - }); - - let search = await pagefind.search(`abcdef`); - - let data = await Promise.all(search.results.map(result => result.data())); - document.querySelector('[data-result]').innerText = data.map(d => d.url).join(', '); - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "/dissimilar-term/, /similar-term/" - - Scenario: Page length ranking can be configured - Given I have a "public/longer/index.html" file with the body: - """ -

This post is quite long, and talks about terracotta at length.

-

Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum terracotta justo sit amet risus. Donec sed odio dui. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Nulla vitae elit libero, a pharetra augue. Aenean lacinia bibendum nulla sed consectetur. Donec id elit non mi porta gravida at eget metus. Maecenas faucibus mollis interdum.

-

Integer terracotta erat a ante venenatis dapibus posuere velit aliquet. Vivamus sagittis lacus vel augue laoreet rutrum faucibus terracotta auctor. Nullam quis risus eget urna mollis ornare vel eu leo. Aenean lacinia bibendum nulla sed consectetur.

-

Praesent commodo cursus magna, vel scelerisque terracotta consectetur et. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur blandit tempus porttitor.

- """ - Given I have a "public/shorter/index.html" file with the body: - """ -

This is a shorter terracotta page.

-

Sed posuere consectetur est at lobortis.

- """ - When I run my program - Then I should see "Running Pagefind" in stdout - When I serve the "public" directory - When I load "/" - # Should prefer documents shorter than the average document - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - await pagefind.options({ - ranking: { - pageLength: 1.0 - } - }); - - let search = await pagefind.search(`terracotta`); - - let data = await Promise.all(search.results.map(result => result.data())); - document.querySelector('[data-result]').innerText = data.map(d => d.url).join(', '); - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "/shorter/, /longer/" - # Should care about term frequency more than document length - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - await pagefind.options({ - ranking: { - pageLength: 0.0 - } - }); - - let search = await pagefind.search(`terracotta`); - - let data = await Promise.all(search.results.map(result => result.data())); - document.querySelector('[data-result]').innerText = data.map(d => d.url).join(', '); - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "/longer/, /shorter/" - - Scenario: Term frequency vs raw count can be configured - Given I have a "public/longer/index.html" file with the body: - """ -

This post is quite long, and talks about terracotta at length.

-

Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum terracotta justo sit amet risus. Donec sed odio dui. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Nulla vitae elit libero, a pharetra augue. Aenean lacinia bibendum nulla sed consectetur. Donec id elit non mi porta gravida at eget metus. Maecenas faucibus mollis interdum.

-

Integer erat a ante venenatis dapibus posuere velit aliquet. Vivamus sagittis lacus vel augue laoreet rutrum faucibus auctor. Nullam quis risus eget urna mollis ornare vel eu leo. Aenean lacinia bibendum nulla sed consectetur.

-

Praesent commodo cursus magna, vel scelerisque consectetur et. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur blandit tempus porttitor.

- """ - Given I have a "public/shorter/index.html" file with the body: - """ -

This is a shorter terracotta page.

- """ - When I run my program - Then I should see "Running Pagefind" in stdout - When I serve the "public" directory - When I load "/" - # Default: should score based on term frequency - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let search = await pagefind.search(`terracotta`); - - let data = await Promise.all(search.results.map(result => result.data())); - document.querySelector('[data-result]').innerText = data.map(d => d.url).join(', '); - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "/shorter/, /longer/" - # Flipped: Should pick the page with higher result count, regardless of length - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - await pagefind.options({ - ranking: { - termFrequency: 0.0 - } - }); - - let search = await pagefind.search(`terracotta`); - - let data = await Promise.all(search.results.map(result => result.data())); - document.querySelector('[data-result]').innerText = data.map(d => d.url).join(', '); - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "/longer/, /shorter/" - - Scenario: Term saturation can be configured - Given I have a "public/lots/index.html" file with the body: - """ -

post

-

common and common and common and unrelated

- """ - Given I have a "public/slightly-less-than-lots/index.html" file with the body: - """ -

post

-

common and common and unrelated and unrelated

- """ - When I run my program - Then I should see "Running Pagefind" in stdout - When I serve the "public" directory - When I load "/" - # More sensitive to term frequency, should pick the more frequent document for "common" - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - await pagefind.options({ - ranking: { - termSaturation: 2.0 - } - }); - - let search = await pagefind.search(`common post`); - - let data = await Promise.all(search.results.map(result => result.data())); - document.querySelector('[data-result]').innerText = data.map(d => d.url).join(', '); - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "/slightly-less-than-lots/, /lots/" - # Less sensitive to term frequency of "common", should pick the better document for "post" - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - await pagefind.options({ - ranking: { - termSaturation: 0.1 - } - }); - - let search = await pagefind.search(`common post`); - - let data = await Promise.all(search.results.map(result => result.data())); - document.querySelector('[data-result]').innerText = data.map(d => d.url).join(', '); - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "/lots/, /slightly-less-than-lots/" diff --git a/pagefind/features/scoring_defaults.feature b/pagefind/features/scoring_defaults.feature deleted file mode 100644 index 90551037..00000000 --- a/pagefind/features/scoring_defaults.feature +++ /dev/null @@ -1,88 +0,0 @@ -Feature: Result Scoring - Background: - Given I have the environment variables: - | PAGEFIND_SITE | public | - Given I have a "public/index.html" file with the body: - """ - - """ - Given I have a "public/cat/index.html" file with the body: - """ -

Happy cat post, that later mentions dogs in the context of cats

- """ - Given I have a "public/dog/index.html" file with the body: - """ -

A post about dogs vs cats (but mainly dogs)

- """ - When I run my program - Then I should see "Running Pagefind" in stdout - When I serve the "public" directory - When I load "/" - - Scenario: Search results are ranked by word frequency - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let search = await pagefind.search(`cat`); - - document.querySelector('[data-count]').innerText = `${search.results.length} result(s)`; - let data = await Promise.all(search.results.map(result => result.data())); - document.querySelector('[data-result]').innerText = data.map(d => d.url).join(', '); - } - """ - Then There should be no logs - Then The selector "[data-count]" should contain "2 result(s)" - Then The selector "[data-result]" should contain "/cat/, /dog/" - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let search = await pagefind.search(`dog`); - - document.querySelector('[data-count]').innerText = `${search.results.length} result(s)`; - let data = await Promise.all(search.results.map(result => result.data())); - document.querySelector('[data-result]').innerText = data.map(d => d.url).join(', '); - } - """ - Then There should be no logs - Then The selector "[data-count]" should contain "2 result(s)" - Then The selector "[data-result]" should contain "/dog/, /cat/" - - @skip - Scenario: Search terms in close proximity rank higher in results - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let search = await pagefind.search(`cats dogs`); - - document.querySelector('[data-count]').innerText = `${search.results.length} result(s)`; - let data = await Promise.all(search.results.map(result => result.data())); - document.querySelector('[data-result]').innerText = data.map(d => d.url).join(', '); - } - """ - Then There should be no logs - Then The selector "[data-count]" should contain "2 result(s)" - Then The selector "[data-result]" should contain "/dog/, /cat/" - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let search = await pagefind.search(`cats posts`); - - document.querySelector('[data-count]').innerText = `${search.results.length} result(s)`; - let data = await Promise.all(search.results.map(result => result.data())); - document.querySelector('[data-result]').innerText = data.map(d => d.url).join(', '); - } - """ - Then There should be no logs - Then The selector "[data-count]" should contain "2 result(s)" - Then The selector "[data-result]" should contain "/cat/, /dog/" diff --git a/pagefind/features/search_options.feature b/pagefind/features/search_options.feature deleted file mode 100644 index 9475a297..00000000 --- a/pagefind/features/search_options.feature +++ /dev/null @@ -1,95 +0,0 @@ -Feature: Search Options - - Background: - Given I have the environment variables: - | PAGEFIND_SITE | public | - - Scenario: Base URL can be configured - Given I have a "public/index.html" file with the body: - """ -

Nothing

- """ - Given I have a "public/cat/index.html" file with the body: - """ -

world

- """ - 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({ - baseUrl: "/docs/" - }); - - 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 "/docs/cat/" - - Scenario: Base URL auto-detects the default directory being moved - Given I have a "public/index.html" file with the body: - """ -

Nothing

- """ - Given I have a "public/cat/index.html" file with the body: - """ -

world

- """ - When I run my program with the flags: - | --output-subdir blog/pagefind | - Then I should see "Running Pagefind" in stdout - Then I should see the file "public/blog/pagefind/pagefind.js" - When I serve the "public" directory - When I load "/" - When I evaluate: - """ - async function() { - let pagefind = await import("/blog/pagefind/pagefind.js"); - - 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 "/blog/cat/" - - Scenario: Keep Index URL can be configured - Given I have a "public/index.html" file with the body: - """ -

Nothing

- """ - Given I have a "public/cat/index.html" file with the body: - """ -

world

- """ - When I run my program with the flags: - | --output-subdir blog/pagefind | - | --keep-index-url | - Then I should see "Running Pagefind" in stdout - Then I should see the file "public/blog/pagefind/pagefind.js" - When I serve the "public" directory - When I load "/" - When I evaluate: - """ - async function() { - let pagefind = await import("/blog/pagefind/pagefind.js"); - - 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 "/blog/cat/index.html" diff --git a/pagefind/features/sentences.feature b/pagefind/features/sentences.feature deleted file mode 100644 index e0580972..00000000 --- a/pagefind/features/sentences.feature +++ /dev/null @@ -1,104 +0,0 @@ -Feature: Sentence Building Tests - Background: - Given I have the environment variables: - | PAGEFIND_SITE | public | - Given I have a "public/index.html" file with the body: - """ -

Nothing

- """ - - Scenario: Pagefind joins block elements as sentences - Given I have a "public/apiary/index.html" file with the body: - """ -

Hello

World

- """ - 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 search = await pagefind.search("h"); - - let pages = await Promise.all(search.results.map(r => r.data())); - document.querySelector('[data-result]').innerText = pages.map(p => p.content).join(", "); - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "Hello. World." - - Scenario: Pagefind doesn't join inline elements as sentences - Given I have a "public/apiary/index.html" file with the body: - """ - HelloWorld - """ - 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 search = await pagefind.search("h"); - - let pages = await Promise.all(search.results.map(r => r.data())); - document.querySelector('[data-result]').innerText = pages.map(p => p.content).join(", "); - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "HelloWorld" - - Scenario: Pagefind treats br tags as spaces - Given I have a "public/apiary/index.html" file with the body: - """ -

Hello
World

- """ - 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 search = await pagefind.search("w"); - - let pages = await Promise.all(search.results.map(r => r.data())); - document.querySelector('[data-result]').innerText = pages.map(p => p.content).join(", "); - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "Hello World." - - Scenario: Pagefind ignores redundant zero-width spaces - Given I have a "public/apiary/index.html" file with the body: - """ -

Hello ​ World

- """ - 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 search = await pagefind.search("w"); - - let pages = await Promise.all(search.results.map(r => r.data())); - document.querySelector('[data-result]').innerHTML = pages.map(p => p.excerpt).join(", "); - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "Hello World." diff --git a/pagefind/features/sorting.feature b/pagefind/features/sorting.feature deleted file mode 100644 index 06839312..00000000 --- a/pagefind/features/sorting.feature +++ /dev/null @@ -1,131 +0,0 @@ -Feature: Result Sorting - Background: - Given I have the environment variables: - | PAGEFIND_SITE | public | - Given I have a "public/index.html" file with the body: - """ -

-

- """ - Given I have a "public/robe/painte/index.html" file with the body: - """ - -

Robe Painte ™️

- - 1 - black - """ - Given I have a "public/robe/megapointe/index.html" file with the body: - """ - -

Robe MegaPointe ™️

- - 9.5 - white - """ - Given I have a "public/robe/superspikie/index.html" file with the body: - """ - 5105 -

Robe SuperSpikie ™️

- - 10 - """ - When I run my program - Then I should see "Running Pagefind" in stdout - When I serve the "public" directory - When I load "/" - - Scenario: Pagefind can sort results by an alphabetical attribute - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let asc_search = await pagefind.search("Robe", { sort: { model: "asc" } }); - let asc_data = await Promise.all(asc_search.results.map(result => result.data())); - document.querySelector('[data-asc]').innerText = asc_data.map(d => d.url).join(', '); - - let desc_search = await pagefind.search("Robe", { sort: { model: "desc" } }); - let desc_data = await Promise.all(desc_search.results.map(result => result.data())); - document.querySelector('[data-desc]').innerText = desc_data.map(d => d.url).join(', '); - } - """ - Then There should be no logs - Then The selector "[data-asc]" should contain "/robe/megapointe/, /robe/painte/, /robe/superspikie/" - Then The selector "[data-desc]" should contain "/robe/superspikie/, /robe/painte/, /robe/megapointe/" - - Scenario: Pagefind can sort results by an automatically detected integer - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let asc_search = await pagefind.search("Robe", { sort: { lumens: "asc" } }); - let asc_data = await Promise.all(asc_search.results.map(result => result.data())); - document.querySelector('[data-asc]').innerText = asc_data.map(d => d.url).join(', '); - - let desc_search = await pagefind.search("Robe", { sort: { lumens: "desc" } }); - let desc_data = await Promise.all(desc_search.results.map(result => result.data())); - document.querySelector('[data-desc]').innerText = desc_data.map(d => d.url).join(', '); - } - """ - Then There should be no logs - Then The selector "[data-asc]" should contain "/robe/superspikie/, /robe/megapointe/, /robe/painte/" - Then The selector "[data-desc]" should contain "/robe/painte/, /robe/megapointe/, /robe/superspikie/" - - Scenario: Pagefind can sort results by an automatically detected float - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let asc_search = await pagefind.search("Robe", { sort: { weight: "asc" } }); - let asc_data = await Promise.all(asc_search.results.map(result => result.data())); - document.querySelector('[data-asc]').innerText = asc_data.map(d => d.url).join(', '); - - let desc_search = await pagefind.search("Robe", { sort: { weight: "desc" } }); - let desc_data = await Promise.all(desc_search.results.map(result => result.data())); - document.querySelector('[data-desc]').innerText = desc_data.map(d => d.url).join(', '); - } - """ - Then There should be no logs - Then The selector "[data-asc]" should contain "/robe/painte/, /robe/megapointe/, /robe/superspikie/" - Then The selector "[data-desc]" should contain "/robe/superspikie/, /robe/megapointe/, /robe/painte/" - - Scenario: Pagefind can sort results by mixed floats and integers - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let asc_search = await pagefind.search("Robe", { sort: { mixed: "asc" } }); - let asc_data = await Promise.all(asc_search.results.map(result => result.data())); - document.querySelector('[data-asc]').innerText = asc_data.map(d => d.url).join(', '); - - let desc_search = await pagefind.search("Robe", { sort: { mixed: "desc" } }); - let desc_data = await Promise.all(desc_search.results.map(result => result.data())); - document.querySelector('[data-desc]').innerText = desc_data.map(d => d.url).join(', '); - } - """ - Then There should be no logs - Then The selector "[data-asc]" should contain "/robe/painte/, /robe/megapointe/, /robe/superspikie/" - Then The selector "[data-desc]" should contain "/robe/superspikie/, /robe/megapointe/, /robe/painte/" - - Scenario: Pagefind excludes pages that aren't tagged with the provided sort option - When I evaluate: - """ - async function() { - let pagefind = await import("/pagefind/pagefind.js"); - - let asc_search = await pagefind.search("Robe", { sort: { color: "asc" } }); - let asc_data = await Promise.all(asc_search.results.map(result => result.data())); - document.querySelector('[data-asc]').innerText = asc_data.map(d => d.url).join(', '); - - let desc_search = await pagefind.search("Robe", { sort: { color: "desc" } }); - let desc_data = await Promise.all(desc_search.results.map(result => result.data())); - document.querySelector('[data-desc]').innerText = desc_data.map(d => d.url).join(', '); - } - """ - Then There should be no logs - Then The selector "[data-asc]" should contain "/robe/painte/, /robe/megapointe/" - Then The selector "[data-desc]" should contain "/robe/megapointe/, /robe/painte/" diff --git a/pagefind/features/stemming.feature b/pagefind/features/stemming.feature deleted file mode 100644 index ac37dc34..00000000 --- a/pagefind/features/stemming.feature +++ /dev/null @@ -1,130 +0,0 @@ -Feature: Word Stemming - Background: - Given I have the environment variables: - | PAGEFIND_SITE | public | - Given I have a "public/index.html" file with the body: - """ - - """ - - Scenario: Searching for a word will match against the stem of that word - Given I have a "public/cat/index.html" file with the body: - """ -

the cat is meowing

- """ - 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 search = await pagefind.search("meowed"); - - let data = await search.results[0].data(); - document.querySelector('[data-result]').innerText = data.url; - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "/cat/" - - Scenario: Search is case independent - Given I have a "public/cat/index.html" file with the body: - """ -

the cat is Meowing

- """ - 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 search = await pagefind.search("meOWings"); - - let data = await search.results[0].data(); - document.querySelector('[data-result]').innerText = data.url; - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "/cat/" - - Scenario: Search is punctuation independent - Given I have a "public/apple/index.html" file with the body: - """ -

My laptop doesn't have a USB-A port

- """ - 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 search = await pagefind.search("usb[a"); - - let data = await search.results[0].data(); - document.querySelector('[data-result]').innerText = data.url; - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "/apple/" - - Scenario: Searching will backtrack a word to find a prefix - Given I have a "public/doc/index.html" file with the body: - """ -

a doc about installation

- """ - 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 search = await pagefind.search("documentation"); - - let results = await Promise.all(search.results.map(r => r.data())); - document.querySelector('[data-result]').innerText = results.map(r => `${r.url} • ${r.excerpt}`).join(', '); - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "/doc/ • a <mark>doc</mark> about installation." - - Scenario: Searching will backtrack a word to find a stem - Given I have a "public/doc/index.html" file with the body: - """ -

a doc about installation

- """ - 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 search = await pagefind.search("installat"); - - let results = await Promise.all(search.results.map(r => r.data())); - document.querySelector('[data-result]').innerText = results.map(r => `${r.url} • ${r.excerpt}`).join(', '); - } - """ - Then There should be no logs - Then The selector "[data-result]" should contain "/doc/ • a doc about <mark>installation.</mark>" \ No newline at end of file diff --git a/pagefind/features/suggestions.feature b/pagefind/features/suggestions.feature deleted file mode 100644 index 00dde252..00000000 --- a/pagefind/features/suggestions.feature +++ /dev/null @@ -1,43 +0,0 @@ -Feature: Spellcheck - - Background: - Given I have the environment variables: - | PAGEFIND_SITE | public | - Given I have a "public/index.html" file with the body: - """ - - """ - - Scenario: Search results will be returned for all extensions of the word - Given I have a "public/one/index.html" file with the body: - """ -

Hello World

- """ - Given I have a "public/two/index.html" file with the body: - """ -

Hello Wow

- """ - 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 search = await pagefind.search("w"); - - let results = await Promise.all(search.results.map(r => r.data())); - document.querySelector('[data-result]').innerText = results.map(r => r.url).join(', '); - } - """ - Then There should be no logs - # It should have prioritised the shorter word extension in the results - Then The selector "[data-result]" should contain "/two/, /one/" - - @skip - Scenario: Spelling correction can be returned for the unique words in the dataset diff --git a/pagefind/features/ui/ui_base.feature b/pagefind/features/ui/ui_base.feature deleted file mode 100644 index b73a3a77..00000000 --- a/pagefind/features/ui/ui_base.feature +++ /dev/null @@ -1,84 +0,0 @@ -Feature: Base UI Tests - Background: - Given I have the environment variables: - | PAGEFIND_SITE | public | - Given I have a "public/index.html" file with the body: - """ - - - - - """ - - Scenario: Pagefind UI loads - Given I have a "public/cat/index.html" file with the body: - """ -

world

- """ - 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 "/" - Then There should be no logs - Then The selector ".pagefind-ui" should exist - - Scenario: Pagefind UI searches - Given I have a "public/cat/index.html" file with the body: - """ -

world

- """ - 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() { - window.pui.triggerSearch("world"); - await new Promise(r => setTimeout(r, 1500)); // TODO: await el in humane - } - """ - Then There should be no logs - Then The selector ".pagefind-ui__result-link" should contain "world" - - Scenario: Pagefind UI can programmatically filter - Given I have a "public/res-zero/index.html" file with the body: - """ -

title title title

- """ - Given I have a "public/res-one/index.html" file with the body: - """ -

title res one

- """ - Given I have a "public/res-two/index.html" file with the body: - """ -

title res two

- """ - 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() { - window.pui.triggerFilters({ "bucket": "a" }); - window.pui.triggerSearch("title"); - await new Promise(r => setTimeout(r, 1500)); // TODO: await el in humane - } - """ - Then There should be no logs - Then The selector ".pagefind-ui__result-link" should contain "title res one" - When I evaluate: - """ - async function() { - window.pui.triggerFilters({ "bucket": ["b"] }); - await new Promise(r => setTimeout(r, 1500)); // TODO: await el in humane - } - """ - Then There should be no logs - Then The selector ".pagefind-ui__result-link" should contain "title res two" diff --git a/pagefind/features/ui/ui_highlight.feature b/pagefind/features/ui/ui_highlight.feature deleted file mode 100644 index 9373be6f..00000000 --- a/pagefind/features/ui/ui_highlight.feature +++ /dev/null @@ -1,134 +0,0 @@ -Feature: Base UI Tests - Background: - Given I have the environment variables: - | PAGEFIND_SITE | public | - - # in this senario I use the css attribute selector to make sure the link has the query param as the end - # if the link doesn't exist, the check will fail - # see https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors#syntax:~:text=%5Battr%24%3Dvalue%5D,by%20value. - - Scenario: Pagefind UI adds highlight query params - Given I have a "public/index.html" file with the body: - """ - - - - - """ - Given I have a "public/cat/index.html" file with the body: - """ -

hello world

-

Hello world! How are you

- """ - 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() { - window.pui.triggerSearch("world"); - await new Promise(r => setTimeout(r, 1500)); // TODO: await el in humane - } - """ - Then There should be no logs - Then The selector ".pagefind-ui__result-link[href$='?pagefind-highlight=world']" should contain "hello world" - When I evaluate: - """ - async function() { - window.pui.triggerSearch("hello world"); - await new Promise(r => setTimeout(r, 1500)); // TODO: await el in humane - } - """ - Then There should be no logs - Then The selector ".pagefind-ui__result-link[href$='?pagefind-highlight=hello&pagefind-highlight=world']" should contain "hello world" - When I evaluate: - """ - async function() { - window.pui.triggerSearch("hello world!"); - await new Promise(r => setTimeout(r, 1500)); // TODO: await el in humane - } - """ - Then There should be no logs - Then The selector ".pagefind-ui__result-link[href$='?pagefind-highlight=hello&pagefind-highlight=world']" should contain "hello world" - - Scenario: Pagefind UI does not add highlight query params by default - Given I have a "public/index.html" file with the body: - """ - - - - - """ - Given I have a "public/cat/index.html" file with the body: - """ -

hello world

-

Hello world! How are you

- """ - 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() { - window.pui.triggerSearch("world"); - await new Promise(r => setTimeout(r, 1500)); // TODO: await el in humane - } - """ - Then There should be no logs - Then The selector ".pagefind-ui__result-link[href$='/']" should contain "hello world" - When I evaluate: - """ - async function() { - window.pui.triggerSearch("hello world"); - await new Promise(r => setTimeout(r, 1500)); // TODO: await el in humane - } - """ - Then There should be no logs - Then The selector ".pagefind-ui__result-link[href$='/']" should contain "hello world" - - Scenario: Pagefind UI uses custom highlight query param name - Given I have a "public/index.html" file with the body: - """ - - - - - """ - Given I have a "public/cat/index.html" file with the body: - """ -

hello world

-

Hello world! How are you

- """ - 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() { - window.pui.triggerSearch("world"); - await new Promise(r => setTimeout(r, 1500)); // TODO: await el in humane - } - """ - Then There should be no logs - Then The selector ".pagefind-ui__result-link[href$='?custom-param=world']" should contain "hello world" - When I evaluate: - """ - async function() { - window.pui.triggerSearch("hello world"); - await new Promise(r => setTimeout(r, 1500)); // TODO: await el in humane - } - """ - Then There should be no logs - Then The selector ".pagefind-ui__result-link[href$='?custom-param=hello&custom-param=world']" should contain "hello world" diff --git a/pagefind/features/ui/ui_hooks.feature b/pagefind/features/ui/ui_hooks.feature deleted file mode 100644 index 2dd637b9..00000000 --- a/pagefind/features/ui/ui_hooks.feature +++ /dev/null @@ -1,76 +0,0 @@ -Feature: UI Hooks - Background: - Given I have the environment variables: - | PAGEFIND_SITE | public | - - Scenario: Pagefind UI can provide a hook to process search terms - Given I have a "public/index.html" file with the body: - """ -

Search

- - - - - """ - 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() { - window.pui.triggerSearch("word"); - await new Promise(r => setTimeout(r, 1500)); // TODO: await el in humane - - // TODO: Add more web test steps to humane instead of throwing js - let el = document.querySelector(".pagefind-ui__result-link"); - if (el.getAttribute("href") !== "/") { - throw new Error(`Search term should have been normalized by processTerm. href: ${el.getAttribute("href")}`); - } - } - """ - Then There should be no logs - - Scenario: Pagefind UI can provide a hook to process results - Given I have a "public/index.html" file with the body: - """ -

Search

- - - - - - """ - 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() { - window.pui.triggerSearch("search"); - await new Promise(r => setTimeout(r, 1500)); // TODO: await el in humane - - // TODO: Add more web test steps to humane instead of throwing js - let el = document.querySelector(".pagefind-ui__result-image"); - if (el.getAttribute("src") !== "/example/absolute/my.png") { - throw new Error("Path should have been updated by processResult"); - } - } - """ - Then There should be no logs diff --git a/pagefind/features/ui/ui_scoring.feature b/pagefind/features/ui/ui_scoring.feature deleted file mode 100644 index 4bcc789f..00000000 --- a/pagefind/features/ui/ui_scoring.feature +++ /dev/null @@ -1,73 +0,0 @@ -Feature: UI Scoring - Background: - Given I have the environment variables: - | PAGEFIND_SITE | public | - - Scenario: Pagefind UI can customize scoring - Given I have a "public/unrelated/index.html" file with the body: - """ -

unrelated

-

Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam quis risus eget urna mollis ornare vel eu leo. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec sed odio dui. Cras mattis consectetur purus sit amet fermentum.

- """ - Given I have a "public/longer/index.html" file with the body: - """ -

longer

-

This post is quite long, and talks about terracotta at length.

-

Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum terracotta justo sit amet risus. Donec sed odio dui. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Nulla vitae elit libero, a pharetra augue. Aenean lacinia bibendum nulla sed consectetur. Donec id elit non mi porta gravida at eget metus. Maecenas faucibus mollis interdum.

-

Integer erat a ante venenatis dapibus posuere velit aliquet. Vivamus sagittis lacus vel augue laoreet rutrum faucibus auctor. Nullam quis risus eget urna mollis ornare vel eu leo. Aenean lacinia bibendum nulla sed consectetur.

-

Praesent commodo cursus magna, vel scelerisque consectetur et. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur blandit tempus porttitor.

- """ - Given I have a "public/shorter/index.html" file with the body: - """ -

shorter

-

This is a shorter terracotta page.

- """ - Given I have a "public/a.html" file with the 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 "/a.html" - When I evaluate: - """ - async function() { - window.pui.triggerSearch("terracotta"); - await new Promise(r => setTimeout(r, 1500)); // TODO: await el in humane - } - """ - Then There should be no logs - Then The selector ".pagefind-ui__result-link" should contain "shorter" - Given I have a "public/b.html" file with the body: - """ - - - - - """ - When I load "/b.html" - When I evaluate: - """ - async function() { - window.pui.triggerSearch("terracotta"); - await new Promise(r => setTimeout(r, 1500)); // TODO: await el in humane - } - """ - Then There should be no logs - Then The selector ".pagefind-ui__result-link" should contain "longer" diff --git a/pagefind/features/ui/ui_strings.feature b/pagefind/features/ui/ui_strings.feature deleted file mode 100644 index 4454b3ad..00000000 --- a/pagefind/features/ui/ui_strings.feature +++ /dev/null @@ -1,73 +0,0 @@ -Feature: UI Test Strings - Background: - Given I have the environment variables: - | PAGEFIND_SITE | public | - - Scenario: Pagefind UI loads automatic translations - Given I have a "public/index.html" file with the content: - """ - - - - -

Search

- - - - - - - """ - 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() { - window.pui.triggerSearch("garbage"); - await new Promise(r => setTimeout(r, 1500)); // TODO: await el in humane - } - """ - Then There should be no logs - Then The selector ".pagefind-ui__message" should contain "Nenhum resultado encontrado para garbage" - - Scenario: Pagefind UI can load custom translations - Given I have a "public/index.html" file with the content: - """ - - - - -

Search

- - - - - - - """ - 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() { - window.pui.triggerSearch("garbage"); - await new Promise(r => setTimeout(r, 1500)); // TODO: await el in humane - } - """ - Then There should be no logs - Then The selector ".pagefind-ui__message" should contain "garbage is oh no" diff --git a/pagefind/features/urls.feature b/pagefind/features/urls.feature deleted file mode 100644 index 461e9f8e..00000000 --- a/pagefind/features/urls.feature +++ /dev/null @@ -1,58 +0,0 @@ -Feature: URL tests - Background: - Given I have the environment variables: - | PAGEFIND_SITE | public | - Given I have a "public/index.html" file with the body: - """ -

Nothing

- """ - Given I have a "public/package.json" file with the content: - """ - { - "name": "test", - "type": "module", - "version": "1.0.0", - "main": "index.js", - "dependencies": { - "pagefind": "file:{{humane_cwd}}/../wrappers/node" - } - } - """ - - @platform-unix - Scenario: Tag pages as external URLs - Given I have a "public/index.js" file with the content: - """ - import * as pagefind from "pagefind"; - - const run = async () => { - const { index } = await pagefind.createIndex(); - await index.addCustomRecord({ - url: "https://example.com/external-url/", - content: "Hello World!", - language: "en" - }); - await index.writeFiles(); - console.log(`Successfully wrote files`); - } - - run(); - """ - When I run "cd public && npm i && PAGEFIND_BINARY_PATH={{humane_cwd}}/$TEST_BINARY node index.js" - Then I should see "Successfully wrote files" 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 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 "https://example.com/external-url/" diff --git a/pagefind/features/weighting.feature b/pagefind/features/weighting.feature deleted file mode 100644 index 0b525478..00000000 --- a/pagefind/features/weighting.feature +++ /dev/null @@ -1,231 +0,0 @@ -Feature: Word Weighting - Background: - Given I have the environment variables: - | PAGEFIND_SITE | public | - Given I have a "public/index.html" file with the body: - """ -

no results

- """ - - Scenario: Headings are automatically favoured over standard text - Given I have a "public/r1/index.html" file with the body: - """ -

Antelope

-

Antelope Antelope Antelope Antelope

-

Other text again

- """ - Given I have a "public/r2/index.html" file with the body: - """ -

Antelope

-

Antelope Antelope Antelope Notantelope

-

Other text again

- """ - Given I have a "public/r3/index.html" file with the body: - """ -
Antelope
-

Antelope Antelope Antelope Notantelope

-

Other text again

- """ - Given I have a "public/r4/index.html" file with the body: - """ -

Antelope

-

Other text, totalling eight words of content

- """ - Given I have a "public/r5/index.html" file with the body: - """ -

Antelope

-

Other antelope antelope text, of a similar length

- """ - 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 search = await pagefind.search(`antelope`); - - let data = await Promise.all(search.results.map(result => result.data())); - document.querySelector('p').innerText = data.map(d => d.url).join(', '); - } - """ - Then There should be no logs - Then The selector "p" should contain "/r4/, /r5/, /r3/, /r1/, /r2/" - - Scenario: Text can be explicitly weighted higher - Given I have a "public/r1/index.html" file with the body: - """ -

Antelope

-

Antelope Antelope Not

- """ - Given I have a "public/r2/index.html" file with the body: - """ -

Antelope

-

Antelope Not

- """ - Given I have a "public/r3/index.html" file with the body: - """ -

Antelope

-

Antelope Not

- """ - Given I have a "public/r4/index.html" file with the body: - """ -

Antelope

-

Antelope Antelope Antelope Antelope

- """ - 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 search = await pagefind.search(`antelope`); - - let data = await Promise.all(search.results.map(result => result.data())); - document.querySelector('p').innerText = data.map(d => d.url).join(', '); - } - """ - Then There should be no logs - Then The selector "p" should contain "/r3/, /r4/, /r1/, /r2/" - - Scenario: Text can be explicitly weighted lower - Given I have a "public/r1/index.html" file with the body: - """ -

Antelope Antelope all about Antelope

-

More text about other stuff

- """ - Given I have a "public/r2/index.html" file with the body: - """ -

Five words that aren't related

-

One solitary mention of antelope

- """ - 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 search = await pagefind.search(`antelope`); - - let data = await Promise.all(search.results.map(result => result.data())); - document.querySelector('p').innerText = data.map(d => d.url).join(', '); - } - """ - Then There should be no logs - Then The selector "p" should contain "/r2/, /r1/" - - Scenario: Compound words are implicitly weighted lower - Given I have a "public/r1/index.html" file with the body: - """ -

A single reference to antelope

- """ - Given I have a "public/r2/index.html" file with the body: - """ -

Two references to SomeLongFiveWordAntelope SomeLongFiveWordAntelope

- """ - Given I have a "public/r3/index.html" file with the body: - """ -

A single reference to the TwoAntelope

- """ - 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"); - await pagefind.options({ - ranking: { - termFrequency: 0.0 - } - }); - - let search = await pagefind.search(`antelope`); - - let data = await Promise.all(search.results.map(result => result.data())); - document.querySelector('p').innerText = data.map(d => d.url).join(', '); - } - """ - Then There should be no logs - Then The selector "p" should contain "/r1/, /r3/, /r2/" - - Scenario: Compound words prefixes prioritise the lower weight - Given I have a "public/r1/index.html" file with the body: - """ -

A single reference to ThreeAntelopes

- """ - 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 search = await pagefind.search(`three`); - let data = await search.results[0].data(); - let weights = data.weighted_locations.map(l => `weight:${l.weight}/bal:${l.balanced_score.toFixed(2)}/loc:${l.location}`).join(' • '); - document.querySelector('p').innerText = weights; - } - """ - Then There should be no logs - # Treat the bal value here as a snapshot — update the expected value as needed - Then The selector "p" should contain "weight:0.5/bal:128.04/loc:4" - - Scenario: Compound words sum to a full weight - Given I have a "public/r1/index.html" file with the body: - """ -

A single reference to ThreeAntelopes

- """ - 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 search = await pagefind.search(`three antelopes`); - let data = await search.results[0].data(); - let weights = data.weighted_locations.map(l => `weight:${l.weight}/bal:${l.balanced_score.toFixed(2)}/loc:${l.location}`).join(' • '); - document.querySelector('p').innerText = weights; - } - """ - Then There should be no logs - # Treat the bal value here as a snapshot — update the expected value as needed - Then The selector "p" should contain "weight:1/bal:512.14/loc:4" - - Scenario: Compound words matched as full words use the full weight - Given I have a "public/r1/index.html" file with the body: - """ -

A single reference to ThreeAntelopes

- """ - 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 search = await pagefind.search(`threea`); - let data = await search.results[0].data(); - let weights = data.weighted_locations.map(l => `weight:${l.weight}/bal:${l.balanced_score.toFixed(2)}/loc:${l.location}`).join(' • '); - document.querySelector('p').innerText = weights; - } - """ - Then There should be no logs - # Treat the bal value here as a snapshot — update the expected value as needed - Then The selector "p" should contain "weight:1/bal:212.36/loc:4" diff --git a/pagefind/integration_tests/anchors/background.toolproof.yml b/pagefind/integration_tests/anchors/background.toolproof.yml new file mode 100644 index 00000000..cda81841 --- /dev/null +++ b/pagefind/integration_tests/anchors/background.toolproof.yml @@ -0,0 +1,57 @@ +name: anchors > Anchors > Background +type: reference +steps: + - step: I have the environment variable "PAGEFIND_SITE" set to "public" + - step: I have a "public/index.html" file with the content {html} + html: >- +

Nothing

+ - step: I have a "public/cat/index.html" file with the content {html} + html: >- +

Outer Heading

+ +
+

PageOne, from Pagefind

+

Cats

+ +

Pagefind

+

PageOne, again, from Pagefind

+
+ +

Outer Content

+ - step: I have a "public/dog/index.html" file with the content {html} + html: |- +
+

PageTwo, from Pagefind

+

Some text nested under the h1

+ +

Words in spans should be extracted

+

Some text nested under the p with spans

+ +

Links should be extracted

+

Some text nested under the h2

+ + Text that is bold or italic should be extracted +

Some text nested under the span

+ +

Text containing nested IDs should extract both

+

Some text nested under the p with IDs

+ +
Divs containing
💀 he he he 💀
divs should only take from the top level
+

Some text nested under the divs

+
+ - step: I have a "public/repr/index.html" file with the content {html} + html: |- +
+

My Redacted Heading about Symbiosis

+
+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: I serve the directory "public" + - step: In my browser, I load "/" diff --git a/pagefind/integration_tests/anchors/pagefind-extracts-page-anchor-text-where-it-makes-sense.toolproof.yml b/pagefind/integration_tests/anchors/pagefind-extracts-page-anchor-text-where-it-makes-sense.toolproof.yml new file mode 100644 index 00000000..6e9cef5f --- /dev/null +++ b/pagefind/integration_tests/anchors/pagefind-extracts-page-anchor-text-where-it-makes-sense.toolproof.yml @@ -0,0 +1,62 @@ +name: Anchors > Pagefind extracts page anchor text where it makes sense +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/pagefind/pagefind.js"); + + let search = await pagefind.search("pagetwo"); + let searchdata = await search.results[0].data(); + document.querySelector('[data-search]').innerHTML = ` + + `; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: >- + let val = await + toolproof.querySelector("[data-search]>ul>li:nth-of-type(1)"); + + toolproof.assert_eq(val.innerHTML, `#h1: 'PageTwo, from Pagefind'`); + - step: In my browser, I evaluate {js} + js: >- + let val = await + toolproof.querySelector("[data-search]>ul>li:nth-of-type(2)"); + + toolproof.assert_eq(val.innerHTML, `#p_spans: 'Words in spans should be + extracted'`); + - step: In my browser, I evaluate {js} + js: >- + let val = await + toolproof.querySelector("[data-search]>ul>li:nth-of-type(3)"); + + toolproof.assert_eq(val.innerHTML, `#h2_hrefs: 'Links should be + extracted'`); + - step: In my browser, I evaluate {js} + js: >- + let val = await + toolproof.querySelector("[data-search]>ul>li:nth-of-type(4)"); + + toolproof.assert_eq(val.innerHTML, `#span_formatted: 'Text that is bold or + italic should be extracted'`); + - step: In my browser, I evaluate {js} + js: >- + let val = await + toolproof.querySelector("[data-search]>ul>li:nth-of-type(5)"); + + toolproof.assert_eq(val.innerHTML, `#p_nested_ids: 'Text containing nested + IDs should extract both'`); + - step: In my browser, I evaluate {js} + js: >- + let val = await + toolproof.querySelector("[data-search]>ul>li:nth-of-type(6)"); + + toolproof.assert_eq(val.innerHTML, `#span_nested: 'nested IDs'`); + - step: In my browser, I evaluate {js} + js: >- + let val = await + toolproof.querySelector("[data-search]>ul>li:nth-of-type(7)"); + + toolproof.assert_eq(val.innerHTML, `#double_div: 'Divs containing divs + should only take from the top level'`); diff --git a/pagefind/integration_tests/anchors/pagefind-respects-data-pagefind-ignore-inside-anchors.toolproof.yml b/pagefind/integration_tests/anchors/pagefind-respects-data-pagefind-ignore-inside-anchors.toolproof.yml new file mode 100644 index 00000000..f7bf5250 --- /dev/null +++ b/pagefind/integration_tests/anchors/pagefind-respects-data-pagefind-ignore-inside-anchors.toolproof.yml @@ -0,0 +1,22 @@ +name: Anchors > Pagefind respects data-pagefind-ignore inside anchors +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/pagefind/pagefind.js"); + + let search = await pagefind.search("symbiosis"); + let searchdata = await search.results[0].data(); + document.querySelector('[data-search]').innerHTML = ` + + `; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: >- + let val = await + toolproof.querySelector("[data-search]>ul>li:nth-of-type(1)"); + + toolproof.assert_eq(val.innerHTML, `/repr/#repr-heading: My Heading about + Symbiosis / 'My Heading about Symbiosis.'`); diff --git a/pagefind/integration_tests/anchors/pagefind-returns-all-page-anchors-in-the-fragment.toolproof.yml b/pagefind/integration_tests/anchors/pagefind-returns-all-page-anchors-in-the-fragment.toolproof.yml new file mode 100644 index 00000000..dcba04f9 --- /dev/null +++ b/pagefind/integration_tests/anchors/pagefind-returns-all-page-anchors-in-the-fragment.toolproof.yml @@ -0,0 +1,22 @@ +name: Anchors > Pagefind returns all page anchors in the fragment +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search("pageone"); + + let searchdata = await search.results[0].data(); + + document.querySelector('[data-search]').innerText = + searchdata.anchors.map(a => `${a.element}#${a.id}: ${a.location}`).join(', + '); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: >- + let val = await toolproof.querySelector("[data-search]"); + + toolproof.assert_eq(val.innerHTML, `h2#cats: 3, ul#list: 4, li#ali: 5, + h2#pagefind: 8`); diff --git a/pagefind/integration_tests/anchors/pagefind-returns-all-word-locations-in-the-fragment.toolproof.yml b/pagefind/integration_tests/anchors/pagefind-returns-all-word-locations-in-the-fragment.toolproof.yml new file mode 100644 index 00000000..79154e86 --- /dev/null +++ b/pagefind/integration_tests/anchors/pagefind-returns-all-word-locations-in-the-fragment.toolproof.yml @@ -0,0 +1,19 @@ +name: Anchors > Pagefind returns all word locations in the fragment +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search("pageone"); + + let searchdata = await search.results[0].data(); + + document.querySelector('[data-search]').innerText = + searchdata.locations.join(', '); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-search]"); + toolproof.assert_eq(val.innerHTML, `0, 9`); diff --git a/pagefind/integration_tests/anchors/pagefind-returns-full-content-without-anchors.toolproof.yml b/pagefind/integration_tests/anchors/pagefind-returns-full-content-without-anchors.toolproof.yml new file mode 100644 index 00000000..0e8cca4f --- /dev/null +++ b/pagefind/integration_tests/anchors/pagefind-returns-full-content-without-anchors.toolproof.yml @@ -0,0 +1,17 @@ +name: Anchors > Pagefind returns full content without anchors +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/pagefind/pagefind.js"); + + let search = await pagefind.search("pageone"); + let searchdata = await search.results[0].data(); + document.querySelector('[data-search]').innerText = searchdata.content; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: >- + let val = await toolproof.querySelector("[data-search]"); + + toolproof.assert_eq(val.innerHTML, `PageOne, from Pagefind. Cats. Cheeka. + Ali. Theodore. Smudge. Pagefind. PageOne, again, from Pagefind.`); diff --git a/pagefind/integration_tests/anchors/pagefind-returns-page-anchor-content-in-the-fragment.toolproof.yml b/pagefind/integration_tests/anchors/pagefind-returns-page-anchor-content-in-the-fragment.toolproof.yml new file mode 100644 index 00000000..53aaafbe --- /dev/null +++ b/pagefind/integration_tests/anchors/pagefind-returns-page-anchor-content-in-the-fragment.toolproof.yml @@ -0,0 +1,21 @@ +name: Anchors > Pagefind returns page anchor content in the fragment +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search("pageone"); + + let searchdata = await search.results[0].data(); + + document.querySelector('[data-search]').innerText = + searchdata.anchors.map(a => `#${a.id}: '${a.text}'`).join(', '); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: >- + let val = await toolproof.querySelector("[data-search]"); + + toolproof.assert_eq(val.innerHTML, `#cats: 'Cats', #list: '', #ali: 'Ali', + #pagefind: 'Pagefind'`); diff --git a/pagefind/integration_tests/anchors/pagefind-returns-subresults-based-on-headings.toolproof.yml b/pagefind/integration_tests/anchors/pagefind-returns-subresults-based-on-headings.toolproof.yml new file mode 100644 index 00000000..a02e09a7 --- /dev/null +++ b/pagefind/integration_tests/anchors/pagefind-returns-subresults-based-on-headings.toolproof.yml @@ -0,0 +1,34 @@ +name: Anchors > Pagefind returns subresults based on headings +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/pagefind/pagefind.js"); + + let search = await pagefind.search("extracted"); + let searchdata = await search.results[0].data(); + document.querySelector('[data-search]').innerHTML = ` + + `; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: >- + let val = await + toolproof.querySelector("[data-search]>ul>li:nth-of-type(1)"); + + toolproof.assert_eq(val.innerHTML, `/dog/#h1: PageTwo, from Pagefind / + 'PageTwo, from Pagefind. Some text nested under the h1. Words in spans + should be extracted. Some text nested under the p with + spans.'`); + - step: In my browser, I evaluate {js} + js: >- + let val = await + toolproof.querySelector("[data-search]>ul>li:nth-of-type(2)"); + + toolproof.assert_eq(val.innerHTML, `/dog/#h2_hrefs: Links should be + extracted / 'should be extracted. Some text nested under the + h2. Text that is bold or italic should be extracted Some text + nested under the span. Text containing nested IDs should + extract'`); diff --git a/pagefind/integration_tests/anchors_example/background.toolproof.yml b/pagefind/integration_tests/anchors_example/background.toolproof.yml new file mode 100644 index 00000000..83a06723 --- /dev/null +++ b/pagefind/integration_tests/anchors_example/background.toolproof.yml @@ -0,0 +1,31 @@ +name: anchors_example > Anchors Example > Background +type: reference +steps: + - step: I have the environment variable "PAGEFIND_SITE" set to "public" + - step: I have a "public/index.html" file with the content {html} + html: >- +

Nothing

+ - step: I have a "public/installation/index.html" file with the content {html} + html: |- +
+

Installing and running Pagefind

+

Pagefind is a static binary with no dynamic dependencies, so in most cases will be simple to install and run. Pagefind is currently supported on Windows, macOS, and x86-64 Linux distributions.

+ +

Running via npx

+

Pagefind publishes a wrapper package through npm, which is the easiest way to get started. This package will download the correct binary of the latest release from GitHub for your platform and run it.

+

Specific versions can be run by passing a version tag.

+

Running Pagefind via npx will download the pagefind_extended release, which includes specialized support for indexing Chinese and Japanese pages.

+ + +

Downloading a precompiled binary

+

If you prefer to install the tool yourself, you can download a precompiled release from GitHub and run the binary directly.

+

We publish two releases, with one being extended. The extended release is a larger binary, but includes specialized support for indexing Chinese and Japanese pages.

+ +

Building from source

+

You can run cargo install pagefind to build from source.

+
+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: I serve the directory "public" + - step: In my browser, I load "/" diff --git a/pagefind/integration_tests/anchors_example/pagefind-returns-subresults-for-an-example-page.toolproof.yml b/pagefind/integration_tests/anchors_example/pagefind-returns-subresults-for-an-example-page.toolproof.yml new file mode 100644 index 00000000..f67987d5 --- /dev/null +++ b/pagefind/integration_tests/anchors_example/pagefind-returns-subresults-for-an-example-page.toolproof.yml @@ -0,0 +1,38 @@ +name: Anchors Example > Pagefind returns subresults for an example page +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/pagefind/pagefind.js"); + + await pagefind.options({ excerptLength: 5 }); + let search = await pagefind.search("pagefind"); + let searchdata = await search.results[0].data(); + document.querySelector('[data-search]').innerHTML = ` + + `; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: >- + let val = await + toolproof.querySelector("[data-search]>ul>li:nth-of-type(1)"); + + toolproof.assert_eq(val.innerHTML, `/installation/: Installing and running + Pagefind / 'and running Pagefind. Pagefind + is'`); + - step: In my browser, I evaluate {js} + js: >- + let val = await + toolproof.querySelector("[data-search]>ul>li:nth-of-type(2)"); + + toolproof.assert_eq(val.innerHTML, `/installation/#running-via-npx: + Running via npx / 'via npx. Pagefind publishes a'`); + - step: In my browser, I evaluate {js} + js: >- + let val = await + toolproof.querySelector("[data-search]>ul>li:nth-of-type(3)"); + + toolproof.assert_eq(val.innerHTML, `/installation/#building-from-source: + Building from source / 'run cargo install pagefind to'`); diff --git a/pagefind/integration_tests/base/background.toolproof.yml b/pagefind/integration_tests/base/background.toolproof.yml new file mode 100644 index 00000000..a3c7195f --- /dev/null +++ b/pagefind/integration_tests/base/background.toolproof.yml @@ -0,0 +1,8 @@ +name: base > Base Tests > Background +type: reference +steps: + - step: I have the environment variable "PAGEFIND_SITE" set to "public" + - step: I have a "public/index.html" file with the content {html} + html: >- +

Nothing

diff --git a/pagefind/integration_tests/base/preload-indexes-then-search-for-a-word.toolproof.yml b/pagefind/integration_tests/base/preload-indexes-then-search-for-a-word.toolproof.yml new file mode 100644 index 00000000..ab7f4469 --- /dev/null +++ b/pagefind/integration_tests/base/preload-indexes-then-search-for-a-word.toolproof.yml @@ -0,0 +1,26 @@ +name: Base Tests > Preload indexes then search for a word +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/cat/index.html" file with the content {html} + html: >- +

world

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/pagefind/pagefind.js"); + + await pagefind.preload("wo"); + let search = await pagefind.search("world"); + + let data = await search.results[0].data(); + document.querySelector('[data-url]').innerText = data.url; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-url]"); + toolproof.assert_eq(val.innerHTML, `/cat/`); diff --git a/pagefind/integration_tests/base/return-all-results.toolproof.yml b/pagefind/integration_tests/base/return-all-results.toolproof.yml new file mode 100644 index 00000000..1251e774 --- /dev/null +++ b/pagefind/integration_tests/base/return-all-results.toolproof.yml @@ -0,0 +1,29 @@ +name: Base Tests > Return all results +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/cat/index.html" file with the content {html} + html: >- +

world

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search(null); + + + let pages = await Promise.all(search.results.map(r => r.data())); + + document.querySelector('[data-url]').innerText = pages.map(p => + p.url).sort().join(", "); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-url]"); + toolproof.assert_eq(val.innerHTML, `/, /cat/`); diff --git a/pagefind/integration_tests/base/search-for-a-word.toolproof.yml b/pagefind/integration_tests/base/search-for-a-word.toolproof.yml new file mode 100644 index 00000000..9c733e85 --- /dev/null +++ b/pagefind/integration_tests/base/search-for-a-word.toolproof.yml @@ -0,0 +1,25 @@ +name: Base Tests > Search for a word +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/cat/index.html" file with the content {html} + html: >- +

world

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/pagefind/pagefind.js"); + + let search = await pagefind.search("world"); + + let data = await search.results[0].data(); + document.querySelector('[data-url]').innerText = data.url; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-url]"); + toolproof.assert_eq(val.innerHTML, `/cat/`); diff --git a/pagefind/integration_tests/build_options/background.toolproof.yml b/pagefind/integration_tests/build_options/background.toolproof.yml new file mode 100644 index 00000000..4b3e7cf7 --- /dev/null +++ b/pagefind/integration_tests/build_options/background.toolproof.yml @@ -0,0 +1,4 @@ +name: build_options > Build Options > Background +type: reference +steps: + - step: I have the environment variable "PAGEFIND_SITE" set to "public" diff --git a/pagefind/integration_tests/build_options/complex-exclusionary-file-glob-can-be-configured.toolproof.yml b/pagefind/integration_tests/build_options/complex-exclusionary-file-glob-can-be-configured.toolproof.yml new file mode 100644 index 00000000..51f5b296 --- /dev/null +++ b/pagefind/integration_tests/build_options/complex-exclusionary-file-glob-can-be-configured.toolproof.yml @@ -0,0 +1,49 @@ +name: Build Options > Complex exclusionary file glob can be configured +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.html" file with the content {html} + html: >- +

Nothing

+ - step: I have a "public/cat/index.htm" file with the content {htm} + htm: >- +

cat + index

+ - step: I have a "public/cat/cat.html" file with the content {html} + html: >- +

cat + cat

+ - step: I have a "public/kitty/cat/index.html" file with the content {html} + html: >- +

kitty cat + index

+ - step: I have a "public/cat.html" file with the content {html} + html: >- +

cat

+ - step: I have a "pagefind.yml" file with the content {yml} + yml: 'glob: "{cat/index.htm,kitty/**/*.html,cat.html}"' + - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search("cat"); + + + let pages = await Promise.all(search.results.map(r => r.data())); + + document.querySelector('[data-result]').innerText = pages.map(p => + p.url).sort().join(", "); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: >- + let val = await toolproof.querySelector("[data-result]"); + + toolproof.assert_eq(val.innerHTML, `/cat.html, /cat/index.htm, + /kitty/cat/`); diff --git a/pagefind/integration_tests/build_options/file-glob-can-be-configured.toolproof.yml b/pagefind/integration_tests/build_options/file-glob-can-be-configured.toolproof.yml new file mode 100644 index 00000000..9fa45bf3 --- /dev/null +++ b/pagefind/integration_tests/build_options/file-glob-can-be-configured.toolproof.yml @@ -0,0 +1,31 @@ +name: Build Options > File glob can be configured +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.html" file with the content {html} + html: >- +

Nothing

+ - step: I have a "public/cat/index.htm" file with the content {htm} + htm: >- +

world

+ - step: I have a "pagefind.yml" file with the content {yml} + yml: 'glob: "**/*.{htm,html}"' + - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/pagefind/pagefind.js"); + + let search = await pagefind.search("world"); + + let data = await search.results[0].data(); + document.querySelector('[data-url]').innerText = data.url; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-url]"); + toolproof.assert_eq(val.innerHTML, `/cat/index.htm`); diff --git a/pagefind/integration_tests/build_options/output-path-can-be-configured-relative-to-cwd.toolproof.yml b/pagefind/integration_tests/build_options/output-path-can-be-configured-relative-to-cwd.toolproof.yml new file mode 100644 index 00000000..2d875509 --- /dev/null +++ b/pagefind/integration_tests/build_options/output-path-can-be-configured-relative-to-cwd.toolproof.yml @@ -0,0 +1,29 @@ +name: Build Options > Output path can be configured relative to cwd +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.html" file with the content {html} + html: >- +

Nothing

+ - step: I have a "public/cat/index.html" file with the content {html} + html: >- +

world

+ - step: I run "%pagefind_exec_path% --output-path misc/_search" + - step: stdout should contain "Running Pagefind" + - step: The file "misc/_search/pagefind.js" should not be empty + - step: I serve the directory "." + - step: In my browser, I load "/public/" + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/misc/_search/pagefind.js"); + + let search = await pagefind.search("world"); + + let data = await search.results[0].data(); + document.querySelector('[data-url]').innerText = data.url; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-url]"); + toolproof.assert_eq(val.innerHTML, `/cat/`); diff --git a/pagefind/integration_tests/build_options/output-path-can-be-configured-with-an-absolute-path.toolproof.yml b/pagefind/integration_tests/build_options/output-path-can-be-configured-with-an-absolute-path.toolproof.yml new file mode 100644 index 00000000..aec2e80b --- /dev/null +++ b/pagefind/integration_tests/build_options/output-path-can-be-configured-with-an-absolute-path.toolproof.yml @@ -0,0 +1,34 @@ +#TODO: This is a broken test that needs to be fixed. + +type: reference +name: Build Options > Output path can be configured with an absolute path +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.html" file with the content {html} + html: >- +

Nothing

+ - step: I have a "public/cat/index.html" file with the content {html} + html: >- +

world

+ - step: >- + I run "%pagefind_exec_path% --output-subdir + %todo_toolproof_dir_abs_path%/other/_search" + - step: stdout should contain "Running Pagefind" + - step: The file "other/_search/pagefind.js" should not be empty + - step: I serve the directory "." + - step: In my browser, I load "/public/" + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/other/_search/pagefind.js"); + + let search = await pagefind.search("world"); + + let data = await search.results[0].data(); + document.querySelector('[data-url]').innerText = data.url; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-url]"); + toolproof.assert_eq(val.innerHTML, `/cat/`); diff --git a/pagefind/integration_tests/build_options/output-path-can-be-configured.toolproof.yml b/pagefind/integration_tests/build_options/output-path-can-be-configured.toolproof.yml new file mode 100644 index 00000000..a84a7661 --- /dev/null +++ b/pagefind/integration_tests/build_options/output-path-can-be-configured.toolproof.yml @@ -0,0 +1,29 @@ +name: Build Options > Output path can be configured +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.html" file with the content {html} + html: >- +

Nothing

+ - step: I have a "public/cat/index.html" file with the content {html} + html: >- +

world

+ - step: I run "%pagefind_exec_path% --output-subdir _search" + - step: stdout should contain "Running Pagefind" + - step: The file "public/_search/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/_search/pagefind.js"); + + let search = await pagefind.search("world"); + + let data = await search.results[0].data(); + document.querySelector('[data-url]').innerText = data.url; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-url]"); + toolproof.assert_eq(val.innerHTML, `/cat/`); diff --git a/pagefind/integration_tests/build_options/root-selector-can-be-configured.toolproof.yml b/pagefind/integration_tests/build_options/root-selector-can-be-configured.toolproof.yml new file mode 100644 index 00000000..cdef9375 --- /dev/null +++ b/pagefind/integration_tests/build_options/root-selector-can-be-configured.toolproof.yml @@ -0,0 +1,36 @@ +name: Build Options > Root selector can be configured +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.html" file with the content {html} + html: >- +

Nothing

+ - step: I have a "public/cat/index.html" file with the content {html} + html: |- +

Ignored

+
+

Hello

+
+

Also ignored

+ - step: I run "%pagefind_exec_path% --root-selector 'body > .content'" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search("hello"); + + + let data = await search.results[0].data(); + + document.querySelector('[data-url]').innerText = `${data.meta.title}, + ${data.content} Ignored is ${data.meta.ignored}.`; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-url]"); + toolproof.assert_eq(val.innerHTML, `Hello, Hello. Ignored is undefined.`); diff --git a/pagefind/integration_tests/build_options/source-folder-can-be-configured.toolproof.yml b/pagefind/integration_tests/build_options/source-folder-can-be-configured.toolproof.yml new file mode 100644 index 00000000..717452bd --- /dev/null +++ b/pagefind/integration_tests/build_options/source-folder-can-be-configured.toolproof.yml @@ -0,0 +1,29 @@ +name: Build Options > Source folder can be configured +steps: + - ref: ./background.toolproof.yml + - step: I have a "my_website/index.html" file with the content {html} + html: >- +

Nothing

+ - step: I have a "my_website/cat/index.html" file with the content {html} + html: >- +

world

+ - step: I run "%pagefind_exec_path% --site my_website" + - step: stdout should contain "Running Pagefind" + - step: The file "my_website/pagefind/pagefind.js" should not be empty + - step: I serve the directory "my_website" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/pagefind/pagefind.js"); + + let search = await pagefind.search("world"); + + let data = await search.results[0].data(); + document.querySelector('[data-url]').innerText = data.url; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-url]"); + toolproof.assert_eq(val.innerHTML, `/cat/`); diff --git a/pagefind/integration_tests/characters/background.toolproof.yml b/pagefind/integration_tests/characters/background.toolproof.yml new file mode 100644 index 00000000..515d2245 --- /dev/null +++ b/pagefind/integration_tests/characters/background.toolproof.yml @@ -0,0 +1,8 @@ +name: characters > Character Tests > Background +type: reference +steps: + - step: I have the environment variable "PAGEFIND_SITE" set to "public" + - step: I have a "public/index.html" file with the content {html} + html: >- +

Nothing

diff --git a/pagefind/integration_tests/characters/pagefind-can-search-for-a-hyphenated-phrase.toolproof.yml b/pagefind/integration_tests/characters/pagefind-can-search-for-a-hyphenated-phrase.toolproof.yml new file mode 100644 index 00000000..bcb9afc2 --- /dev/null +++ b/pagefind/integration_tests/characters/pagefind-can-search-for-a-hyphenated-phrase.toolproof.yml @@ -0,0 +1,29 @@ +name: Character Tests > Pagefind can search for a hyphenated phrase +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/ds/index.html" file with the content {html} + html: >- +

The + beet-root

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search("beet-root"); + + + let pages = await Promise.all(search.results.map(r => r.data())); + + document.querySelector('[data-result]').innerText = pages.map(p => + p.url).join(", "); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `/ds/`); diff --git a/pagefind/integration_tests/characters/pagefind-does-not-return-results-for-queries-that-normalize-to-nothing.toolproof.yml b/pagefind/integration_tests/characters/pagefind-does-not-return-results-for-queries-that-normalize-to-nothing.toolproof.yml new file mode 100644 index 00000000..7b617b34 --- /dev/null +++ b/pagefind/integration_tests/characters/pagefind-does-not-return-results-for-queries-that-normalize-to-nothing.toolproof.yml @@ -0,0 +1,29 @@ +name: >- + Character Tests > Pagefind does not return results for queries that normalize + to nothing +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/bundaberg/index.html" file with the content {html} + html: >- +

Invert can before + opening

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/pagefind/pagefind.js"); + + // Preload some pages that Pagefind might then return as "all pages" + await pagefind.preload("can"); + let search = await pagefind.search("*"); + + let pages = await Promise.all(search.results.map(r => r.data())); + document.querySelector('[data-result]').innerText = `[${pages.length}]`; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `[0]`); diff --git a/pagefind/integration_tests/characters/pagefind-doesn-t-match-html-entities-as-their-text.toolproof.yml b/pagefind/integration_tests/characters/pagefind-doesn-t-match-html-entities-as-their-text.toolproof.yml new file mode 100644 index 00000000..e974bf0f --- /dev/null +++ b/pagefind/integration_tests/characters/pagefind-doesn-t-match-html-entities-as-their-text.toolproof.yml @@ -0,0 +1,29 @@ +name: Character Tests > Pagefind doesn't match HTML entities as their text +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/apiary/index.html" file with the content {html} + html: >- +

The + "bees"

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search("bees"); + + + let pages = await Promise.all(search.results.map(r => r.data())); + + document.querySelector('[data-result]').innerText = pages.map(p => + p.content).join(", "); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `The "bees"`); diff --git a/pagefind/integration_tests/characters/pagefind-handles-html-entities-in-meta.toolproof.yml b/pagefind/integration_tests/characters/pagefind-handles-html-entities-in-meta.toolproof.yml new file mode 100644 index 00000000..a3f32503 --- /dev/null +++ b/pagefind/integration_tests/characters/pagefind-handles-html-entities-in-meta.toolproof.yml @@ -0,0 +1,29 @@ +name: Character Tests > Pagefind handles HTML entities in meta +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/apiary/index.html" file with the content {html} + html: >- +

The "bees"

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search("bees"); + + + let pages = await Promise.all(search.results.map(r => r.data())); + + document.querySelector('[data-result]').innerText = pages.map(p => + p.meta.title).join(", "); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `The "bees"`); diff --git a/pagefind/integration_tests/characters/pagefind-matches-emoji.toolproof.yml b/pagefind/integration_tests/characters/pagefind-matches-emoji.toolproof.yml new file mode 100644 index 00000000..82f31f64 --- /dev/null +++ b/pagefind/integration_tests/characters/pagefind-matches-emoji.toolproof.yml @@ -0,0 +1,33 @@ +name: Character Tests > Pagefind matches emoji +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/fam-separate/index.html" file with the content {html} + html: >- +

Fam + 👨‍👩‍👧‍👦

+ - step: I have a "public/fam-middled/index.html" file with the content {html} + html: >- +

F👨‍👩‍👧‍👦am

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search("👨‍👩‍👧‍👦"); + + + let pages = await Promise.all(search.results.map(r => r.data())); + + document.querySelector('[data-result]').innerText = pages.map(p => + p.url).sort().join(", "); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `/fam-middled/, /fam-separate/`); diff --git a/pagefind/integration_tests/characters/pagefind-matches-special-characters.toolproof.yml b/pagefind/integration_tests/characters/pagefind-matches-special-characters.toolproof.yml new file mode 100644 index 00000000..ff96476a --- /dev/null +++ b/pagefind/integration_tests/characters/pagefind-matches-special-characters.toolproof.yml @@ -0,0 +1,29 @@ +name: Character Tests > Pagefind matches special characters +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/apiary/index.html" file with the content {html} + html: >- +

Béës

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search("Béës"); + + + let pages = await Promise.all(search.results.map(r => r.data())); + + document.querySelector('[data-result]').innerText = pages.map(p => + p.url).join(", "); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `/apiary/`); diff --git a/pagefind/integration_tests/characters/punctuated-compound-words-are-indexed-per-word.toolproof.yml b/pagefind/integration_tests/characters/punctuated-compound-words-are-indexed-per-word.toolproof.yml new file mode 100644 index 00000000..8c57d516 --- /dev/null +++ b/pagefind/integration_tests/characters/punctuated-compound-words-are-indexed-per-word.toolproof.yml @@ -0,0 +1,142 @@ +name: Character Tests > Punctuated compound words are indexed per word +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/hyphen/index.html" file with the content {html} + html: >- +

beet-root

+ - step: I have a "public/period/index.html" file with the content {html} + html: >- +

image.png

+ - step: I have a "public/camel/index.html" file with the content {html} + html: >- +

WKWebVIEWComponent

+ - step: I have a "public/underscore/index.html" file with the content {html} + html: >- +

Word_Boundaries

+ - step: I have a "public/slash/index.html" file with the content {html} + html: >- +

sandwich/salad

+ - step: I have a "public/comma/index.html" file with the content {html} + html: >- +

Cloud,Cannon

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let pages = [ + ...(await Promise.all((await pagefind.search("beet")).results.map(r => r.data()))), + ...(await Promise.all((await pagefind.search("root")).results.map(r => r.data()))), + ]; + + + document.querySelector('[data-result]').innerText = pages.map(p => + p.url).join(", "); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `/hyphen/, /hyphen/`); + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let pages = [ + ...(await Promise.all((await pagefind.search("image")).results.map(r => r.data()))), + ...(await Promise.all((await pagefind.search("png")).results.map(r => r.data()))), + ]; + + + document.querySelector('[data-result]').innerText = pages.map(p => + p.url).join(", "); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `/period/, /period/`); + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let pages = [ + ...(await Promise.all((await pagefind.search("WkWebVIEWComponent")).results.map(r => r.data()))), + ...(await Promise.all((await pagefind.search("web")).results.map(r => r.data()))), + ...(await Promise.all((await pagefind.search("component")).results.map(r => r.data()))), + ]; + + + document.querySelector('[data-result]').innerText = pages.map(p => + p.url).join(", "); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `/camel/, /camel/, /camel/`); + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let pages = [ + ...(await Promise.all((await pagefind.search("word")).results.map(r => r.data()))), + ...(await Promise.all((await pagefind.search("bound")).results.map(r => r.data()))), + ]; + + + document.querySelector('[data-result]').innerText = pages.map(p => + p.url).join(", "); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `/underscore/, /underscore/`); + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let pages = [ + ...(await Promise.all((await pagefind.search("sandwich")).results.map(r => r.data()))), + ...(await Promise.all((await pagefind.search("salad")).results.map(r => r.data()))), + ]; + + + document.querySelector('[data-result]').innerText = pages.map(p => + p.url).join(", "); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `/slash/, /slash/`); + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let pages = [ + ...(await Promise.all((await pagefind.search("CloudCannon")).results.map(r => r.data()))), + ...(await Promise.all((await pagefind.search("cloud")).results.map(r => r.data()))), + ...(await Promise.all((await pagefind.search("cannon")).results.map(r => r.data()))), + ]; + + + document.querySelector('[data-result]').innerText = pages.map(p => + p.url).join(", "); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `/comma/, /comma/, /comma/`); diff --git a/pagefind/integration_tests/compound_filtering/background.toolproof.yml b/pagefind/integration_tests/compound_filtering/background.toolproof.yml new file mode 100644 index 00000000..f273dcca --- /dev/null +++ b/pagefind/integration_tests/compound_filtering/background.toolproof.yml @@ -0,0 +1,78 @@ +name: compound_filtering > Filtering > Background +type: reference +steps: + - step: I have the environment variable "PAGEFIND_SITE" set to "public" + - step: I have a "public/index.html" file with the content {html} + html: >- +

Nothing

+ - step: I have a "public/cheeka/index.html" file with the content {html} + html: >- + Black + + White + +

Cat

+ - step: I have a "public/theodore/index.html" file with the content {html} + html: >- + Zen + + Orange + +

Cat

+ - step: I have a "public/ali/index.html" file with the content {html} + html: >- + Angry + +

Ali Cat

+ - step: I have a "public/smudge/index.html" file with the content {html} + html: >- + Boisterous + + Mischievous + + Black + + White + +

Cat

+ - step: I have a "public/grey/index.html" file with the content {html} + html: >- + Nervous + + Pining + + Grey + +

Cat

+ - step: I have a "public/treacle/index.html" file with the content {html} + html: >- + Lazy + + Black + + White + + Orange + +

Cat

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: |- + window.pagefind = await import("/pagefind/pagefind.js"); + + window.test = async function(pagefind_incantation) { + let search = await pagefind_incantation; + let data = await Promise.all(search.results.map(result => result.data())); + + document.querySelector('[data-results]').innerText = data.map(d => d.url).sort().join(', '); + } diff --git a/pagefind/integration_tests/compound_filtering/filtering-to-a-complex-nested-filter.toolproof.yml b/pagefind/integration_tests/compound_filtering/filtering-to-a-complex-nested-filter.toolproof.yml new file mode 100644 index 00000000..b9500f27 --- /dev/null +++ b/pagefind/integration_tests/compound_filtering/filtering-to-a-complex-nested-filter.toolproof.yml @@ -0,0 +1,27 @@ +name: Filtering > Filtering to a complex nested filter +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I evaluate {js} + js: |- + await test(pagefind.search("Cat", { + filters: { + any: [{ + color: { + any: [{ + any: ["Tabby"] + }, { + all: ["Black", "White", "Orange"] + }] + } + }, { + mood: { + all: ["Nervous", "Pining"] + } + }] + } + })); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-results]"); + toolproof.assert_eq(val.innerHTML, `/ali/, /grey/, /treacle/`); diff --git a/pagefind/integration_tests/compound_filtering/filtering-to-any-of-a-set-of-values-and-another-filter.toolproof.yml b/pagefind/integration_tests/compound_filtering/filtering-to-any-of-a-set-of-values-and-another-filter.toolproof.yml new file mode 100644 index 00000000..d17ff595 --- /dev/null +++ b/pagefind/integration_tests/compound_filtering/filtering-to-any-of-a-set-of-values-and-another-filter.toolproof.yml @@ -0,0 +1,33 @@ +name: Filtering > Filtering to any of a set of values and another filter +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I evaluate {js} + js: |- + await test(pagefind.search("Cat", { + filters: { + color: { + any: ["Black", "Orange"] + }, + mood: "Lazy" + } + })); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-results]"); + toolproof.assert_eq(val.innerHTML, `/cheeka/, /treacle/`); + - step: In my browser, I evaluate {js} + js: |- + await test(pagefind.search("Cat", { + filters: { + color: { + any: ["Black", "Orange"] + }, + mood: "Zen" + } + })); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-results]"); + toolproof.assert_eq(val.innerHTML, `/theodore/`); diff --git a/pagefind/integration_tests/compound_filtering/filtering-to-any-of-a-set-of-values-or-another-filter.toolproof.yml b/pagefind/integration_tests/compound_filtering/filtering-to-any-of-a-set-of-values-or-another-filter.toolproof.yml new file mode 100644 index 00000000..0b812527 --- /dev/null +++ b/pagefind/integration_tests/compound_filtering/filtering-to-any-of-a-set-of-values-or-another-filter.toolproof.yml @@ -0,0 +1,22 @@ +name: Filtering > Filtering to any of a set of values or another filter +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I evaluate {js} + js: |- + await test(pagefind.search("Cat", { + filters: { + any: { + color: { + any: ["Black", "Orange"] + }, + mood: "Angry" + } + } + })); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: >- + let val = await toolproof.querySelector("[data-results]"); + + toolproof.assert_eq(val.innerHTML, `/ali/, /cheeka/, /smudge/, /theodore/, + /treacle/`); diff --git a/pagefind/integration_tests/compound_filtering/filtering-to-any-of-a-single-filter.toolproof.yml b/pagefind/integration_tests/compound_filtering/filtering-to-any-of-a-single-filter.toolproof.yml new file mode 100644 index 00000000..f91b0fac --- /dev/null +++ b/pagefind/integration_tests/compound_filtering/filtering-to-any-of-a-single-filter.toolproof.yml @@ -0,0 +1,19 @@ +name: Filtering > Filtering to any of a single filter +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I evaluate {js} + js: |- + await test(pagefind.search("Cat", { + filters: { + color: { + any: ["Black", "Orange"] + } + } + })); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: >- + let val = await toolproof.querySelector("[data-results]"); + + toolproof.assert_eq(val.innerHTML, `/cheeka/, /smudge/, /theodore/, + /treacle/`); diff --git a/pagefind/integration_tests/compound_filtering/filtering-with-an-exclusion.toolproof.yml b/pagefind/integration_tests/compound_filtering/filtering-with-an-exclusion.toolproof.yml new file mode 100644 index 00000000..6f1b52c9 --- /dev/null +++ b/pagefind/integration_tests/compound_filtering/filtering-with-an-exclusion.toolproof.yml @@ -0,0 +1,20 @@ +name: Filtering > Filtering with an exclusion +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I evaluate {js} + js: |- + await test(pagefind.search("Cat", { + filters: { + color: { + any: ["Black", "Orange"] + }, + mood: { + not: "Lazy" + } + } + })); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-results]"); + toolproof.assert_eq(val.innerHTML, `/smudge/, /theodore/`); diff --git a/pagefind/integration_tests/compound_filtering/filtering-with-nested-exclusions.toolproof.yml b/pagefind/integration_tests/compound_filtering/filtering-with-nested-exclusions.toolproof.yml new file mode 100644 index 00000000..7a06a2c8 --- /dev/null +++ b/pagefind/integration_tests/compound_filtering/filtering-with-nested-exclusions.toolproof.yml @@ -0,0 +1,38 @@ +name: Filtering > Filtering with nested exclusions +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I evaluate {js} + js: |- + await test(pagefind.search("Cat", { + filters: { + all: [ + { + all: [ + { + color: { + any: ["Orange", "White"] + }, + mood: { + any: ["Lazy", "Zen"] + } + }, + { + not: { + color: "Black" + } + } + ] + }, + { + mood: { + none: ["Lazy", "Nervous"] + } + } + ], + } + })); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-results]"); + toolproof.assert_eq(val.innerHTML, `/theodore/`); diff --git a/pagefind/integration_tests/compound_filtering/filtering-with-top-level-exclusion.toolproof.yml b/pagefind/integration_tests/compound_filtering/filtering-with-top-level-exclusion.toolproof.yml new file mode 100644 index 00000000..d4d900e1 --- /dev/null +++ b/pagefind/integration_tests/compound_filtering/filtering-with-top-level-exclusion.toolproof.yml @@ -0,0 +1,24 @@ +name: Filtering > Filtering with top-level exclusion +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I evaluate {js} + js: |- + await test(pagefind.search("Cat", { + filters: { + none: [ + { + color: { + any: ["Orange", "White"] + } + }, + { + mood: "Angry" + } + ] + } + })); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-results]"); + toolproof.assert_eq(val.innerHTML, `/grey/`); diff --git a/pagefind/integration_tests/config_sources/settings-can-be-pulled-from-command-line-flags.toolproof.yml b/pagefind/integration_tests/config_sources/settings-can-be-pulled-from-command-line-flags.toolproof.yml new file mode 100644 index 00000000..2acb1c5a --- /dev/null +++ b/pagefind/integration_tests/config_sources/settings-can-be-pulled-from-command-line-flags.toolproof.yml @@ -0,0 +1,9 @@ +name: Config Sources > Settings can be pulled from command-line flags +steps: + - step: I have a "public/index.html" file with the content {html} + html: >- +

Hello.

+ - step: I run "%pagefind_exec_path% --site public" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty diff --git a/pagefind/integration_tests/config_sources/settings-can-be-pulled-from-environment-variables.toolproof.yml b/pagefind/integration_tests/config_sources/settings-can-be-pulled-from-environment-variables.toolproof.yml new file mode 100644 index 00000000..e756d198 --- /dev/null +++ b/pagefind/integration_tests/config_sources/settings-can-be-pulled-from-environment-variables.toolproof.yml @@ -0,0 +1,10 @@ +name: Config Sources > Settings can be pulled from environment variables +steps: + - step: I have a "public/index.html" file with the content {html} + html: >- +

Hello.

+ - step: I have the environment variable "PAGEFIND_SITE" set to "public" + - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty diff --git a/pagefind/integration_tests/config_sources/settings-can-be-pulled-from-json-configuration-files.toolproof.yml b/pagefind/integration_tests/config_sources/settings-can-be-pulled-from-json-configuration-files.toolproof.yml new file mode 100644 index 00000000..95a211a1 --- /dev/null +++ b/pagefind/integration_tests/config_sources/settings-can-be-pulled-from-json-configuration-files.toolproof.yml @@ -0,0 +1,14 @@ +name: Config Sources > Settings can be pulled from JSON configuration files +steps: + - step: I have a "public/index.html" file with the content {html} + html: >- +

Hello.

+ - step: I have a "pagefind.json" file with the content {json} + json: |- + { + "site": "public" + } + - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty diff --git a/pagefind/integration_tests/config_sources/settings-can-be-pulled-from-multiple-sources.toolproof.yml b/pagefind/integration_tests/config_sources/settings-can-be-pulled-from-multiple-sources.toolproof.yml new file mode 100644 index 00000000..b8d59622 --- /dev/null +++ b/pagefind/integration_tests/config_sources/settings-can-be-pulled-from-multiple-sources.toolproof.yml @@ -0,0 +1,14 @@ +name: Config Sources > Settings can be pulled from multiple sources +steps: + - step: I have a "public/index.html" file with the content {html} + html: >- +

Hello.

+ - step: I have a "pagefind.json" file with the content {json} + json: |- + { + "site": "public" + } + - step: I run "%pagefind_exec_path% --output-subdir _out" + - step: stdout should contain "Running Pagefind" + - step: The file "public/_out/pagefind.js" should not be empty diff --git a/pagefind/integration_tests/config_sources/settings-can-be-pulled-from-toml-configuration-files.toolproof.yml b/pagefind/integration_tests/config_sources/settings-can-be-pulled-from-toml-configuration-files.toolproof.yml new file mode 100644 index 00000000..32a1615c --- /dev/null +++ b/pagefind/integration_tests/config_sources/settings-can-be-pulled-from-toml-configuration-files.toolproof.yml @@ -0,0 +1,11 @@ +name: Config Sources > Settings can be pulled from TOML configuration files +steps: + - step: I have a "public/index.html" file with the content {html} + html: >- +

Hello.

+ - step: I have a "pagefind.toml" file with the content {toml} + toml: site = "public" + - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty diff --git a/pagefind/integration_tests/config_sources/settings-can-be-pulled-from-yaml-configuration-files.toolproof.yml b/pagefind/integration_tests/config_sources/settings-can-be-pulled-from-yaml-configuration-files.toolproof.yml new file mode 100644 index 00000000..05496339 --- /dev/null +++ b/pagefind/integration_tests/config_sources/settings-can-be-pulled-from-yaml-configuration-files.toolproof.yml @@ -0,0 +1,11 @@ +name: Config Sources > Settings can be pulled from YAML configuration files +steps: + - step: I have a "public/index.html" file with the content {html} + html: >- +

Hello.

+ - step: I have a "pagefind.yml" file with the content {yml} + yml: 'site: public' + - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty diff --git a/pagefind/integration_tests/debounce/background.toolproof.yml b/pagefind/integration_tests/debounce/background.toolproof.yml new file mode 100644 index 00000000..1c6921ac --- /dev/null +++ b/pagefind/integration_tests/debounce/background.toolproof.yml @@ -0,0 +1,10 @@ +name: debounce > Debounced Searches > Background +type: reference +steps: + - step: I have the environment variable "PAGEFIND_SITE" set to "public" + - step: I have a "public/index.html" file with the content {html} + html: >- +

Nothing

+ +

Nothing

diff --git a/pagefind/integration_tests/debounce/debounce-repeated-search-calls.toolproof.yml b/pagefind/integration_tests/debounce/debounce-repeated-search-calls.toolproof.yml new file mode 100644 index 00000000..5c81e832 --- /dev/null +++ b/pagefind/integration_tests/debounce/debounce-repeated-search-calls.toolproof.yml @@ -0,0 +1,43 @@ +name: Debounced Searches > Debounce repeated search calls +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/cat/index.html" file with the content {html} + html: >- +

world

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let results = await Promise.all([ + pagefind.debouncedSearch("a"), + pagefind.debouncedSearch("w"), + pagefind.debouncedSearch("wo"), + pagefind.debouncedSearch("wor"), + pagefind.debouncedSearch("worl") + ]); + + + document.querySelector('[data-types]').innerText = results.map(r => (r === + null ? "null" : r.results.length)).join(', '); + + + let pages = await Promise.all(results[4].results.map(r => r.data())); + + document.querySelector('[data-last]').innerText = pages.map(p => + p.url).sort().join(", "); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-types]"); + toolproof.assert_eq(val.innerHTML, `null, null, null, null, 1`); + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-last]"); + toolproof.assert_eq(val.innerHTML, `/cat/`); diff --git a/pagefind/integration_tests/debounce/debounce-with-options.toolproof.yml b/pagefind/integration_tests/debounce/debounce-with-options.toolproof.yml new file mode 100644 index 00000000..3b38cf34 --- /dev/null +++ b/pagefind/integration_tests/debounce/debounce-with-options.toolproof.yml @@ -0,0 +1,43 @@ +name: Debounced Searches > Debounce with options +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/cat/index.html" file with the content {html} + html: >- +

world

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let results = await Promise.all([ + pagefind.debouncedSearch("a", { filters: {} }), + pagefind.debouncedSearch("w", { filters: {} }), + pagefind.debouncedSearch("wo", { filters: {} }), + pagefind.debouncedSearch("wor", { filters: {} }), + pagefind.debouncedSearch("worl", { filters: {} }) + ]); + + + document.querySelector('[data-types]').innerText = results.map(r => (r === + null ? "null" : r.results.length)).join(', '); + + + let pages = await Promise.all(results[4].results.map(r => r.data())); + + document.querySelector('[data-last]').innerText = pages.map(p => + p.url).sort().join(", "); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-types]"); + toolproof.assert_eq(val.innerHTML, `null, null, null, null, 1`); + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-last]"); + toolproof.assert_eq(val.innerHTML, `/cat/`); diff --git a/pagefind/integration_tests/edge_cases/anchors-do-not-leak-through-metadata.toolproof.yml b/pagefind/integration_tests/edge_cases/anchors-do-not-leak-through-metadata.toolproof.yml new file mode 100644 index 00000000..fe0682e5 --- /dev/null +++ b/pagefind/integration_tests/edge_cases/anchors-do-not-leak-through-metadata.toolproof.yml @@ -0,0 +1,83 @@ +name: Graceful Pagefind Errors > Anchors do not leak through metadata +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.html" file with the content {html} + html: |- + + + +

Nothing

+

Nothing

+

Nothing

+

Nothing

+ + + - step: I have a "public/test/index.html" file with the content {html} + html: |- + + + +

+ Heading text +

+

+ Second meta text +

+

+ Extra meta text +

+

+ Extra filter text +

+ + + - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search("text"); + + let results = await Promise.all(search.results.map(r => r.data())); + + let result = results[0]; + + + document.querySelector('[data-title]').innerText = result.meta.title; + + + let subs = result.sub_results.map(s => s.title).sort().join(', '); + + document.querySelector('[data-subs]').innerText = subs; + + + document.querySelector('[data-meta]').innerText = result.meta.extra_meta; + + + let filters = await pagefind.filters(); + + + document.querySelector('[data-filter]').innerText = + Object.keys(filters.extra_filter).join(", "); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-title]"); + toolproof.assert_eq(val.innerHTML, `Heading text`); + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-subs]"); + toolproof.assert_eq(val.innerHTML, `Heading text, Second meta text`); + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-meta]"); + toolproof.assert_eq(val.innerHTML, `Extra meta text`); + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-filter]"); + toolproof.assert_eq(val.innerHTML, `Extra filter text`); diff --git a/pagefind/integration_tests/edge_cases/background.toolproof.yml b/pagefind/integration_tests/edge_cases/background.toolproof.yml new file mode 100644 index 00000000..1b36bb4a --- /dev/null +++ b/pagefind/integration_tests/edge_cases/background.toolproof.yml @@ -0,0 +1,8 @@ +name: edge_cases > Graceful Pagefind Errors > Background +type: reference +steps: + - step: I have the environment variable "PAGEFIND_SITE" set to "public" + - step: I have a "public/index.html" file with the content {html} + html: >- +

Nothing

diff --git a/pagefind/integration_tests/edge_cases/pagefind-doesn-t-error-on-parsing-ambiguities.toolproof.yml b/pagefind/integration_tests/edge_cases/pagefind-doesn-t-error-on-parsing-ambiguities.toolproof.yml new file mode 100644 index 00000000..643167c7 --- /dev/null +++ b/pagefind/integration_tests/edge_cases/pagefind-doesn-t-error-on-parsing-ambiguities.toolproof.yml @@ -0,0 +1,33 @@ +name: Graceful Pagefind Errors > Pagefind doesn't error on parsing ambiguities +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/cat/index.html" file with the content {html} + html: >- +

hello + world

+ - step: I have a "public/dog/index.html" file with the content {html} + html: |- +

hello world

+ + - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search("world"); + + let results = await Promise.all(search.results.map(r => r.data())); + + + document.querySelector('[data-url]').innerText = results.map(r => + r.url).sort().join(', '); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-url]"); + toolproof.assert_eq(val.innerHTML, `/cat/, /dog/`); diff --git a/pagefind/integration_tests/edge_cases/pagefind-finds-a-data-pagefind-body-when-elements-sit-outside-of-the-main-html-element.toolproof.yml b/pagefind/integration_tests/edge_cases/pagefind-finds-a-data-pagefind-body-when-elements-sit-outside-of-the-main-html-element.toolproof.yml new file mode 100644 index 00000000..cbc32c69 --- /dev/null +++ b/pagefind/integration_tests/edge_cases/pagefind-finds-a-data-pagefind-body-when-elements-sit-outside-of-the-main-html-element.toolproof.yml @@ -0,0 +1,46 @@ +name: >- + Graceful Pagefind Errors > Pagefind finds a data-pagefind-body when elements + sit outside of the main html element +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/dog/index.html" file with the content {html} + html: >- +

should not be + indexed, no data-pagefind-body

+ - step: I have a "public/cat/index.html" file with the content {html} + html: |- + + + + + + +

hello world

+ + + + + + - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: stdout should contain "Found a data-pagefind-body element on the site" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search("world"); + + let results = await Promise.all(search.results.map(r => r.data())); + + + document.querySelector('[data-url]').innerText = results.map(r => + r.url).sort().join(', '); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-url]"); + toolproof.assert_eq(val.innerHTML, `/cat/`); diff --git a/pagefind/integration_tests/edge_cases/pagefind-handles-non-breaking-spaces-in-segmented-language-pages.toolproof.yml b/pagefind/integration_tests/edge_cases/pagefind-handles-non-breaking-spaces-in-segmented-language-pages.toolproof.yml new file mode 100644 index 00000000..aac503de --- /dev/null +++ b/pagefind/integration_tests/edge_cases/pagefind-handles-non-breaking-spaces-in-segmented-language-pages.toolproof.yml @@ -0,0 +1,43 @@ +name: >- + Graceful Pagefind Errors > Pagefind handles non-breaking spaces in segmented + language pages +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.html" file with the content {html} + html: |- + + + +

Nothing

+ + + - step: I have a "public/ja/index.html" file with the content {html} + html: |- + + + +

Hello 👋

+ + + - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search("👋"); + + let results = await Promise.all(search.results.map(r => r.data())); + + + document.querySelector('[data-url]').innerText = results.map(r => + r.url).sort().join(', '); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-url]"); + toolproof.assert_eq(val.innerHTML, `/ja/`); diff --git a/pagefind/integration_tests/edge_cases/pagefind-multilingual-sub-results.toolproof.yml b/pagefind/integration_tests/edge_cases/pagefind-multilingual-sub-results.toolproof.yml new file mode 100644 index 00000000..6605b45a --- /dev/null +++ b/pagefind/integration_tests/edge_cases/pagefind-multilingual-sub-results.toolproof.yml @@ -0,0 +1,49 @@ +name: Graceful Pagefind Errors > Pagefind multilingual sub-results +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.html" file with the content {html} + html: |- + + + +

Nothing

+ + + - step: I have a "public/test/index.html" file with the content {html} + html: |- + + + +

چامه - آصف آشنا

+

هزار سال پس از ماجرای گمشدنت

+ +

RTL ID

+

از پیاله‌ای چای سیاه پررنگ

+ +

بیرون نه می‌روی از من

+

بیرون نه می‌روی از من

+ + + - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/pagefind/pagefind.js"); + + let search = await pagefind.search("از"); + let results = await Promise.all(search.results.map(r => r.data())); + let result = results[0]; + + let subs = result.sub_results.map(s => s.url).sort().join(', '); + + document.querySelector('[data-url]').innerText = subs; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: >- + let val = await toolproof.querySelector("[data-url]"); + + toolproof.assert_eq(val.innerHTML, `/test/#%D8%A7%D8%B2, /test/#_top, + /test/#rtl-content`); diff --git a/pagefind/integration_tests/exact_phrase/background.toolproof.yml b/pagefind/integration_tests/exact_phrase/background.toolproof.yml new file mode 100644 index 00000000..6af1cb23 --- /dev/null +++ b/pagefind/integration_tests/exact_phrase/background.toolproof.yml @@ -0,0 +1,10 @@ +name: exact_phrase > Exact Phrase Matching > Background +type: reference +steps: + - step: I have the environment variable "PAGEFIND_SITE" set to "public" + - step: I have a "public/index.html" file with the content {html} + html: >- +

Nothing

+ +

Nothing

diff --git a/pagefind/integration_tests/exact_phrase/exact-matches-will-be-discouraged-across-element-boundaries.toolproof.yml b/pagefind/integration_tests/exact_phrase/exact-matches-will-be-discouraged-across-element-boundaries.toolproof.yml new file mode 100644 index 00000000..fc4670b4 --- /dev/null +++ b/pagefind/integration_tests/exact_phrase/exact-matches-will-be-discouraged-across-element-boundaries.toolproof.yml @@ -0,0 +1,43 @@ +#TODO: This is an intentionally skipped test — add skipping to toolproof. + +type: reference +name: >- + Exact Phrase Matching > Exact matches will be discouraged across element + boundaries +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/catone/index.html" file with the content {html} + html: |- +

Happy post

+

about cats

+ - step: I have a "public/cattwo/index.html" file with the content {html} + html: >- +

Happy post about + cats

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search(`"post about"`); + + + document.querySelector('[data-count]').innerText = + `${search.results.length} result(s)`; + + let data = await search.results[0].data(); + + document.querySelector('[data-result]').innerText = data.url; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-count]"); + toolproof.assert_eq(val.innerHTML, `1 result(s)`); + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `/cattwo/`); diff --git a/pagefind/integration_tests/exact_phrase/searching-in-quotes-will-return-pages-with-exact-matches.toolproof.yml b/pagefind/integration_tests/exact_phrase/searching-in-quotes-will-return-pages-with-exact-matches.toolproof.yml new file mode 100644 index 00000000..6329c1c7 --- /dev/null +++ b/pagefind/integration_tests/exact_phrase/searching-in-quotes-will-return-pages-with-exact-matches.toolproof.yml @@ -0,0 +1,41 @@ +name: >- + Exact Phrase Matching > Searching in quotes will return pages with exact + matches +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/cat/index.html" file with the content {html} + html: >- +

Happy post about + cats

+ - step: I have a "public/dog/index.html" file with the content {html} + html: >- +

A post about how + cats do not like dogs

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search(`"about cats"`); + + + document.querySelector('[data-count]').innerText = + `${search.results.length} result(s)`; + + let data = await search.results[0]?.data(); + + document.querySelector('[data-result]').innerText = data?.url; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-count]"); + toolproof.assert_eq(val.innerHTML, `1 result(s)`); + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `/cat/`); diff --git a/pagefind/integration_tests/exclusions/background.toolproof.yml b/pagefind/integration_tests/exclusions/background.toolproof.yml new file mode 100644 index 00000000..24e7fda2 --- /dev/null +++ b/pagefind/integration_tests/exclusions/background.toolproof.yml @@ -0,0 +1,4 @@ +name: exclusions > Exclusions > Background +type: reference +steps: + - step: I have the environment variable "PAGEFIND_SITE" set to "public" diff --git a/pagefind/integration_tests/exclusions/custom-selectors-can-be-excluded-as-an-option.toolproof.yml b/pagefind/integration_tests/exclusions/custom-selectors-can-be-excluded-as-an-option.toolproof.yml new file mode 100644 index 00000000..9c9f85d8 --- /dev/null +++ b/pagefind/integration_tests/exclusions/custom-selectors-can-be-excluded-as-an-option.toolproof.yml @@ -0,0 +1,57 @@ +name: Exclusions > Custom selectors can be excluded as an option +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.html" file with the content {html} + html: |- +

+

+ - step: I have a "public/cat/index.html" file with the content {html} + html: >- +

Hello World, from + Pagefind

+ +
+

Goodbye World!

+
+ +
+
Hoorah!
+

Hooray!

🙂

+
+ - step: I have a "pagefind.yml" file with the content {yml} + yml: |- + exclude_selectors: + - '[id^="g"]' + - 'div > div' + - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let searchone = await pagefind.search("hello"); + + let searchonedata = await searchone.results[0].data(); + + document.querySelector('[data-search-one]').innerText = + searchonedata.content; + + + let searchtwo = await pagefind.search("goodbye"); + + document.querySelector('[data-search-two]').innerText = + `${searchtwo.results.length} result(s)`; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: >- + let val = await toolproof.querySelector("[data-search-one]"); + + toolproof.assert_eq(val.innerHTML, `Hello World, from Pagefind. Hooray! + 🙂`); + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-search-two]"); + toolproof.assert_eq(val.innerHTML, `0 result(s)`); diff --git a/pagefind/integration_tests/exclusions/elements-within-search-regions-can-be-excluded-from-indexing-and-excerpts.toolproof.yml b/pagefind/integration_tests/exclusions/elements-within-search-regions-can-be-excluded-from-indexing-and-excerpts.toolproof.yml new file mode 100644 index 00000000..8ba7e60d --- /dev/null +++ b/pagefind/integration_tests/exclusions/elements-within-search-regions-can-be-excluded-from-indexing-and-excerpts.toolproof.yml @@ -0,0 +1,53 @@ +name: >- + Exclusions > Elements within search regions can be excluded from indexing and + excerpts +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.html" file with the content {html} + html: >- +

Nothing

+ +

Nothing

+ - step: I have a "public/cat/index.html" file with the content {html} + html: >- +

Hello World, from + not Pagefind

+ +

Goodbye

+ +
+

Nested content

+
+ +

Huzzah!

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let searchone = await pagefind.search("hello"); + + let searchonedata = await searchone.results[0].data(); + + document.querySelector('[data-search-one]').innerText = + searchonedata.content; + + + let searchtwo = await pagefind.search("goodbye"); + + document.querySelector('[data-search-two]').innerText = + `${searchtwo.results.length} result(s)`; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-search-one]"); + toolproof.assert_eq(val.innerHTML, `Hello World, from Pagefind. Huzzah!`); + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-search-two]"); + toolproof.assert_eq(val.innerHTML, `0 result(s)`); diff --git a/pagefind/integration_tests/exclusions/some-elements-are-excluded-automatically.toolproof.yml b/pagefind/integration_tests/exclusions/some-elements-are-excluded-automatically.toolproof.yml new file mode 100644 index 00000000..c9f0a8a1 --- /dev/null +++ b/pagefind/integration_tests/exclusions/some-elements-are-excluded-automatically.toolproof.yml @@ -0,0 +1,56 @@ +name: Exclusions > Some elements are excluded automatically +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.html" file with the content {html} + html: |- +

+

+ - step: I have a "public/cat/index.html" file with the content {html} + html: >- +

Hello World, from + Pagefind

+ + + + goodbye + +
+ +
+ +

Hooray!

+ + + - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let searchone = await pagefind.search("hello"); + + let searchonedata = await searchone.results[0].data(); + + document.querySelector('[data-search-one]').innerText = + searchonedata.content; + + + let searchtwo = await pagefind.search("goodbye"); + + document.querySelector('[data-search-two]').innerText = + `${searchtwo.results.length} result(s)`; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-search-one]"); + toolproof.assert_eq(val.innerHTML, `Hello World, from Pagefind. Hooray!`); + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-search-two]"); + toolproof.assert_eq(val.innerHTML, `0 result(s)`); diff --git a/pagefind/integration_tests/exclusions/tagged-elements-inside-ignored-elements-can-be-ignored.toolproof.yml b/pagefind/integration_tests/exclusions/tagged-elements-inside-ignored-elements-can-be-ignored.toolproof.yml new file mode 100644 index 00000000..1bb95819 --- /dev/null +++ b/pagefind/integration_tests/exclusions/tagged-elements-inside-ignored-elements-can-be-ignored.toolproof.yml @@ -0,0 +1,45 @@ +name: Exclusions > Tagged elements inside ignored elements can be ignored +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.html" file with the content {html} + html: >- +

Nothing

+ - step: I have a "public/cat/index.html" file with the content {html} + html: >- +

Hello World, from + Pagefind

+ +
+

Nested content

+
+ +
+

Nested content

+
+ +
+

Nested content

+
+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/pagefind/pagefind.js"); + + let search = await pagefind.search("hello"); + let searchdata = await search.results[0].data(); + document.querySelector('[data-search]').innerText = [ + searchdata.meta?.elided || "None", + searchdata.meta?.index || "None", + searchdata.meta?.all || "None", + ].join(' — '); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: >- + let val = await toolproof.querySelector("[data-search]"); + + toolproof.assert_eq(val.innerHTML, `Nested content — Nested content — + None`); diff --git a/pagefind/integration_tests/filtering/all-results-are-returned-with-no-filters.toolproof.yml b/pagefind/integration_tests/filtering/all-results-are-returned-with-no-filters.toolproof.yml new file mode 100644 index 00000000..fb8be7bd --- /dev/null +++ b/pagefind/integration_tests/filtering/all-results-are-returned-with-no-filters.toolproof.yml @@ -0,0 +1,20 @@ +name: Filtering > All results are returned with no filters +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search("Cat"); + + let data = await Promise.all(search.results.map(result => result.data())); + + + document.querySelector('[data-results]').innerText = data.map(d => + d.url).sort().join(', '); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-results]"); + toolproof.assert_eq(val.innerHTML, `/ali/, /cheeka/, /theodore/`); diff --git a/pagefind/integration_tests/filtering/background.toolproof.yml b/pagefind/integration_tests/filtering/background.toolproof.yml new file mode 100644 index 00000000..0e8c8298 --- /dev/null +++ b/pagefind/integration_tests/filtering/background.toolproof.yml @@ -0,0 +1,32 @@ +name: filtering > Filtering > Background +type: reference +steps: + - step: I have the environment variable "PAGEFIND_SITE" set to "public" + - step: I have a "public/index.html" file with the content {html} + html: >- +

Nothing

+ - step: I have a "public/cheeka/index.html" file with the content {html} + html: >- + Black + + White + +

Cat

+ - step: I have a "public/theodore/index.html" file with the content {html} + html: >- + Orange + +

Cat

+ - step: I have a "public/ali/index.html" file with the content {html} + html: >- + Angry + +

Ali Cat

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: I serve the directory "public" + - step: In my browser, I load "/" diff --git a/pagefind/integration_tests/filtering/filter-counts-are-returned-for-a-given-search-term.toolproof.yml b/pagefind/integration_tests/filtering/filter-counts-are-returned-for-a-given-search-term.toolproof.yml new file mode 100644 index 00000000..3335bdca --- /dev/null +++ b/pagefind/integration_tests/filtering/filter-counts-are-returned-for-a-given-search-term.toolproof.yml @@ -0,0 +1,24 @@ +name: Filtering > Filter counts are returned for a given search term +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/pagefind/pagefind.js"); + + await pagefind.filters(); // Load filters + let search = await pagefind.search("Ali"); + let strings = Object.entries(search.filters).map(([filter, values]) => { + values = Object.entries(values).map(([value, count]) => { + return `${value}(${count})`; + }) + return `${filter}:[${values.join(", ")}]`; + }); + + document.querySelector('[data-results]').innerText = strings.join(' '); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: >- + let val = await toolproof.querySelector("[data-results]"); + + toolproof.assert_eq(val.innerHTML, `color:[Black(0), Orange(0), Tabby(1), + White(0)] mood:[Angry(1)]`); diff --git a/pagefind/integration_tests/filtering/filtering-on-a-search-term-with-no-results-returns-nothing.toolproof.yml b/pagefind/integration_tests/filtering/filtering-on-a-search-term-with-no-results-returns-nothing.toolproof.yml new file mode 100644 index 00000000..f535cf02 --- /dev/null +++ b/pagefind/integration_tests/filtering/filtering-on-a-search-term-with-no-results-returns-nothing.toolproof.yml @@ -0,0 +1,22 @@ +name: Filtering > Filtering on a search term with no results returns nothing +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search("Pontification", { + filters: { + color: "Orange" + } + }); + + + document.querySelector('[data-results]').innerText = + search.results.length; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-results]"); + toolproof.assert_eq(val.innerHTML, `0`); diff --git a/pagefind/integration_tests/filtering/filtering-on-tagged-elements.toolproof.yml b/pagefind/integration_tests/filtering/filtering-on-tagged-elements.toolproof.yml new file mode 100644 index 00000000..1af1be9e --- /dev/null +++ b/pagefind/integration_tests/filtering/filtering-on-tagged-elements.toolproof.yml @@ -0,0 +1,24 @@ +name: Filtering > Filtering on tagged elements +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search("Cat", { + filters: { + color: "Orange" + } + }); + + let data = await Promise.all(search.results.map(result => result.data())); + + + document.querySelector('[data-results]').innerText = data.map(d => + d.url).sort().join(', '); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-results]"); + toolproof.assert_eq(val.innerHTML, `/theodore/`); diff --git a/pagefind/integration_tests/filtering/filtering-on-tagged-values.toolproof.yml b/pagefind/integration_tests/filtering/filtering-on-tagged-values.toolproof.yml new file mode 100644 index 00000000..840cf46a --- /dev/null +++ b/pagefind/integration_tests/filtering/filtering-on-tagged-values.toolproof.yml @@ -0,0 +1,24 @@ +name: Filtering > Filtering on tagged values +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search("Cat", { + filters: { + color: "Tabby" + } + }); + + let data = await Promise.all(search.results.map(result => result.data())); + + + document.querySelector('[data-results]').innerText = data.map(d => + d.url).sort().join(', '); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-results]"); + toolproof.assert_eq(val.innerHTML, `/ali/`); diff --git a/pagefind/integration_tests/filtering/filtering-returns-multiple-results.toolproof.yml b/pagefind/integration_tests/filtering/filtering-returns-multiple-results.toolproof.yml new file mode 100644 index 00000000..b53a48d4 --- /dev/null +++ b/pagefind/integration_tests/filtering/filtering-returns-multiple-results.toolproof.yml @@ -0,0 +1,24 @@ +name: Filtering > Filtering returns multiple results +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search("Cat", { + filters: { + color: "White" + } + }); + + let data = await Promise.all(search.results.map(result => result.data())); + + + document.querySelector('[data-results]').innerText = data.map(d => + d.url).sort().join(', '); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-results]"); + toolproof.assert_eq(val.innerHTML, `/cheeka/, /theodore/`); diff --git a/pagefind/integration_tests/filtering/filtering-with-an--empty--bogus-filter-does-nothing.toolproof.yml b/pagefind/integration_tests/filtering/filtering-with-an--empty--bogus-filter-does-nothing.toolproof.yml new file mode 100644 index 00000000..ba5a44e8 --- /dev/null +++ b/pagefind/integration_tests/filtering/filtering-with-an--empty--bogus-filter-does-nothing.toolproof.yml @@ -0,0 +1,24 @@ +name: Filtering > Filtering with an _empty_ bogus filter does nothing +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search("Cat", { + filters: { + something_nonexistent: [] + } + }); + + let data = await Promise.all(search.results.map(result => result.data())); + + + document.querySelector('[data-results]').innerText = data.map(d => + d.url).sort().join(', '); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-results]"); + toolproof.assert_eq(val.innerHTML, `/ali/, /cheeka/, /theodore/`); diff --git a/pagefind/integration_tests/filtering/filtering-with-an-empty-array-returns-all-results.toolproof.yml b/pagefind/integration_tests/filtering/filtering-with-an-empty-array-returns-all-results.toolproof.yml new file mode 100644 index 00000000..23f4a15e --- /dev/null +++ b/pagefind/integration_tests/filtering/filtering-with-an-empty-array-returns-all-results.toolproof.yml @@ -0,0 +1,24 @@ +name: Filtering > Filtering with an empty array returns all results +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search("Cat", { + filters: { + color: [] + } + }); + + let data = await Promise.all(search.results.map(result => result.data())); + + + document.querySelector('[data-results]').innerText = data.map(d => + d.url).sort().join(', '); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-results]"); + toolproof.assert_eq(val.innerHTML, `/ali/, /cheeka/, /theodore/`); diff --git a/pagefind/integration_tests/filtering/filtering-without-search-term-returns-an-unprocessed-excerpt.toolproof.yml b/pagefind/integration_tests/filtering/filtering-without-search-term-returns-an-unprocessed-excerpt.toolproof.yml new file mode 100644 index 00000000..b72189ab --- /dev/null +++ b/pagefind/integration_tests/filtering/filtering-without-search-term-returns-an-unprocessed-excerpt.toolproof.yml @@ -0,0 +1,29 @@ +name: Filtering > Filtering without search term returns an unprocessed excerpt +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + // Run a search so that some index words are loaded + + let unused = await pagefind.search("cat"); + + + let search = await pagefind.search(null, { + filters: { + color: ["Black", "White"] + } + }); + + let data = await Promise.all(search.results.map(result => result.data())); + + + document.querySelector('[data-results]').innerText = data.map(d => + d.excerpt).join(', '); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-results]"); + toolproof.assert_eq(val.innerHTML, `Black White Cat.`); diff --git a/pagefind/integration_tests/filtering/filtering-without-search-term-returns-only-filter.toolproof.yml b/pagefind/integration_tests/filtering/filtering-without-search-term-returns-only-filter.toolproof.yml new file mode 100644 index 00000000..8a669806 --- /dev/null +++ b/pagefind/integration_tests/filtering/filtering-without-search-term-returns-only-filter.toolproof.yml @@ -0,0 +1,24 @@ +name: Filtering > Filtering without search term returns only filter +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search(null, { + filters: { + color: "White" + } + }); + + let data = await Promise.all(search.results.map(result => result.data())); + + + document.querySelector('[data-results]').innerText = data.map(d => + d.url).sort().join(', '); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-results]"); + toolproof.assert_eq(val.innerHTML, `/cheeka/, /theodore/`); diff --git a/pagefind/integration_tests/filtering/filters-can-be-retrieved.toolproof.yml b/pagefind/integration_tests/filtering/filters-can-be-retrieved.toolproof.yml new file mode 100644 index 00000000..319324b3 --- /dev/null +++ b/pagefind/integration_tests/filtering/filters-can-be-retrieved.toolproof.yml @@ -0,0 +1,23 @@ +name: Filtering > Filters can be retrieved +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/pagefind/pagefind.js"); + + let filters = await pagefind.filters(); + let strings = Object.entries(filters).map(([filter, values]) => { + values = Object.entries(values).map(([value, count]) => { + return `${value}(${count})`; + }) + return `${filter}:[${values.join(", ")}]`; + }); + + document.querySelector('[data-results]').innerText = strings.join(' '); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: >- + let val = await toolproof.querySelector("[data-results]"); + + toolproof.assert_eq(val.innerHTML, `color:[Black(1), Orange(1), Tabby(1), + White(2)] mood:[Angry(1)]`); diff --git a/pagefind/integration_tests/filtering/non-existent-filters-return-no-results.toolproof.yml b/pagefind/integration_tests/filtering/non-existent-filters-return-no-results.toolproof.yml new file mode 100644 index 00000000..1b5d1b53 --- /dev/null +++ b/pagefind/integration_tests/filtering/non-existent-filters-return-no-results.toolproof.yml @@ -0,0 +1,22 @@ +name: Filtering > Non-existent filters return no results +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search("Cat", { + filters: { + name: "Ali" + } + }); + + + document.querySelector('[data-results]').innerText = + search.results.length; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-results]"); + toolproof.assert_eq(val.innerHTML, `0`); diff --git a/pagefind/integration_tests/filtering/non-existent-values-return-no-results.toolproof.yml b/pagefind/integration_tests/filtering/non-existent-values-return-no-results.toolproof.yml new file mode 100644 index 00000000..0ec6c0cd --- /dev/null +++ b/pagefind/integration_tests/filtering/non-existent-values-return-no-results.toolproof.yml @@ -0,0 +1,22 @@ +name: Filtering > Non-existent values return no results +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search("Cat", { + filters: { + color: "Green" + } + }); + + + document.querySelector('[data-results]').innerText = + search.results.length; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-results]"); + toolproof.assert_eq(val.innerHTML, `0`); diff --git a/pagefind/integration_tests/filtering/total-filter-counts-are-returned-for-a-given-search-term.toolproof.yml b/pagefind/integration_tests/filtering/total-filter-counts-are-returned-for-a-given-search-term.toolproof.yml new file mode 100644 index 00000000..1937bd56 --- /dev/null +++ b/pagefind/integration_tests/filtering/total-filter-counts-are-returned-for-a-given-search-term.toolproof.yml @@ -0,0 +1,33 @@ +name: Filtering > Total filter counts are returned for a given search term +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + await pagefind.filters(); // Load filters + + let search = await pagefind.search("Cat", { + filters: { + color: "White" + } + }); + + let strings = Object.entries(search.totalFilters).map(([filter, values]) + => { + values = Object.entries(values).map(([value, count]) => { + return `${value}(${count})`; + }) + return `${filter}:[${values.join(", ")}]`; + }); + + + document.querySelector('[data-results]').innerText = strings.join(' '); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: >- + let val = await toolproof.querySelector("[data-results]"); + + toolproof.assert_eq(val.innerHTML, `color:[Black(1), Orange(1), Tabby(1), + White(2)] mood:[Angry(1)]`); diff --git a/pagefind/integration_tests/filtering/total-unfiltered-result-counts-are-given-for-a-filtered-search-term.toolproof.yml b/pagefind/integration_tests/filtering/total-unfiltered-result-counts-are-given-for-a-filtered-search-term.toolproof.yml new file mode 100644 index 00000000..49c4a423 --- /dev/null +++ b/pagefind/integration_tests/filtering/total-unfiltered-result-counts-are-given-for-a-filtered-search-term.toolproof.yml @@ -0,0 +1,25 @@ +name: >- + Filtering > Total unfiltered result counts are given for a filtered search + term +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + await pagefind.filters(); // Load filters + + let search = await pagefind.search("Ali", { + filters: { + color: "Orange" + } + }); + + document.querySelector('[data-results]').innerText = + `results:${search.results.length} total:${search.unfilteredResultCount}`; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-results]"); + toolproof.assert_eq(val.innerHTML, `results:0 total:1`); diff --git a/pagefind/integration_tests/frozen-pre-1.0/base/background.toolproof.yml b/pagefind/integration_tests/frozen-pre-1.0/base/background.toolproof.yml new file mode 100644 index 00000000..018c1609 --- /dev/null +++ b/pagefind/integration_tests/frozen-pre-1.0/base/background.toolproof.yml @@ -0,0 +1,8 @@ +name: frozen-pre-1.0/base > Base Tests > Background +type: reference +steps: + - step: I have the environment variable "PAGEFIND_SOURCE" set to "public" + - step: I have a "public/index.html" file with the content {html} + html: >- +

Nothing

diff --git a/pagefind/integration_tests/frozen-pre-1.0/base/legacy-preload-indexes-then-search-for-a-word.toolproof.yml b/pagefind/integration_tests/frozen-pre-1.0/base/legacy-preload-indexes-then-search-for-a-word.toolproof.yml new file mode 100644 index 00000000..57530eda --- /dev/null +++ b/pagefind/integration_tests/frozen-pre-1.0/base/legacy-preload-indexes-then-search-for-a-word.toolproof.yml @@ -0,0 +1,29 @@ +name: Base Tests > LEGACY Preload indexes then search for a word +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/cat/index.html" file with the content {html} + html: >- + + +

world

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: stderr should contain "pre-1.0 compatibility mode" + - step: The file "public/_pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/_pagefind/pagefind.js"); + + await pagefind.preload("wo"); + let search = await pagefind.search("world"); + + let data = await search.results[0].data(); + document.querySelector('[data-url]').innerText = data.url; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-url]"); + toolproof.assert_eq(val.innerHTML, `/cat/`); diff --git a/pagefind/integration_tests/frozen-pre-1.0/base/legacy-search-for-a-word.toolproof.yml b/pagefind/integration_tests/frozen-pre-1.0/base/legacy-search-for-a-word.toolproof.yml new file mode 100644 index 00000000..27485c57 --- /dev/null +++ b/pagefind/integration_tests/frozen-pre-1.0/base/legacy-search-for-a-word.toolproof.yml @@ -0,0 +1,28 @@ +name: Base Tests > LEGACY Search for a word +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/cat/index.html" file with the content {html} + html: >- + + +

world

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: stderr should contain "pre-1.0 compatibility mode" + - step: The file "public/_pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/_pagefind/pagefind.js"); + + let search = await pagefind.search("world"); + + let data = await search.results[0].data(); + document.querySelector('[data-url]').innerText = data.url; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-url]"); + toolproof.assert_eq(val.innerHTML, `/cat/`); diff --git a/pagefind/integration_tests/frozen-pre-1.0/build_options/background.toolproof.yml b/pagefind/integration_tests/frozen-pre-1.0/build_options/background.toolproof.yml new file mode 100644 index 00000000..2ec4c639 --- /dev/null +++ b/pagefind/integration_tests/frozen-pre-1.0/build_options/background.toolproof.yml @@ -0,0 +1,4 @@ +name: frozen-pre-1.0/build_options > Build Options > Background +type: reference +steps: + - step: I have the environment variable "PAGEFIND_SOURCE" set to "public" diff --git a/pagefind/integration_tests/frozen-pre-1.0/build_options/legacy-complex-exclusionary-file-glob-can-be-configured.toolproof.yml b/pagefind/integration_tests/frozen-pre-1.0/build_options/legacy-complex-exclusionary-file-glob-can-be-configured.toolproof.yml new file mode 100644 index 00000000..4be103f2 --- /dev/null +++ b/pagefind/integration_tests/frozen-pre-1.0/build_options/legacy-complex-exclusionary-file-glob-can-be-configured.toolproof.yml @@ -0,0 +1,52 @@ +name: Build Options > LEGACY Complex exclusionary file glob can be configured +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.html" file with the content {html} + html: >- +

Nothing

+ - step: I have a "public/cat/index.htm" file with the content {htm} + htm: >- + + +

cat index

+ - step: I have a "public/cat/cat.html" file with the content {html} + html: >- +

cat + cat

+ - step: I have a "public/kitty/cat/index.html" file with the content {html} + html: >- +

kitty cat + index

+ - step: I have a "public/cat.html" file with the content {html} + html: >- +

cat

+ - step: I have a "pagefind.yml" file with the content {yml} + yml: 'glob: "{cat/index.htm,kitty/**/*.html,cat.html}"' + - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: stderr should contain "pre-1.0 compatibility mode" + - step: The file "public/_pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/_pagefind/pagefind.js"); + + + let search = await pagefind.search("cat"); + + + let pages = await Promise.all(search.results.map(r => r.data())); + + document.querySelector('[data-result]').innerText = pages.map(p => + p.url).sort().join(", "); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: >- + let val = await toolproof.querySelector("[data-result]"); + + toolproof.assert_eq(val.innerHTML, `/cat.html, /cat/index.htm, + /kitty/cat/`); diff --git a/pagefind/integration_tests/frozen-pre-1.0/build_options/legacy-file-glob-can-be-configured.toolproof.yml b/pagefind/integration_tests/frozen-pre-1.0/build_options/legacy-file-glob-can-be-configured.toolproof.yml new file mode 100644 index 00000000..e300cbf4 --- /dev/null +++ b/pagefind/integration_tests/frozen-pre-1.0/build_options/legacy-file-glob-can-be-configured.toolproof.yml @@ -0,0 +1,34 @@ +name: Build Options > LEGACY File glob can be configured +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.html" file with the content {html} + html: >- + + +

Nothing

+ - step: I have a "public/cat/index.htm" file with the content {htm} + htm: >- +

world

+ - step: I have a "pagefind.yml" file with the content {yml} + yml: 'glob: "**/*.{htm,html}"' + - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: stderr should contain "pre-1.0 compatibility mode" + - step: The file "public/_pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/_pagefind/pagefind.js"); + + let search = await pagefind.search("world"); + + let data = await search.results[0].data(); + document.querySelector('[data-url]').innerText = data.url; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-url]"); + toolproof.assert_eq(val.innerHTML, `/cat/index.htm`); diff --git a/pagefind/integration_tests/frozen-pre-1.0/build_options/legacy-output-path-can-be-configured-with-an-absolute-path.toolproof.yml b/pagefind/integration_tests/frozen-pre-1.0/build_options/legacy-output-path-can-be-configured-with-an-absolute-path.toolproof.yml new file mode 100644 index 00000000..4589ea3a --- /dev/null +++ b/pagefind/integration_tests/frozen-pre-1.0/build_options/legacy-output-path-can-be-configured-with-an-absolute-path.toolproof.yml @@ -0,0 +1,36 @@ +#TODO: This is a broken test that needs to be fixed. + +type: reference +name: Build Options > LEGACY Output path can be configured with an absolute path +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.html" file with the content {html} + html: >- + + +

Nothing

+ - step: I have a "public/cat/index.html" file with the content {html} + html: >- +

world

+ - step: >- + I run "%pagefind_exec_path% --bundle-dir + %todo_toolproof_dir_abs_path%/other/_search" + - step: stdout should contain "Running Pagefind" + - step: The file "other/_search/pagefind.js" should not be empty + - step: I serve the directory "." + - step: In my browser, I load "/public/" + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/other/_search/pagefind.js"); + + let search = await pagefind.search("world"); + + let data = await search.results[0].data(); + document.querySelector('[data-url]').innerText = data.url; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-url]"); + toolproof.assert_eq(val.innerHTML, `/cat/`); diff --git a/pagefind/integration_tests/frozen-pre-1.0/build_options/legacy-output-path-can-be-configured.toolproof.yml b/pagefind/integration_tests/frozen-pre-1.0/build_options/legacy-output-path-can-be-configured.toolproof.yml new file mode 100644 index 00000000..7098e291 --- /dev/null +++ b/pagefind/integration_tests/frozen-pre-1.0/build_options/legacy-output-path-can-be-configured.toolproof.yml @@ -0,0 +1,31 @@ +name: Build Options > LEGACY Output path can be configured +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.html" file with the content {html} + html: >- + + +

Nothing

+ - step: I have a "public/cat/index.html" file with the content {html} + html: >- +

world

+ - step: I run "%pagefind_exec_path% --bundle-dir _search" + - step: stdout should contain "Running Pagefind" + - step: The file "public/_search/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/_search/pagefind.js"); + + let search = await pagefind.search("world"); + + let data = await search.results[0].data(); + document.querySelector('[data-url]').innerText = data.url; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-url]"); + toolproof.assert_eq(val.innerHTML, `/cat/`); diff --git a/pagefind/integration_tests/frozen-pre-1.0/build_options/legacy-root-selector-can-be-configured.toolproof.yml b/pagefind/integration_tests/frozen-pre-1.0/build_options/legacy-root-selector-can-be-configured.toolproof.yml new file mode 100644 index 00000000..44742a9b --- /dev/null +++ b/pagefind/integration_tests/frozen-pre-1.0/build_options/legacy-root-selector-can-be-configured.toolproof.yml @@ -0,0 +1,39 @@ +name: Build Options > LEGACY Root selector can be configured +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.html" file with the content {html} + html: >- + + +

Nothing

+ - step: I have a "public/cat/index.html" file with the content {html} + html: |- +

Ignored

+
+

Hello

+
+

Also ignored

+ - step: I run "%pagefind_exec_path% --root-selector 'body > .content'" + - step: stdout should contain "Running Pagefind" + - step: stderr should contain "pre-1.0 compatibility mode" + - step: The file "public/_pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/_pagefind/pagefind.js"); + + + let search = await pagefind.search("hello"); + + + let data = await search.results[0].data(); + + document.querySelector('[data-url]').innerText = `${data.meta.title}, + ${data.content} Ignored is ${data.meta.ignored}.`; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-url]"); + toolproof.assert_eq(val.innerHTML, `Hello, Hello. Ignored is undefined.`); diff --git a/pagefind/integration_tests/frozen-pre-1.0/build_options/legacy-source-folder-can-be-configured.toolproof.yml b/pagefind/integration_tests/frozen-pre-1.0/build_options/legacy-source-folder-can-be-configured.toolproof.yml new file mode 100644 index 00000000..04ca6bf5 --- /dev/null +++ b/pagefind/integration_tests/frozen-pre-1.0/build_options/legacy-source-folder-can-be-configured.toolproof.yml @@ -0,0 +1,32 @@ +name: Build Options > LEGACY Source folder can be configured +steps: + - ref: ./background.toolproof.yml + - step: I have a "my_website/index.html" file with the content {html} + html: >- + + +

Nothing

+ - step: I have a "my_website/cat/index.html" file with the content {html} + html: >- +

world

+ - step: I run "%pagefind_exec_path% --source my_website" + - step: stdout should contain "Running Pagefind" + - step: stderr should contain "pre-1.0 compatibility mode" + - step: The file "my_website/_pagefind/pagefind.js" should not be empty + - step: I serve the directory "my_website" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/_pagefind/pagefind.js"); + + let search = await pagefind.search("world"); + + let data = await search.results[0].data(); + document.querySelector('[data-url]').innerText = data.url; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-url]"); + toolproof.assert_eq(val.innerHTML, `/cat/`); diff --git a/pagefind/integration_tests/frozen-pre-1.0/config_sources/legacy-settings-can-be-pulled-from-command-line-flags.toolproof.yml b/pagefind/integration_tests/frozen-pre-1.0/config_sources/legacy-settings-can-be-pulled-from-command-line-flags.toolproof.yml new file mode 100644 index 00000000..da6f9e65 --- /dev/null +++ b/pagefind/integration_tests/frozen-pre-1.0/config_sources/legacy-settings-can-be-pulled-from-command-line-flags.toolproof.yml @@ -0,0 +1,12 @@ +name: Config Sources > LEGACY Settings can be pulled from command-line flags +steps: + - step: I have a "public/index.html" file with the content {html} + html: >- + + +

Hello.

+ - step: I run "%pagefind_exec_path% --source public" + - step: stdout should contain "Running Pagefind" + - step: stderr should contain "pre-1.0 compatibility mode" + - step: The file "public/_pagefind/pagefind.js" should not be empty diff --git a/pagefind/integration_tests/frozen-pre-1.0/config_sources/legacy-settings-can-be-pulled-from-environment-variables.toolproof.yml b/pagefind/integration_tests/frozen-pre-1.0/config_sources/legacy-settings-can-be-pulled-from-environment-variables.toolproof.yml new file mode 100644 index 00000000..e4cd6b49 --- /dev/null +++ b/pagefind/integration_tests/frozen-pre-1.0/config_sources/legacy-settings-can-be-pulled-from-environment-variables.toolproof.yml @@ -0,0 +1,13 @@ +name: Config Sources > LEGACY Settings can be pulled from environment variables +steps: + - step: I have a "public/index.html" file with the content {html} + html: >- + + +

Hello.

+ - step: I have the environment variable "PAGEFIND_SOURCE" set to "public" + - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: stderr should contain "pre-1.0 compatibility mode" + - step: The file "public/_pagefind/pagefind.js" should not be empty diff --git a/pagefind/integration_tests/frozen-pre-1.0/config_sources/legacy-settings-can-be-pulled-from-json-configuration-files.toolproof.yml b/pagefind/integration_tests/frozen-pre-1.0/config_sources/legacy-settings-can-be-pulled-from-json-configuration-files.toolproof.yml new file mode 100644 index 00000000..6d19aaf6 --- /dev/null +++ b/pagefind/integration_tests/frozen-pre-1.0/config_sources/legacy-settings-can-be-pulled-from-json-configuration-files.toolproof.yml @@ -0,0 +1,17 @@ +name: Config Sources > LEGACY Settings can be pulled from JSON configuration files +steps: + - step: I have a "public/index.html" file with the content {html} + html: >- + + +

Hello.

+ - step: I have a "pagefind.json" file with the content {json} + json: |- + { + "source": "public" + } + - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: stderr should contain "pre-1.0 compatibility mode" + - step: The file "public/_pagefind/pagefind.js" should not be empty diff --git a/pagefind/integration_tests/frozen-pre-1.0/config_sources/legacy-settings-can-be-pulled-from-multiple-sources.toolproof.yml b/pagefind/integration_tests/frozen-pre-1.0/config_sources/legacy-settings-can-be-pulled-from-multiple-sources.toolproof.yml new file mode 100644 index 00000000..8f03f313 --- /dev/null +++ b/pagefind/integration_tests/frozen-pre-1.0/config_sources/legacy-settings-can-be-pulled-from-multiple-sources.toolproof.yml @@ -0,0 +1,16 @@ +name: Config Sources > LEGACY Settings can be pulled from multiple sources +steps: + - step: I have a "public/index.html" file with the content {html} + html: >- + + +

Hello.

+ - step: I have a "pagefind.json" file with the content {json} + json: |- + { + "source": "public" + } + - step: I run "%pagefind_exec_path% --bundle-dir _out" + - step: stdout should contain "Running Pagefind" + - step: The file "public/_out/pagefind.js" should not be empty diff --git a/pagefind/integration_tests/frozen-pre-1.0/config_sources/legacy-settings-can-be-pulled-from-toml-configuration-files.toolproof.yml b/pagefind/integration_tests/frozen-pre-1.0/config_sources/legacy-settings-can-be-pulled-from-toml-configuration-files.toolproof.yml new file mode 100644 index 00000000..241e3b2d --- /dev/null +++ b/pagefind/integration_tests/frozen-pre-1.0/config_sources/legacy-settings-can-be-pulled-from-toml-configuration-files.toolproof.yml @@ -0,0 +1,14 @@ +name: Config Sources > LEGACY Settings can be pulled from TOML configuration files +steps: + - step: I have a "public/index.html" file with the content {html} + html: >- + + +

Hello.

+ - step: I have a "pagefind.toml" file with the content {toml} + toml: source = "public" + - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: stderr should contain "pre-1.0 compatibility mode" + - step: The file "public/_pagefind/pagefind.js" should not be empty diff --git a/pagefind/integration_tests/frozen-pre-1.0/config_sources/legacy-settings-can-be-pulled-from-yaml-configuration-files.toolproof.yml b/pagefind/integration_tests/frozen-pre-1.0/config_sources/legacy-settings-can-be-pulled-from-yaml-configuration-files.toolproof.yml new file mode 100644 index 00000000..96cbec4b --- /dev/null +++ b/pagefind/integration_tests/frozen-pre-1.0/config_sources/legacy-settings-can-be-pulled-from-yaml-configuration-files.toolproof.yml @@ -0,0 +1,14 @@ +name: Config Sources > LEGACY Settings can be pulled from YAML configuration files +steps: + - step: I have a "public/index.html" file with the content {html} + html: >- + + +

Hello.

+ - step: I have a "pagefind.yml" file with the content {yml} + yml: 'source: public' + - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: stderr should contain "pre-1.0 compatibility mode" + - step: The file "public/_pagefind/pagefind.js" should not be empty diff --git a/pagefind/integration_tests/frozen-pre-1.0/modular_ui/modular_ui_base/background.toolproof.yml b/pagefind/integration_tests/frozen-pre-1.0/modular_ui/modular_ui_base/background.toolproof.yml new file mode 100644 index 00000000..7a3d0569 --- /dev/null +++ b/pagefind/integration_tests/frozen-pre-1.0/modular_ui/modular_ui_base/background.toolproof.yml @@ -0,0 +1,23 @@ +name: frozen-pre-1.0/modular_ui/modular_ui_base > Base Modular UI Tests > Background +type: reference +steps: + - step: I have the environment variable "PAGEFIND_SOURCE" set to "public" + - step: I have a "public/index.html" file with the content {html} + html: |- + +
+
+ + + diff --git a/pagefind/integration_tests/frozen-pre-1.0/modular_ui/modular_ui_base/legacy-pagefind-modular-ui-loads.toolproof.yml b/pagefind/integration_tests/frozen-pre-1.0/modular_ui/modular_ui_base/legacy-pagefind-modular-ui-loads.toolproof.yml new file mode 100644 index 00000000..55d750f6 --- /dev/null +++ b/pagefind/integration_tests/frozen-pre-1.0/modular_ui/modular_ui_base/legacy-pagefind-modular-ui-loads.toolproof.yml @@ -0,0 +1,18 @@ +name: Base Modular UI Tests > LEGACY Pagefind Modular UI loads +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/cat/index.html" file with the content {html} + html: >- +

world

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: stderr should contain "pre-1.0 compatibility mode" + - step: The file "public/_pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let el = await toolproof.querySelector("#search input"); + toolproof.assert(el); diff --git a/pagefind/integration_tests/frozen-pre-1.0/modular_ui/modular_ui_base/legacy-pagefind-modular-ui-searches.toolproof.yml b/pagefind/integration_tests/frozen-pre-1.0/modular_ui/modular_ui_base/legacy-pagefind-modular-ui-searches.toolproof.yml new file mode 100644 index 00000000..4bc80891 --- /dev/null +++ b/pagefind/integration_tests/frozen-pre-1.0/modular_ui/modular_ui_base/legacy-pagefind-modular-ui-searches.toolproof.yml @@ -0,0 +1,23 @@ +name: Base Modular UI Tests > LEGACY Pagefind Modular UI searches +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/cat/index.html" file with the content {html} + html: >- +

world

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: stderr should contain "pre-1.0 compatibility mode" + - step: The file "public/_pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: |- + let e = new Event('input', {bubbles:true, cancelable:true}); + document.querySelector("#search input").value = "world"; + document.querySelector("#search input").dispatchEvent(e); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector(".pagefind-modular-list-link"); + toolproof.assert_eq(val.innerHTML, `world`); diff --git a/pagefind/integration_tests/frozen-pre-1.0/multilingual/background.toolproof.yml b/pagefind/integration_tests/frozen-pre-1.0/multilingual/background.toolproof.yml new file mode 100644 index 00000000..88b3d3cf --- /dev/null +++ b/pagefind/integration_tests/frozen-pre-1.0/multilingual/background.toolproof.yml @@ -0,0 +1,27 @@ +name: frozen-pre-1.0/multilingual > Multilingual > Background +type: reference +steps: + - step: I have the environment variable "PAGEFIND_SOURCE" set to "public" + - step: I have a "public/en/index.html" file with the content {html} + html: |- + + + + Document + + + +

I am some English documentation

+ + + - step: I have a "public/pt-br/index.html" file with the content {html} + html: |- + + + + Document + + +

I am a Portuguese document (trust me — quilométricas — see?)

+ + diff --git a/pagefind/integration_tests/frozen-pre-1.0/multilingual/legacy-pagefind-can-be-configured-to-lump-all-languages-together.toolproof.yml b/pagefind/integration_tests/frozen-pre-1.0/multilingual/legacy-pagefind-can-be-configured-to-lump-all-languages-together.toolproof.yml new file mode 100644 index 00000000..81f8160b --- /dev/null +++ b/pagefind/integration_tests/frozen-pre-1.0/multilingual/legacy-pagefind-can-be-configured-to-lump-all-languages-together.toolproof.yml @@ -0,0 +1,45 @@ +name: >- + Multilingual > LEGACY Pagefind can be configured to lump all languages + together +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.html" file with the content {html} + html: |- + + + + Document + + +

Nothing

+ + + - step: I run "%pagefind_exec_path% --force-language 'en'" + - step: stdout should contain "Running Pagefind" + - step: stderr should contain "pre-1.0 compatibility mode" + - step: The file "public/_pagefind/pagefind.js" should not be empty + - step: I run "ls -lh public/_pagefind/wasm.unknown.pagefind" + notes: 'TODO: Build a file existence check into toolproof' + - step: I run "ls -lh public/_pagefind/wasm.en.pagefind" + notes: 'TODO: Build a file existence check into toolproof' + - step: I run "ls -lh public/_pagefind/wasm.pt-br.pagefind" and expect it to fail + notes: 'TODO: Build a file existence check into toolproof' + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/_pagefind/pagefind.js"); + + + let search = await pagefind.search("documenting"); + + + let data = await Promise.all(search.results.map(result => result.data())); + + document.querySelector('[data-result]').innerText = + `${search.results.length} — ${data.map(d => d.url).sort().join(', ')}`; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `2 — /en/, /pt-br/`); diff --git a/pagefind/integration_tests/frozen-pre-1.0/multilingual/legacy-pagefind-keeps-dialects-separate.toolproof.yml b/pagefind/integration_tests/frozen-pre-1.0/multilingual/legacy-pagefind-keeps-dialects-separate.toolproof.yml new file mode 100644 index 00000000..6bb73c81 --- /dev/null +++ b/pagefind/integration_tests/frozen-pre-1.0/multilingual/legacy-pagefind-keeps-dialects-separate.toolproof.yml @@ -0,0 +1,56 @@ +name: Multilingual > LEGACY Pagefind keeps dialects separate +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/pt-pt/index.html" file with the content {html} + html: |- + + + + Document + + +

I am a different Portuguese document (trust me — quilométricas — see?)

+ + + - step: I have a "public/index.html" file with the content {html} + html: |- + + + + Document + + +

Nothing

+ + + - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: stderr should contain "pre-1.0 compatibility mode" + - step: The file "public/_pagefind/pagefind.js" should not be empty + - step: I run "ls -lh public/_pagefind/wasm.unknown.pagefind" + notes: 'TODO: Build a file existence check into toolproof' + - step: I run "ls -lh public/_pagefind/wasm.pt-pt.pagefind" + notes: 'TODO: Build a file existence check into toolproof' + - step: I run "ls -lh public/_pagefind/wasm.pt-br.pagefind" + notes: 'TODO: Build a file existence check into toolproof' + - step: The file "public/_pagefind/pagefind-entry.json" should contain "pt-pt" + - step: The file "public/_pagefind/pagefind-entry.json" should contain "pt-br" + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/_pagefind/pagefind.js"); + + + let search = await pagefind.search("quilométricos"); + + + let data = search.results[0] ? await search.results[0].data() : "None"; + + document.querySelector('[data-result]').innerText = + `${search.results.length} — ${data.url}`; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `1 — /pt-br/`); diff --git a/pagefind/integration_tests/frozen-pre-1.0/multilingual/legacy-pagefind-merges-omitted-languages-into-the-primary-language.toolproof.yml b/pagefind/integration_tests/frozen-pre-1.0/multilingual/legacy-pagefind-merges-omitted-languages-into-the-primary-language.toolproof.yml new file mode 100644 index 00000000..069d4181 --- /dev/null +++ b/pagefind/integration_tests/frozen-pre-1.0/multilingual/legacy-pagefind-merges-omitted-languages-into-the-primary-language.toolproof.yml @@ -0,0 +1,55 @@ +name: >- + Multilingual > LEGACY Pagefind merges omitted languages into the primary + language +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.html" file with the content {html} + html: |- + + + + Document + + +

Nothing

+ + + - step: I have a "public/mystery/index.html" file with the content {html} + html: |- + + + + Document + + +

I am a mystery document

+ + + - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: stderr should contain "pre-1.0 compatibility mode" + - step: The file "public/_pagefind/pagefind.js" should not be empty + - step: I run "ls -lh public/_pagefind/wasm.unknown.pagefind" + notes: 'TODO: Build a file existence check into toolproof' + - step: >- + The file "public/_pagefind/pagefind-entry.json" should not contain + "unknown" + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/_pagefind/pagefind.js"); + + + let search = await pagefind.search("documenting"); + + + let data = await Promise.all(search.results.map(result => result.data())); + + document.querySelector('[data-result]').innerText = `${data.map(d => + d.url).sort().join(', ')}`; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `/en/, /mystery/`); diff --git a/pagefind/integration_tests/frozen-pre-1.0/multilingual/legacy-pagefind-searches-for-english-with-english-stemming.toolproof.yml b/pagefind/integration_tests/frozen-pre-1.0/multilingual/legacy-pagefind-searches-for-english-with-english-stemming.toolproof.yml new file mode 100644 index 00000000..62553dbd --- /dev/null +++ b/pagefind/integration_tests/frozen-pre-1.0/multilingual/legacy-pagefind-searches-for-english-with-english-stemming.toolproof.yml @@ -0,0 +1,43 @@ +name: Multilingual > LEGACY Pagefind searches for English with English stemming +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.html" file with the content {html} + html: |- + + + + Document + + + +

Nothing

+ + + - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: stderr should contain "pre-1.0 compatibility mode" + - step: The file "public/_pagefind/pagefind.js" should not be empty + - step: I run "ls -lh public/_pagefind/wasm.unknown.pagefind" + notes: 'TODO: Build a file existence check into toolproof' + - step: I run "ls -lh public/_pagefind/wasm.en.pagefind" + notes: 'TODO: Build a file existence check into toolproof' + - step: The file "public/_pagefind/pagefind-entry.json" should contain "en" + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/_pagefind/pagefind.js"); + + + let search = await pagefind.search("documenting"); + + + let data = search.results[0] ? await search.results[0].data() : "None"; + + document.querySelector('[data-result]').innerText = + `${search.results.length} — ${data.url}`; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `1 — /en/`); diff --git a/pagefind/integration_tests/frozen-pre-1.0/multilingual/legacy-pagefind-searches-for-portuguese-with-portuguese-stemming.toolproof.yml b/pagefind/integration_tests/frozen-pre-1.0/multilingual/legacy-pagefind-searches-for-portuguese-with-portuguese-stemming.toolproof.yml new file mode 100644 index 00000000..77958a97 --- /dev/null +++ b/pagefind/integration_tests/frozen-pre-1.0/multilingual/legacy-pagefind-searches-for-portuguese-with-portuguese-stemming.toolproof.yml @@ -0,0 +1,44 @@ +name: >- + Multilingual > LEGACY Pagefind searches for Portuguese with Portuguese + stemming +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.html" file with the content {html} + html: |- + + + + Document + + +

Nothing

+ + + - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: stderr should contain "pre-1.0 compatibility mode" + - step: The file "public/_pagefind/pagefind.js" should not be empty + - step: I run "ls -lh public/_pagefind/wasm.unknown.pagefind" + notes: 'TODO: Build a file existence check into toolproof' + - step: I run "ls -lh public/_pagefind/wasm.pt-br.pagefind" + notes: 'TODO: Build a file existence check into toolproof' + - step: The file "public/_pagefind/pagefind-entry.json" should contain "pt-br" + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/_pagefind/pagefind.js"); + + + let search = await pagefind.search("quilométricos"); + + + let data = search.results[0] ? await search.results[0].data() : "None"; + + document.querySelector('[data-result]').innerText = + `${search.results.length} — ${data.url}`; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `1 — /pt-br/`); diff --git a/pagefind/integration_tests/frozen-pre-1.0/multilingual/legacy-pagefind-searches-for-unknown-languages-with-no-stemming.toolproof.yml b/pagefind/integration_tests/frozen-pre-1.0/multilingual/legacy-pagefind-searches-for-unknown-languages-with-no-stemming.toolproof.yml new file mode 100644 index 00000000..c5da53ca --- /dev/null +++ b/pagefind/integration_tests/frozen-pre-1.0/multilingual/legacy-pagefind-searches-for-unknown-languages-with-no-stemming.toolproof.yml @@ -0,0 +1,59 @@ +name: Multilingual > LEGACY Pagefind searches for unknown languages with no stemming +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.html" file with the content {html} + html: |- + + + + Document + + +

Nothing

+ + + - step: I have a "public/mystery/index.html" file with the content {html} + html: |- + + + + Document + + +

I am a documentation

+ + + - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: stderr should contain "pre-1.0 compatibility mode" + - step: The file "public/_pagefind/pagefind.js" should not be empty + - step: I run "ls -lh public/_pagefind/wasm.unknown.pagefind" + notes: 'TODO: Build a file existence check into toolproof' + - step: >- + I run "ls -lh public/_pagefind/wasm.my_cool_language.pagefind" and expect + it to fail + notes: 'TODO: Build a file existence check into toolproof' + - step: >- + The file "public/_pagefind/pagefind-entry.json" should contain + "my_cool_language" + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/_pagefind/pagefind.js"); + + + let search = await pagefind.search("documentation"); + + let stem_search = await pagefind.search("documenting"); + + + let data = search.results[0] ? await search.results[0].data() : "None"; + + document.querySelector('[data-result]').innerText = + `${search.results.length} — ${data.url} — ${stem_search.results.length}`; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `1 — /mystery/ — 0`); diff --git a/pagefind/integration_tests/frozen-pre-1.0/multisite/multisite_base/background.toolproof.yml b/pagefind/integration_tests/frozen-pre-1.0/multisite/multisite_base/background.toolproof.yml new file mode 100644 index 00000000..033a7c1d --- /dev/null +++ b/pagefind/integration_tests/frozen-pre-1.0/multisite/multisite_base/background.toolproof.yml @@ -0,0 +1,19 @@ +name: frozen-pre-1.0/multisite/multisite_base > Multisite Search > Background +type: reference +steps: + - step: I have a "root/index.html" file with the content {html} + html: >- +

Nothing

+ - step: I have a "root/website_a/hello/index.html" file with the content {html} + html: >- + + +

web web world PAGEFIND_ROOT_SELECTOR

+ - step: I have a "root/website_b/lorem/index.html" file with the content {html} + html: >- + + +

web ipsum

diff --git a/pagefind/integration_tests/frozen-pre-1.0/multisite/multisite_base/legacy-pagefind-can-search-across-multiple-sites.toolproof.yml b/pagefind/integration_tests/frozen-pre-1.0/multisite/multisite_base/legacy-pagefind-can-search-across-multiple-sites.toolproof.yml new file mode 100644 index 00000000..3b1a9344 --- /dev/null +++ b/pagefind/integration_tests/frozen-pre-1.0/multisite/multisite_base/legacy-pagefind-can-search-across-multiple-sites.toolproof.yml @@ -0,0 +1,34 @@ +name: Multisite Search > LEGACY Pagefind can search across multiple sites +steps: + - ref: ./background.toolproof.yml + - step: I run "%pagefind_exec_path% --source root/website_a" + - step: stdout should contain "Running Pagefind" + - step: stderr should contain "pre-1.0 compatibility mode" + - step: The file "root/website_a/_pagefind/pagefind.js" should not be empty + - step: I run "%pagefind_exec_path% --source root/website_b" + - step: stdout should contain "Running Pagefind" + - step: stderr should contain "pre-1.0 compatibility mode" + - step: The file "root/website_b/_pagefind/pagefind.js" should not be empty + - step: I serve the directory "root" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/website_a/_pagefind/pagefind.js"); + + await pagefind.mergeIndex("/website_b/_pagefind/"); + + + let search = await pagefind.search("web"); + + + let pages = await Promise.all(search.results.map(r => r.data())); + + document.querySelector('[data-result]').innerText = pages.map(p => + p.url).join(", "); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: >- + let val = await toolproof.querySelector("[data-result]"); + + toolproof.assert_eq(val.innerHTML, `/website_a/hello/, + /website_b/lorem/`); diff --git a/pagefind/integration_tests/frozen-pre-1.0/multisite/multisite_base/legacy-pagefind-ui-can-search-across-multiple-sites.toolproof.yml b/pagefind/integration_tests/frozen-pre-1.0/multisite/multisite_base/legacy-pagefind-ui-can-search-across-multiple-sites.toolproof.yml new file mode 100644 index 00000000..b55ddb08 --- /dev/null +++ b/pagefind/integration_tests/frozen-pre-1.0/multisite/multisite_base/legacy-pagefind-ui-can-search-across-multiple-sites.toolproof.yml @@ -0,0 +1,43 @@ +name: Multisite Search > LEGACY Pagefind UI can search across multiple sites +steps: + - ref: ./background.toolproof.yml + - step: I have a "root/index.html" file with the content {html} + html: |- + + + - step: I run "%pagefind_exec_path% --source root/website_a" + - step: stdout should contain "Running Pagefind" + - step: stderr should contain "pre-1.0 compatibility mode" + - step: The file "root/website_a/_pagefind/pagefind.js" should not be empty + - step: I run "%pagefind_exec_path% --source root/website_b" + - step: stdout should contain "Running Pagefind" + - step: stderr should contain "pre-1.0 compatibility mode" + - step: The file "root/website_b/_pagefind/pagefind.js" should not be empty + - step: I serve the directory "root" + - step: In my browser, I load "/" + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let pui = new PagefindUI({ + element: "#search", + mergeIndex: [{ + bundlePath: "/website_b/_pagefind/" + }] + }); + pui.triggerSearch("web"); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: >- + let val = await + toolproof.querySelector(".pagefind-ui__result:nth-of-type(1) + .pagefind-ui__result-link"); + + toolproof.assert_eq(val.innerHTML, `web web world + PAGEFIND_ROOT_SELECTOR`); + - step: In my browser, I evaluate {js} + js: >- + let val = await + toolproof.querySelector(".pagefind-ui__result:nth-of-type(2) + .pagefind-ui__result-link"); + + toolproof.assert_eq(val.innerHTML, `web ipsum`); diff --git a/pagefind/integration_tests/frozen-pre-1.0/sanity/legacy-cli-tests-are-working.toolproof.yml b/pagefind/integration_tests/frozen-pre-1.0/sanity/legacy-cli-tests-are-working.toolproof.yml new file mode 100644 index 00000000..f1e105cf --- /dev/null +++ b/pagefind/integration_tests/frozen-pre-1.0/sanity/legacy-cli-tests-are-working.toolproof.yml @@ -0,0 +1,11 @@ +name: Sanity Tests > LEGACY CLI tests are working +steps: + - step: I have a "public/index.html" file with the content {html} + html: >- + +

Nothing

+ - step: I run "%pagefind_exec_path% --source public" + - step: stdout should contain "Running Pagefind" + - step: stderr should contain "pre-1.0 compatibility mode" + - step: stderr should contain "The `source` option is deprecated" diff --git a/pagefind/integration_tests/frozen-pre-1.0/sanity/legacy-web-tests-are-working.toolproof.yml b/pagefind/integration_tests/frozen-pre-1.0/sanity/legacy-web-tests-are-working.toolproof.yml new file mode 100644 index 00000000..180aba8e --- /dev/null +++ b/pagefind/integration_tests/frozen-pre-1.0/sanity/legacy-web-tests-are-working.toolproof.yml @@ -0,0 +1,12 @@ +name: Sanity Tests > LEGACY Web tests are working +steps: + - step: I have a "public/index.html" file with the content {html} + html: >- +

Hello!

+ - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("h1"); + toolproof.assert_eq(val.innerHTML, `Hello!`); diff --git a/pagefind/integration_tests/frozen-pre-1.0/search_options/background.toolproof.yml b/pagefind/integration_tests/frozen-pre-1.0/search_options/background.toolproof.yml new file mode 100644 index 00000000..46a73953 --- /dev/null +++ b/pagefind/integration_tests/frozen-pre-1.0/search_options/background.toolproof.yml @@ -0,0 +1,4 @@ +name: frozen-pre-1.0/search_options > Search Options > Background +type: reference +steps: + - step: I have the environment variable "PAGEFIND_SOURCE" set to "public" diff --git a/pagefind/integration_tests/frozen-pre-1.0/search_options/legacy-base-url-auto-detects-the-default-directory-being-moved.toolproof.yml b/pagefind/integration_tests/frozen-pre-1.0/search_options/legacy-base-url-auto-detects-the-default-directory-being-moved.toolproof.yml new file mode 100644 index 00000000..7b224d92 --- /dev/null +++ b/pagefind/integration_tests/frozen-pre-1.0/search_options/legacy-base-url-auto-detects-the-default-directory-being-moved.toolproof.yml @@ -0,0 +1,33 @@ +name: >- + Search Options > LEGACY Base URL auto-detects the default directory being + moved +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.html" file with the content {html} + html: >- + + +

Nothing

+ - step: I have a "public/cat/index.html" file with the content {html} + html: >- +

world

+ - step: I run "%pagefind_exec_path% --bundle-dir blog/_pagefind" + - step: stdout should contain "Running Pagefind" + - step: The file "public/blog/_pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/blog/_pagefind/pagefind.js"); + + let search = await pagefind.search("world"); + + let data = await search.results[0].data(); + document.querySelector('[data-url]').innerText = data.url; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-url]"); + toolproof.assert_eq(val.innerHTML, `/blog/cat/`); diff --git a/pagefind/integration_tests/frozen-pre-1.0/search_options/legacy-base-url-can-be-configured.toolproof.yml b/pagefind/integration_tests/frozen-pre-1.0/search_options/legacy-base-url-can-be-configured.toolproof.yml new file mode 100644 index 00000000..e859d774 --- /dev/null +++ b/pagefind/integration_tests/frozen-pre-1.0/search_options/legacy-base-url-can-be-configured.toolproof.yml @@ -0,0 +1,35 @@ +name: Search Options > LEGACY Base URL can be configured +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.html" file with the content {html} + html: >- + + +

Nothing

+ - step: I have a "public/cat/index.html" file with the content {html} + html: >- +

world

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: stderr should contain "pre-1.0 compatibility mode" + - step: The file "public/_pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/_pagefind/pagefind.js"); + await pagefind.options({ + baseUrl: "/docs/" + }); + + let search = await pagefind.search("world"); + + let data = await search.results[0].data(); + document.querySelector('[data-url]').innerText = data.url; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-url]"); + toolproof.assert_eq(val.innerHTML, `/docs/cat/`); diff --git a/pagefind/integration_tests/frozen-pre-1.0/search_options/legacy-keep-index-url-can-be-configured.toolproof.yml b/pagefind/integration_tests/frozen-pre-1.0/search_options/legacy-keep-index-url-can-be-configured.toolproof.yml new file mode 100644 index 00000000..4c28af1a --- /dev/null +++ b/pagefind/integration_tests/frozen-pre-1.0/search_options/legacy-keep-index-url-can-be-configured.toolproof.yml @@ -0,0 +1,31 @@ +name: Search Options > LEGACY Keep Index URL can be configured +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.html" file with the content {html} + html: >- + + +

Nothing

+ - step: I have a "public/cat/index.html" file with the content {html} + html: >- +

world

+ - step: I run "%pagefind_exec_path% --bundle-dir blog/_pagefind --keep-index-url" + - step: stdout should contain "Running Pagefind" + - step: The file "public/blog/_pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/blog/_pagefind/pagefind.js"); + + let search = await pagefind.search("world"); + + let data = await search.results[0].data(); + document.querySelector('[data-url]').innerText = data.url; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-url]"); + toolproof.assert_eq(val.innerHTML, `/blog/cat/index.html`); diff --git a/pagefind/integration_tests/frozen-pre-1.0/ui/ui_base/background.toolproof.yml b/pagefind/integration_tests/frozen-pre-1.0/ui/ui_base/background.toolproof.yml new file mode 100644 index 00000000..439497a5 --- /dev/null +++ b/pagefind/integration_tests/frozen-pre-1.0/ui/ui_base/background.toolproof.yml @@ -0,0 +1,12 @@ +name: frozen-pre-1.0/ui/ui_base > Base UI Tests > Background +type: reference +steps: + - step: I have the environment variable "PAGEFIND_SOURCE" set to "public" + - step: I have a "public/index.html" file with the content {html} + html: |- + + + + diff --git a/pagefind/integration_tests/frozen-pre-1.0/ui/ui_base/legacy-pagefind-ui-loads.toolproof.yml b/pagefind/integration_tests/frozen-pre-1.0/ui/ui_base/legacy-pagefind-ui-loads.toolproof.yml new file mode 100644 index 00000000..d9768bf2 --- /dev/null +++ b/pagefind/integration_tests/frozen-pre-1.0/ui/ui_base/legacy-pagefind-ui-loads.toolproof.yml @@ -0,0 +1,18 @@ +name: Base UI Tests > LEGACY Pagefind UI loads +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/cat/index.html" file with the content {html} + html: >- +

world

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: stderr should contain "pre-1.0 compatibility mode" + - step: The file "public/_pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let el = await toolproof.querySelector(".pagefind-ui"); + toolproof.assert(el); diff --git a/pagefind/integration_tests/frozen-pre-1.0/ui/ui_base/legacy-pagefind-ui-searches.toolproof.yml b/pagefind/integration_tests/frozen-pre-1.0/ui/ui_base/legacy-pagefind-ui-searches.toolproof.yml new file mode 100644 index 00000000..2cf3604f --- /dev/null +++ b/pagefind/integration_tests/frozen-pre-1.0/ui/ui_base/legacy-pagefind-ui-searches.toolproof.yml @@ -0,0 +1,20 @@ +name: Base UI Tests > LEGACY Pagefind UI searches +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/cat/index.html" file with the content {html} + html: >- +

world

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: stderr should contain "pre-1.0 compatibility mode" + - step: The file "public/_pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: window.pui.triggerSearch("world"); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector(".pagefind-ui__result-link"); + toolproof.assert_eq(val.innerHTML, `world`); diff --git a/pagefind/integration_tests/highlighting/highlighting_results/background.toolproof.yml b/pagefind/integration_tests/highlighting/highlighting_results/background.toolproof.yml new file mode 100644 index 00000000..16ed2520 --- /dev/null +++ b/pagefind/integration_tests/highlighting/highlighting_results/background.toolproof.yml @@ -0,0 +1,83 @@ +name: highlighting/highlighting_results > Highlighting Result Tests > Background +type: reference +steps: + - step: I have the environment variable "PAGEFIND_SITE" set to "public" + - step: I have a "public/words/index.html" file with the content {html} + html: >- +

Is + this highlighted? It should be!

+ +

This should not be highlighted

+ +

This should not be highlighted

+ + + - step: I have a "public/single-body/index.html" file with the content {html} + html: >- +
+

This should be highlighted

+

This should not be highlighted

+
+ +

This should not be highlighted

+ + + - step: I have a "public/multiple-bodies/index.html" file with the content {html} + html: >- +
+

This should be highlighted

+

This should not be highlighted

+
+ +

This should not be highlighted

+ +
+

This should be highlighted

+

This should not be highlighted

+
+ + + - step: I have a "public/options/index.html" file with the content {html} + html: >- +
+

This should be highlighted

+

This should not be highlighted

+
+ +

This should not be highlighted

+ +
+

This should be highlighted

+

This should not be highlighted

+

This should not be highlighted

+
+ + + - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: I serve the directory "public" diff --git a/pagefind/integration_tests/highlighting/highlighting_results/highlight-script-is-loaded.toolproof.yml b/pagefind/integration_tests/highlighting/highlighting_results/highlight-script-is-loaded.toolproof.yml new file mode 100644 index 00000000..da2f5b2d --- /dev/null +++ b/pagefind/integration_tests/highlighting/highlighting_results/highlight-script-is-loaded.toolproof.yml @@ -0,0 +1,8 @@ +name: Highlighting Result Tests > Highlight script is loaded +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I load "/words/" + - step: In my browser, I evaluate {js} + js: await new Promise(r => setTimeout(r, 200)); + - step: The file "public/pagefind/pagefind-highlight.js" should not be empty + - step: In my browser, the console should be empty diff --git a/pagefind/integration_tests/highlighting/highlighting_results/highlight-script-marks-correctly.toolproof.yml b/pagefind/integration_tests/highlighting/highlighting_results/highlight-script-marks-correctly.toolproof.yml new file mode 100644 index 00000000..9452e335 --- /dev/null +++ b/pagefind/integration_tests/highlighting/highlighting_results/highlight-script-marks-correctly.toolproof.yml @@ -0,0 +1,70 @@ +name: Highlighting Result Tests > Highlight script marks correctly +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I load "/words/?pagefind-highlight=this" + - step: In my browser, I evaluate {js} + js: await new Promise(r => setTimeout(r, 200)); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("#has-highlight mark"); + toolproof.assert_eq(val.innerHTML, `this`); + - step: In my browser, I evaluate {js} + js: >- + let val = await toolproof.querySelector("#has-highlight + mark.pagefind-highlight"); + + toolproof.assert_eq(val.innerHTML, `this`); + - step: In my browser, I evaluate {js} + js: >- + let val = await + toolproof.querySelector("p[data-pagefind-ignore]:not(:has(span))"); + + toolproof.assert_eq(val.innerHTML, `This should not be highlighted`); + - step: In my browser, I evaluate {js} + js: >- + let val = await + toolproof.querySelector("p[data-pagefind-ignore]:has(span)"); + + toolproof.assert_eq(val.innerHTML, `This should not be + highlighted`); + - step: >- + In my browser, I load + "/words/?pagefind-highlight=this&pagefind-highlight=should" + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: >- + let val = await toolproof.querySelector("#has-highlight + mark:first-of-type"); + + toolproof.assert_eq(val.innerHTML, `this`); + - step: In my browser, I evaluate {js} + js: >- + let val = await toolproof.querySelector("#has-highlight + mark:nth-of-type(2)"); + + toolproof.assert_eq(val.innerHTML, `should`); + - step: In my browser, I load "/words/?pagefind-highlight=is+this" + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("#has-highlight mark"); + toolproof.assert_eq(val.innerHTML, `Is this`); + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("p[data-pagefind-ignore]"); + toolproof.assert_eq(val.innerHTML, `This should not be highlighted`); + - step: In my browser, I load "/words/?pagefind-highlight=highlighted%3F" + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("#has-highlight mark"); + toolproof.assert_eq(val.innerHTML, `highlighted?`); + - step: In my browser, I load "/words/?pagefind-highlight=this+highlighted%3F" + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: >- + let val = await toolproof.querySelector("#has-highlight + mark:first-of-type"); + + toolproof.assert_eq(val.innerHTML, `this highlighted?`); diff --git a/pagefind/integration_tests/highlighting/highlighting_results/highlight-script-options-work.toolproof.yml b/pagefind/integration_tests/highlighting/highlighting_results/highlight-script-options-work.toolproof.yml new file mode 100644 index 00000000..98891f7a --- /dev/null +++ b/pagefind/integration_tests/highlighting/highlighting_results/highlight-script-options-work.toolproof.yml @@ -0,0 +1,29 @@ +name: Highlighting Result Tests > Highlight script options work +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I load "/options/?custom-name=this" + - step: In my browser, I evaluate {js} + js: await new Promise(r => setTimeout(r, 200)); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("#has-highlight mark"); + toolproof.assert_eq(val.innerHTML, `This`); + - step: In my browser, I evaluate {js} + js: >- + let val = await toolproof.querySelector("#has-highlight + mark.custom-class"); + + toolproof.assert_eq(val.innerHTML, `This`); + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("p[data-pagefind-ignore]"); + toolproof.assert_eq(val.innerHTML, `This should not be highlighted`); + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("p.ignore"); + toolproof.assert_eq(val.innerHTML, `This should not be highlighted`); + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("#no-highlight"); + toolproof.assert_eq(val.innerHTML, `This should not be highlighted`); diff --git a/pagefind/integration_tests/highlighting/highlighting_results/highlight-script-stays-within-pagefind-body.toolproof.yml b/pagefind/integration_tests/highlighting/highlighting_results/highlight-script-stays-within-pagefind-body.toolproof.yml new file mode 100644 index 00000000..9a2e1d38 --- /dev/null +++ b/pagefind/integration_tests/highlighting/highlighting_results/highlight-script-stays-within-pagefind-body.toolproof.yml @@ -0,0 +1,33 @@ +name: Highlighting Result Tests > Highlight script stays within pagefind-body +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I load "/single-body/?pagefind-highlight=this" + - step: In my browser, I evaluate {js} + js: await new Promise(r => setTimeout(r, 200)); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("#has-highlight mark"); + toolproof.assert_eq(val.innerHTML, `This`); + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("p[data-pagefind-ignore]"); + toolproof.assert_eq(val.innerHTML, `This should not be highlighted`); + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("#no-highlight"); + toolproof.assert_eq(val.innerHTML, `This should not be highlighted`); + - step: In my browser, I load "/multiple-bodies/?pagefind-highlight=this" + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("#has-highlight mark"); + toolproof.assert_eq(val.innerHTML, `This`); + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("p[data-pagefind-ignore]"); + toolproof.assert_eq(val.innerHTML, `This should not be highlighted`); + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("#no-highlight"); + toolproof.assert_eq(val.innerHTML, `This should not be highlighted`); diff --git a/pagefind/integration_tests/highlighting/highlighting_search/background.toolproof.yml b/pagefind/integration_tests/highlighting/highlighting_search/background.toolproof.yml new file mode 100644 index 00000000..a89ff46a --- /dev/null +++ b/pagefind/integration_tests/highlighting/highlighting_search/background.toolproof.yml @@ -0,0 +1,18 @@ +name: highlighting/highlighting_search > Highlighting Search Tests > Background +type: reference +steps: + - step: I have the environment variable "PAGEFIND_SITE" set to "public" + - step: I have a "public/index.html" file with the content {html} + html: >- +

Nothing

+ - step: I have a "public/a/index.html" file with the content {html} + html: >- +

Hello + World

+ - step: I have a "public/b/index.html" file with the content {html} + html: >- +

Second

+ +

Second Page

diff --git a/pagefind/integration_tests/highlighting/highlighting_search/multiple-query-parameters-are-inserted-through-the-js-api.toolproof.yml b/pagefind/integration_tests/highlighting/highlighting_search/multiple-query-parameters-are-inserted-through-the-js-api.toolproof.yml new file mode 100644 index 00000000..05ba82c6 --- /dev/null +++ b/pagefind/integration_tests/highlighting/highlighting_search/multiple-query-parameters-are-inserted-through-the-js-api.toolproof.yml @@ -0,0 +1,24 @@ +name: >- + Highlighting Search Tests > Multiple query parameters are inserted through the + JS API +steps: + - ref: ./background.toolproof.yml + - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: |- + 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; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-url]"); + toolproof.assert_eq(val.innerHTML, `/a/?hi=hello&hi=world`); diff --git a/pagefind/integration_tests/highlighting/highlighting_search/query-parameters-can-be-inserted-through-the-js-api.toolproof.yml b/pagefind/integration_tests/highlighting/highlighting_search/query-parameters-can-be-inserted-through-the-js-api.toolproof.yml new file mode 100644 index 00000000..105ce881 --- /dev/null +++ b/pagefind/integration_tests/highlighting/highlighting_search/query-parameters-can-be-inserted-through-the-js-api.toolproof.yml @@ -0,0 +1,24 @@ +name: >- + Highlighting Search Tests > Query parameters can be inserted through the JS + API +steps: + - ref: ./background.toolproof.yml + - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: |- + 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; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-url]"); + toolproof.assert_eq(val.innerHTML, `/a/?hi=world`); diff --git a/pagefind/integration_tests/highlighting/highlighting_search/query-parameters-don-t-conflict-with-subresult-anchors.toolproof.yml b/pagefind/integration_tests/highlighting/highlighting_search/query-parameters-don-t-conflict-with-subresult-anchors.toolproof.yml new file mode 100644 index 00000000..f691f7e9 --- /dev/null +++ b/pagefind/integration_tests/highlighting/highlighting_search/query-parameters-don-t-conflict-with-subresult-anchors.toolproof.yml @@ -0,0 +1,24 @@ +name: >- + Highlighting Search Tests > Query parameters don't conflict with subresult + anchors +steps: + - ref: ./background.toolproof.yml + - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: |- + 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; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-url]"); + toolproof.assert_eq(val.innerHTML, `/b/?hi=second#second`); diff --git a/pagefind/integration_tests/index_chunking/background.toolproof.yml b/pagefind/integration_tests/index_chunking/background.toolproof.yml new file mode 100644 index 00000000..e5fc0080 --- /dev/null +++ b/pagefind/integration_tests/index_chunking/background.toolproof.yml @@ -0,0 +1,9 @@ +name: index_chunking > Index Chunking > Background +type: reference +steps: + - step: I have the environment variable "PAGEFIND_SITE" set to "public" + - step: I have a "public/index.html" file with the content {html} + html: |- + diff --git a/pagefind/integration_tests/index_chunking/searches-that-don-t-match-a-chunk-will-load-the-closest-chunk.toolproof.yml b/pagefind/integration_tests/index_chunking/searches-that-don-t-match-a-chunk-will-load-the-closest-chunk.toolproof.yml new file mode 100644 index 00000000..739cc341 --- /dev/null +++ b/pagefind/integration_tests/index_chunking/searches-that-don-t-match-a-chunk-will-load-the-closest-chunk.toolproof.yml @@ -0,0 +1,29 @@ +name: Index Chunking > Searches that don't match a chunk will load the closest chunk +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/one/index.html" file with the content {html} + html: >- +

Hello + World

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search("h"); + + + let results = await Promise.all(search.results.map(r => r.data())); + + document.querySelector('[data-result]').innerText = results.map(r => + r.url).join(', '); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `/one/`); diff --git a/pagefind/integration_tests/indexing/background.toolproof.yml b/pagefind/integration_tests/indexing/background.toolproof.yml new file mode 100644 index 00000000..a727ca5e --- /dev/null +++ b/pagefind/integration_tests/indexing/background.toolproof.yml @@ -0,0 +1,4 @@ +name: indexing > Indexing > Background +type: reference +steps: + - step: I have the environment variable "PAGEFIND_SITE" set to "public" diff --git a/pagefind/integration_tests/indexing/html-attributes-can-be-indexed.toolproof.yml b/pagefind/integration_tests/indexing/html-attributes-can-be-indexed.toolproof.yml new file mode 100644 index 00000000..78c7cedb --- /dev/null +++ b/pagefind/integration_tests/indexing/html-attributes-can-be-indexed.toolproof.yml @@ -0,0 +1,33 @@ +name: Indexing > HTML attributes can be indexed +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.html" file with the content {html} + html: >- +

Nothing

+ - step: I have a "public/cat/index.html" file with the content {html} + html: >- +

Page Title

+ + Alternate Text + +

Hello World, from Pagefind

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/pagefind/pagefind.js"); + + let search = await pagefind.search("Alternate"); + let searchdata = await search.results[0]?.data(); + document.querySelector('[data-search]').innerText = searchdata?.content; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: >- + let val = await toolproof.querySelector("[data-search]"); + + toolproof.assert_eq(val.innerHTML, `Page Title. Alternate Text. Hello + World, from Pagefind.`); diff --git a/pagefind/integration_tests/indexing/indexing-can-be-limited-to-a-given-element.toolproof.yml b/pagefind/integration_tests/indexing/indexing-can-be-limited-to-a-given-element.toolproof.yml new file mode 100644 index 00000000..64e25349 --- /dev/null +++ b/pagefind/integration_tests/indexing/indexing-can-be-limited-to-a-given-element.toolproof.yml @@ -0,0 +1,61 @@ +name: Indexing > Indexing can be limited to a given element +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.html" file with the content {html} + html: >- +

Nothing

+ +

Nothing

+ - step: I have a "public/cat/index.html" file with the content {html} + html: |- +

Outer Content

+
+

Hello World, from Pagefind

+

Huzzah!

+
+

goodbye content

+

Little extra body

+
+

More unindexed content

+
+

Body number 3

+
+

And yet more unindexed content

+
+ - step: I have a "public/dog/index.html" file with the content {html} + html: |- +

No selector

+

goodbye content

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let searchone = await pagefind.search("hello"); + + let searchonedata = await searchone.results[0].data(); + + document.querySelector('[data-search-one]').innerText = + searchonedata.content; + + + let searchtwo = await pagefind.search("goodbye"); + + document.querySelector('[data-search-two]').innerText = + `${searchtwo.results.length} result(s)`; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: >- + let val = await toolproof.querySelector("[data-search-one]"); + + toolproof.assert_eq(val.innerHTML, `Hello World, from Pagefind. Huzzah! + Little extra body. Body number 3.`); + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-search-two]"); + toolproof.assert_eq(val.innerHTML, `0 result(s)`); diff --git a/pagefind/integration_tests/input_quirks/background.toolproof.yml b/pagefind/integration_tests/input_quirks/background.toolproof.yml new file mode 100644 index 00000000..3f454404 --- /dev/null +++ b/pagefind/integration_tests/input_quirks/background.toolproof.yml @@ -0,0 +1,9 @@ +name: input_quirks > Input Quirk Tests > Background +type: reference +steps: + - step: I have the environment variable "PAGEFIND_SITE" set to "public" + - step: I have the environment variable "PAGEFIND_verbose" set to "true" + - step: I have a "public/index.html" file with the content {html} + html: >- +

Nothing

diff --git a/pagefind/integration_tests/input_quirks/index-gzipped-input-files.toolproof.yml b/pagefind/integration_tests/input_quirks/index-gzipped-input-files.toolproof.yml new file mode 100644 index 00000000..b2b5a0cd --- /dev/null +++ b/pagefind/integration_tests/input_quirks/index-gzipped-input-files.toolproof.yml @@ -0,0 +1,28 @@ +name: Input Quirk Tests > Index gzipped input files +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/cat/index.html" file with the content {html} + html: >- +

Hello + World

+ - step: >- + I run "gzip public/cat/index.html && mv public/cat/index.html.gz + public/cat/index.html" + - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/pagefind/pagefind.js"); + + let search = await pagefind.search("world"); + + let data = await search.results[0].data(); + document.querySelector('[data-title]').innerText = data.meta.title; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-title]"); + toolproof.assert_eq(val.innerHTML, `Hello World`); diff --git a/pagefind/integration_tests/metadata/background.toolproof.yml b/pagefind/integration_tests/metadata/background.toolproof.yml new file mode 100644 index 00000000..aed7e555 --- /dev/null +++ b/pagefind/integration_tests/metadata/background.toolproof.yml @@ -0,0 +1,70 @@ +name: metadata > Metadata > Background +type: reference +steps: + - step: I have the environment variable "PAGEFIND_SITE" set to "public" + - step: I have a "public/index.html" file with the content {html} + html: |- + + + +

Nothing

+

Nothing

+ + + - step: I have a "public/cat/index.html" file with the content {html} + html: |- + + + + + + +

+ Cat Post. +

+ cats + cat picture +

A post about the 'felines'

+

This post has some gnarly things to test the fragment formatting.

+ cat footer picture + + + - step: I have a "public/dog/index.html" file with the content {html} + html: |- + + + + Website | Dogs + + +

Dog Post.

+ dog + generic + + + - step: I have a "public/kea/index.html" file with the content {html} + html: |- + + + Website | Kea + + +

NZ Kea Post.

+ + + - step: I have a "public/kaka/index.html" file with the content {html} + html: |- + + + Website | Kaka + + +

+

NZ Kaka Post.

+ + + - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" diff --git a/pagefind/integration_tests/metadata/default-metadata-can-be-defined.toolproof.yml b/pagefind/integration_tests/metadata/default-metadata-can-be-defined.toolproof.yml new file mode 100644 index 00000000..842b9ff0 --- /dev/null +++ b/pagefind/integration_tests/metadata/default-metadata-can-be-defined.toolproof.yml @@ -0,0 +1,24 @@ +name: Metadata > Default metadata can be defined +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/pagefind/pagefind.js"); + + let search = await pagefind.search("dog"); + + let data = await search.results[0].data(); + document.querySelector('[data-result]').innerText = [ + data.meta.title, + data.meta.image, + data.meta.animal, + data.meta.vegetable, + data.meta.mineral, + ].join(' | '); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: >- + let val = await toolproof.querySelector("[data-result]"); + + toolproof.assert_eq(val.innerHTML, `Dog Post. | /puppy.jpg | dog | generic + | generic`); diff --git a/pagefind/integration_tests/metadata/search-results-return-complex-metadata.toolproof.yml b/pagefind/integration_tests/metadata/search-results-return-complex-metadata.toolproof.yml new file mode 100644 index 00000000..1d1b6fab --- /dev/null +++ b/pagefind/integration_tests/metadata/search-results-return-complex-metadata.toolproof.yml @@ -0,0 +1,22 @@ +name: Metadata > Search results return complex metadata +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search("cat"); + + + let data = await search.results[0].data(); + + document.querySelector('[data-result]').innerText = data.meta.footer + " — + " + data.meta.footer_alt; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: >- + let val = await toolproof.querySelector("[data-result]"); + + toolproof.assert_eq(val.innerHTML, `/cat-footer.png — cat footer + picture`); diff --git a/pagefind/integration_tests/metadata/search-results-return-generic-information-about-the-page.toolproof.yml b/pagefind/integration_tests/metadata/search-results-return-generic-information-about-the-page.toolproof.yml new file mode 100644 index 00000000..33472a67 --- /dev/null +++ b/pagefind/integration_tests/metadata/search-results-return-generic-information-about-the-page.toolproof.yml @@ -0,0 +1,26 @@ +name: Metadata > Search results return generic information about the page +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search("cat"); + + + let data = await search.results[0].data(); + + document.querySelector('[data-result]').innerText = data.meta.title; + + document.querySelector('[data-result-two]').innerText = + `${data.meta.image} | ${data.meta.image_alt}`; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `Cat Post.`); + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result-two]"); + toolproof.assert_eq(val.innerHTML, `/cat.png | cat picture`); diff --git a/pagefind/integration_tests/metadata/search-results-return-highlighted-search-excerpt.toolproof.yml b/pagefind/integration_tests/metadata/search-results-return-highlighted-search-excerpt.toolproof.yml new file mode 100644 index 00000000..bb61040e --- /dev/null +++ b/pagefind/integration_tests/metadata/search-results-return-highlighted-search-excerpt.toolproof.yml @@ -0,0 +1,19 @@ +name: Metadata > Search results return highlighted search excerpt +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/pagefind/pagefind.js"); + + let search = await pagefind.search("feline"); + + let data = await search.results[0].data(); + document.querySelector('[data-result]').innerText = data.excerpt; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: >- + let val = await toolproof.querySelector("[data-result]"); + + toolproof.assert_eq(val.innerHTML, `Cat Post. A post about the + <mark>'felines'.</mark> This post has some gnarly things to + test the fragment formatting.`); diff --git a/pagefind/integration_tests/metadata/search-results-return-nicely-formatted-content.toolproof.yml b/pagefind/integration_tests/metadata/search-results-return-nicely-formatted-content.toolproof.yml new file mode 100644 index 00000000..9066998a --- /dev/null +++ b/pagefind/integration_tests/metadata/search-results-return-nicely-formatted-content.toolproof.yml @@ -0,0 +1,18 @@ +name: Metadata > Search results return nicely formatted content +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/pagefind/pagefind.js"); + + let search = await pagefind.search("feline"); + + let data = await search.results[0].data(); + document.querySelector('[data-result]').innerText = data.content; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: >- + let val = await toolproof.querySelector("[data-result]"); + + toolproof.assert_eq(val.innerHTML, `Cat Post. A post about the 'felines'. + This post has some gnarly things to test the fragment formatting.`); diff --git a/pagefind/integration_tests/metadata/search-results-return-tagged-filters.toolproof.yml b/pagefind/integration_tests/metadata/search-results-return-tagged-filters.toolproof.yml new file mode 100644 index 00000000..d0a99d7a --- /dev/null +++ b/pagefind/integration_tests/metadata/search-results-return-tagged-filters.toolproof.yml @@ -0,0 +1,21 @@ +name: Metadata > Search results return tagged filters +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search("cat"); + + + let data = await search.results[0].data(); + + document.querySelector('[data-result]').innerText = + Object.entries(data.filters).map(([f, v]) => `${f}: ${v}`).sort().join(', + '); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `animal: cats, title: Cat Post.`); diff --git a/pagefind/integration_tests/metadata/search-results-return-tagged-metadata.toolproof.yml b/pagefind/integration_tests/metadata/search-results-return-tagged-metadata.toolproof.yml new file mode 100644 index 00000000..79a5b3df --- /dev/null +++ b/pagefind/integration_tests/metadata/search-results-return-tagged-metadata.toolproof.yml @@ -0,0 +1,20 @@ +name: Metadata > Search results return tagged metadata +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search("cat"); + + + let data = await search.results[0].data(); + + document.querySelector('[data-result]').innerText = + data.meta["social-image"] + " — " + data.meta.adjective; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `/kitty.jpg — gnarly`); diff --git a/pagefind/integration_tests/metadata/title-metadata-falls-back-to-the-title-element.toolproof.yml b/pagefind/integration_tests/metadata/title-metadata-falls-back-to-the-title-element.toolproof.yml new file mode 100644 index 00000000..5668e11f --- /dev/null +++ b/pagefind/integration_tests/metadata/title-metadata-falls-back-to-the-title-element.toolproof.yml @@ -0,0 +1,20 @@ +name: Metadata > Title metadata falls back to the title element +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search("NZ"); + + + let data = await Promise.all(search.results.map(result => result.data())); + + document.querySelector('[data-result]').innerText = data.map(d => + d.meta.title).sort().join(', '); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `Website | Kaka, Website | Kea`); diff --git a/pagefind/integration_tests/modular_ui/modular_ui_base/background.toolproof.yml b/pagefind/integration_tests/modular_ui/modular_ui_base/background.toolproof.yml new file mode 100644 index 00000000..2d9fce02 --- /dev/null +++ b/pagefind/integration_tests/modular_ui/modular_ui_base/background.toolproof.yml @@ -0,0 +1,23 @@ +name: modular_ui/modular_ui_base > Base Modular UI Tests > Background +type: reference +steps: + - step: I have the environment variable "PAGEFIND_SITE" set to "public" + - step: I have a "public/index.html" file with the content {html} + html: |- + +
+
+ + + diff --git a/pagefind/integration_tests/modular_ui/modular_ui_base/pagefind-modular-ui-loads.toolproof.yml b/pagefind/integration_tests/modular_ui/modular_ui_base/pagefind-modular-ui-loads.toolproof.yml new file mode 100644 index 00000000..60355979 --- /dev/null +++ b/pagefind/integration_tests/modular_ui/modular_ui_base/pagefind-modular-ui-loads.toolproof.yml @@ -0,0 +1,17 @@ +name: Base Modular UI Tests > Pagefind Modular UI loads +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/cat/index.html" file with the content {html} + html: >- +

world

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let el = await toolproof.querySelector("#search input"); + toolproof.assert(el); diff --git a/pagefind/integration_tests/modular_ui/modular_ui_base/pagefind-modular-ui-searches.toolproof.yml b/pagefind/integration_tests/modular_ui/modular_ui_base/pagefind-modular-ui-searches.toolproof.yml new file mode 100644 index 00000000..05c0c731 --- /dev/null +++ b/pagefind/integration_tests/modular_ui/modular_ui_base/pagefind-modular-ui-searches.toolproof.yml @@ -0,0 +1,22 @@ +name: Base Modular UI Tests > Pagefind Modular UI searches +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/cat/index.html" file with the content {html} + html: >- +

world

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: |- + let e = new Event('input', {bubbles:true, cancelable:true}); + document.querySelector("#search input").value = "world"; + document.querySelector("#search input").dispatchEvent(e); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector(".pagefind-modular-list-link"); + toolproof.assert_eq(val.innerHTML, `world`); diff --git a/pagefind/integration_tests/multilingual/background.toolproof.yml b/pagefind/integration_tests/multilingual/background.toolproof.yml new file mode 100644 index 00000000..4e03d5f3 --- /dev/null +++ b/pagefind/integration_tests/multilingual/background.toolproof.yml @@ -0,0 +1,26 @@ +name: multilingual > Multilingual > Background +type: reference +steps: + - step: I have the environment variable "PAGEFIND_SITE" set to "public" + - step: I have a "public/en/index.html" file with the content {html} + html: |- + + + + Document + + +

I am some English documentation

+ + + - step: I have a "public/pt-br/index.html" file with the content {html} + html: |- + + + + Document + + +

I am a Portuguese document (trust me — quilométricas — see?)

+ + diff --git a/pagefind/integration_tests/multilingual/pagefind-can-be-configured-to-lump-all-languages-together.toolproof.yml b/pagefind/integration_tests/multilingual/pagefind-can-be-configured-to-lump-all-languages-together.toolproof.yml new file mode 100644 index 00000000..b5751b6c --- /dev/null +++ b/pagefind/integration_tests/multilingual/pagefind-can-be-configured-to-lump-all-languages-together.toolproof.yml @@ -0,0 +1,42 @@ +name: Multilingual > Pagefind can be configured to lump all languages together +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.html" file with the content {html} + html: |- + + + + Document + + +

Nothing

+ + + - step: I run "%pagefind_exec_path% --force-language 'en'" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I run "ls -lh public/pagefind/wasm.unknown.pagefind" + notes: 'TODO: Build a file existence check into toolproof' + - step: I run "ls -lh public/pagefind/wasm.en.pagefind" + notes: 'TODO: Build a file existence check into toolproof' + - step: I run "ls -lh public/pagefind/wasm.pt-br.pagefind" and expect it to fail + notes: 'TODO: Build a file existence check into toolproof' + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search("documenting"); + + + let data = await Promise.all(search.results.map(result => result.data())); + + document.querySelector('[data-result]').innerText = + `${search.results.length} — ${data.map(d => d.url).sort().join(', ')}`; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `2 — /en/, /pt-br/`); diff --git a/pagefind/integration_tests/multilingual/pagefind-can-be-destroyed-and-re-initialized.toolproof.yml b/pagefind/integration_tests/multilingual/pagefind-can-be-destroyed-and-re-initialized.toolproof.yml new file mode 100644 index 00000000..3b09a802 --- /dev/null +++ b/pagefind/integration_tests/multilingual/pagefind-can-be-destroyed-and-re-initialized.toolproof.yml @@ -0,0 +1,70 @@ +name: Multilingual > Pagefind can be destroyed and re-initialized +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.html" file with the content {html} + html: |- + + + + Generic Page + + +

Nothing

+

Nothing

+ + + - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I run "ls -lh public/pagefind/wasm.unknown.pagefind" + notes: 'TODO: Build a file existence check into toolproof' + - step: I run "ls -lh public/pagefind/wasm.en.pagefind" + notes: 'TODO: Build a file existence check into toolproof' + - step: I run "ls -lh public/pagefind/wasm.pt-br.pagefind" + notes: 'TODO: Build a file existence check into toolproof' + - step: The file "public/pagefind/pagefind-entry.json" should contain "en" + - step: The file "public/pagefind/pagefind-entry.json" should contain "pt-br" + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + await pagefind.init(); + + let en_search = await pagefind.search("documenting"); + + + let en_data = en_search.results[0] ? await en_search.results[0].data() : + "None"; + + document.querySelector('[data-result-a]').innerText = + `${en_search.results.length} — ${en_data.url}`; + + + await pagefind.destroy(); + + + document.querySelector('html').setAttribute("lang", "pt-br"); + + + await pagefind.init(); + + let pt_search = await pagefind.search("quilométricos"); + + + let pt_data = pt_search.results[0] ? await pt_search.results[0].data() : + "None"; + + document.querySelector('[data-result-b]').innerText = + `${pt_search.results.length} — ${pt_data.url}`; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result-a]"); + toolproof.assert_eq(val.innerHTML, `1 — /en/`); + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result-b]"); + toolproof.assert_eq(val.innerHTML, `1 — /pt-br/`); diff --git a/pagefind/integration_tests/multilingual/pagefind-keeps-dialects-separate.toolproof.yml b/pagefind/integration_tests/multilingual/pagefind-keeps-dialects-separate.toolproof.yml new file mode 100644 index 00000000..fe7c6c4e --- /dev/null +++ b/pagefind/integration_tests/multilingual/pagefind-keeps-dialects-separate.toolproof.yml @@ -0,0 +1,55 @@ +name: Multilingual > Pagefind keeps dialects separate +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/pt-pt/index.html" file with the content {html} + html: |- + + + + Document + + +

I am a different Portuguese document (trust me — quilométricas — see?)

+ + + - step: I have a "public/index.html" file with the content {html} + html: |- + + + + Document + + +

Nothing

+ + + - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I run "ls -lh public/pagefind/wasm.unknown.pagefind" + notes: 'TODO: Build a file existence check into toolproof' + - step: I run "ls -lh public/pagefind/wasm.pt-pt.pagefind" + notes: 'TODO: Build a file existence check into toolproof' + - step: I run "ls -lh public/pagefind/wasm.pt-br.pagefind" + notes: 'TODO: Build a file existence check into toolproof' + - step: The file "public/pagefind/pagefind-entry.json" should contain "pt-pt" + - step: The file "public/pagefind/pagefind-entry.json" should contain "pt-br" + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search("quilométricos"); + + + let data = search.results[0] ? await search.results[0].data() : "None"; + + document.querySelector('[data-result]').innerText = + `${search.results.length} — ${data.url}`; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `1 — /pt-br/`); diff --git a/pagefind/integration_tests/multilingual/pagefind-merges-omitted-languages-into-the-primary-language.toolproof.yml b/pagefind/integration_tests/multilingual/pagefind-merges-omitted-languages-into-the-primary-language.toolproof.yml new file mode 100644 index 00000000..0ec0fa29 --- /dev/null +++ b/pagefind/integration_tests/multilingual/pagefind-merges-omitted-languages-into-the-primary-language.toolproof.yml @@ -0,0 +1,52 @@ +name: Multilingual > Pagefind merges omitted languages into the primary language +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.html" file with the content {html} + html: |- + + + + Document + + +

Nothing

+ + + - step: I have a "public/mystery/index.html" file with the content {html} + html: |- + + + + Document + + +

I am a mystery document

+ + + - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I run "ls -lh public/pagefind/wasm.unknown.pagefind" + notes: 'TODO: Build a file existence check into toolproof' + - step: >- + The file "public/pagefind/pagefind-entry.json" should not contain + "unknown" + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search("documenting"); + + + let data = await Promise.all(search.results.map(result => result.data())); + + document.querySelector('[data-result]').innerText = `${data.map(d => + d.url).sort().join(', ')}`; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `/en/, /mystery/`); diff --git a/pagefind/integration_tests/multilingual/pagefind-searches-for-english-with-english-stemming.toolproof.yml b/pagefind/integration_tests/multilingual/pagefind-searches-for-english-with-english-stemming.toolproof.yml new file mode 100644 index 00000000..af7148df --- /dev/null +++ b/pagefind/integration_tests/multilingual/pagefind-searches-for-english-with-english-stemming.toolproof.yml @@ -0,0 +1,41 @@ +name: Multilingual > Pagefind searches for English with English stemming +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.html" file with the content {html} + html: |- + + + + Document + + +

Nothing

+ + + - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I run "ls -lh public/pagefind/wasm.unknown.pagefind" + notes: 'TODO: Build a file existence check into toolproof' + - step: I run "ls -lh public/pagefind/wasm.en.pagefind" + notes: 'TODO: Build a file existence check into toolproof' + - step: The file "public/pagefind/pagefind-entry.json" should contain "en" + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search("documenting"); + + + let data = search.results[0] ? await search.results[0].data() : "None"; + + document.querySelector('[data-result]').innerText = + `${search.results.length} — ${data.url}`; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `1 — /en/`); diff --git a/pagefind/integration_tests/multilingual/pagefind-searches-for-portuguese-with-portuguese-stemming.toolproof.yml b/pagefind/integration_tests/multilingual/pagefind-searches-for-portuguese-with-portuguese-stemming.toolproof.yml new file mode 100644 index 00000000..248f02f5 --- /dev/null +++ b/pagefind/integration_tests/multilingual/pagefind-searches-for-portuguese-with-portuguese-stemming.toolproof.yml @@ -0,0 +1,41 @@ +name: Multilingual > Pagefind searches for Portuguese with Portuguese stemming +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.html" file with the content {html} + html: |- + + + + Document + + +

Nothing

+ + + - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I run "ls -lh public/pagefind/wasm.unknown.pagefind" + notes: 'TODO: Build a file existence check into toolproof' + - step: I run "ls -lh public/pagefind/wasm.pt-br.pagefind" + notes: 'TODO: Build a file existence check into toolproof' + - step: The file "public/pagefind/pagefind-entry.json" should contain "pt-br" + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search("quilométricos"); + + + let data = search.results[0] ? await search.results[0].data() : "None"; + + document.querySelector('[data-result]').innerText = + `${search.results.length} — ${data.url}`; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `1 — /pt-br/`); diff --git a/pagefind/integration_tests/multilingual/pagefind-searches-for-unknown-languages-with-no-stemming.toolproof.yml b/pagefind/integration_tests/multilingual/pagefind-searches-for-unknown-languages-with-no-stemming.toolproof.yml new file mode 100644 index 00000000..9caf76c9 --- /dev/null +++ b/pagefind/integration_tests/multilingual/pagefind-searches-for-unknown-languages-with-no-stemming.toolproof.yml @@ -0,0 +1,58 @@ +name: Multilingual > Pagefind searches for unknown languages with no stemming +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.html" file with the content {html} + html: |- + + + + Document + + +

Nothing

+ + + - step: I have a "public/mystery/index.html" file with the content {html} + html: |- + + + + Document + + +

I am a documentation

+ + + - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I run "ls -lh public/pagefind/wasm.unknown.pagefind" + notes: 'TODO: Build a file existence check into toolproof' + - step: >- + I run "ls -lh public/pagefind/wasm.my_cool_language.pagefind" and expect + it to fail + notes: 'TODO: Build a file existence check into toolproof' + - step: >- + The file "public/pagefind/pagefind-entry.json" should contain + "my_cool_language" + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search("documentation"); + + let stem_search = await pagefind.search("documenting"); + + + let data = search.results[0] ? await search.results[0].data() : "None"; + + document.querySelector('[data-result]').innerText = + `${search.results.length} — ${data.url} — ${stem_search.results.length}`; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `1 — /mystery/ — 0`); diff --git a/pagefind/integration_tests/multisite/multisite_base/background.toolproof.yml b/pagefind/integration_tests/multisite/multisite_base/background.toolproof.yml new file mode 100644 index 00000000..50900ade --- /dev/null +++ b/pagefind/integration_tests/multisite/multisite_base/background.toolproof.yml @@ -0,0 +1,15 @@ +name: multisite/multisite_base > Multisite Search > Background +type: reference +steps: + - step: I have a "root/index.html" file with the content {html} + html: >- +

Nothing

+ - step: I have a "root/website_a/hello/index.html" file with the content {html} + html: >- +

web web world web + PAGEFIND_ROOT_SELECTOR

+ - step: I have a "root/website_b/lorem/index.html" file with the content {html} + html: >- +

web + ipsum

diff --git a/pagefind/integration_tests/multisite/multisite_base/pagefind-can-search-across-discrete-domains.toolproof.yml b/pagefind/integration_tests/multisite/multisite_base/pagefind-can-search-across-discrete-domains.toolproof.yml new file mode 100644 index 00000000..ee608ecb --- /dev/null +++ b/pagefind/integration_tests/multisite/multisite_base/pagefind-can-search-across-discrete-domains.toolproof.yml @@ -0,0 +1,31 @@ +#TODO: This is an intentionally skipped test — add skipping to toolproof. + +type: reference +name: Multisite Search > Pagefind can search across discrete domains +steps: + - ref: ./background.toolproof.yml + - step: I run "%pagefind_exec_path% --site root/website_a" + - step: stdout should contain "Running Pagefind" + - step: The file "root/website_a/pagefind/pagefind.js" should not be empty + - step: I serve the directory "root" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/website_a/pagefind/pagefind.js"); + + await pagefind.mergeIndex("https://pagefind.app/pagefind/"); + + + let search = await pagefind.search("PAGEFIND_ROOT_SELECTOR"); + + + let pages = await Promise.all(search.results.map(r => r.data())); + + document.querySelector('[data-result]').innerText = pages.map(p => + p.url).sort().join(", "); + - step: In my browser, I evaluate {js} + js: >- + let val = await toolproof.querySelector("[data-result]"); + + toolproof.assert_eq(val.innerHTML, `/website_a/hello/, + https://pagefind.app/docs/config-options/`); diff --git a/pagefind/integration_tests/multisite/multisite_base/pagefind-can-search-across-multiple-basic-sites.toolproof.yml b/pagefind/integration_tests/multisite/multisite_base/pagefind-can-search-across-multiple-basic-sites.toolproof.yml new file mode 100644 index 00000000..e74e0c20 --- /dev/null +++ b/pagefind/integration_tests/multisite/multisite_base/pagefind-can-search-across-multiple-basic-sites.toolproof.yml @@ -0,0 +1,32 @@ +name: Multisite Search > Pagefind can search across multiple basic sites +steps: + - ref: ./background.toolproof.yml + - step: I run "%pagefind_exec_path% --site root/website_a" + - step: stdout should contain "Running Pagefind" + - step: The file "root/website_a/pagefind/pagefind.js" should not be empty + - step: I run "%pagefind_exec_path% --site root/website_b" + - step: stdout should contain "Running Pagefind" + - step: The file "root/website_b/pagefind/pagefind.js" should not be empty + - step: I serve the directory "root" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/website_a/pagefind/pagefind.js"); + + await pagefind.mergeIndex("/website_b/pagefind/"); + + + let search = await pagefind.search("web"); + + + let pages = await Promise.all(search.results.map(r => r.data())); + + document.querySelector('[data-result]').innerText = pages.map(p => + p.url).join(", "); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: >- + let val = await toolproof.querySelector("[data-result]"); + + toolproof.assert_eq(val.innerHTML, `/website_a/hello/, + /website_b/lorem/`); diff --git a/pagefind/integration_tests/multisite/multisite_base/pagefind-ui-can-search-across-discrete-domains.toolproof.yml b/pagefind/integration_tests/multisite/multisite_base/pagefind-ui-can-search-across-discrete-domains.toolproof.yml new file mode 100644 index 00000000..240b98e4 --- /dev/null +++ b/pagefind/integration_tests/multisite/multisite_base/pagefind-ui-can-search-across-discrete-domains.toolproof.yml @@ -0,0 +1,55 @@ +#TODO: This is an intentionally skipped test — add skipping to toolproof. + +type: reference +name: Multisite Search > Pagefind UI can search across discrete domains +steps: + - ref: ./background.toolproof.yml + - step: I have a "root/index.html" file with the content {html} + html: |- + + + - step: I run "%pagefind_exec_path% --site root/website_a" + - step: stdout should contain "Running Pagefind" + - step: The file "root/website_a/pagefind/pagefind.js" should not be empty + - step: I serve the directory "root" + - step: In my browser, I load "/" + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: >- + let pui = new PagefindUI({ + element: "#search", + mergeIndex: [{ + bundlePath: "https://pagefind.app/pagefind/" + }] + }); + + pui.triggerSearch("PAGEFIND_ROOT_SELECTOR"); + + + let waiting_since = Date.now(); + + while + (!document.querySelector(".pagefind-ui__result-link:nth-of-type(2)")) { + await new Promise(r => setTimeout(r, 100)); // TODO: await el in humane + if (Date.now() - waiting_since > 10000) { + break; + } + } + + + const links = + [...document.querySelectorAll(".pagefind-ui__result-link")].map(l => + l.getAttribute('href')).sort(); + + const expected = ["/website_a/hello/", + "https://pagefind.app/docs/config-options/"]; + + if (links.length < expected.length) { + throw new Error(`Expected ${expected.length} links, found ${links.length}`); + } + + for (let i = 0; i < links.length; i++) { + if (links[i] !== expected[i]) { + throw new Error(`${links[i]} !== ${expected[i]}`); + } + } diff --git a/pagefind/integration_tests/multisite/multisite_base/pagefind-ui-can-search-across-multiple-sites.toolproof.yml b/pagefind/integration_tests/multisite/multisite_base/pagefind-ui-can-search-across-multiple-sites.toolproof.yml new file mode 100644 index 00000000..97f18fae --- /dev/null +++ b/pagefind/integration_tests/multisite/multisite_base/pagefind-ui-can-search-across-multiple-sites.toolproof.yml @@ -0,0 +1,41 @@ +name: Multisite Search > Pagefind UI can search across multiple sites +steps: + - ref: ./background.toolproof.yml + - step: I have a "root/index.html" file with the content {html} + html: |- + + + - step: I run "%pagefind_exec_path% --site root/website_a" + - step: stdout should contain "Running Pagefind" + - step: The file "root/website_a/pagefind/pagefind.js" should not be empty + - step: I run "%pagefind_exec_path% --site root/website_b" + - step: stdout should contain "Running Pagefind" + - step: The file "root/website_b/pagefind/pagefind.js" should not be empty + - step: I serve the directory "root" + - step: In my browser, I load "/" + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let pui = new PagefindUI({ + element: "#search", + mergeIndex: [{ + bundlePath: "/website_b/pagefind/" + }] + }); + pui.triggerSearch("web"); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: >- + let val = await + toolproof.querySelector(".pagefind-ui__result:nth-of-type(1) + .pagefind-ui__result-link"); + + toolproof.assert_eq(val.innerHTML, `web web world web + PAGEFIND_ROOT_SELECTOR`); + - step: In my browser, I evaluate {js} + js: >- + let val = await + toolproof.querySelector(".pagefind-ui__result:nth-of-type(2) + .pagefind-ui__result-link"); + + toolproof.assert_eq(val.innerHTML, `web ipsum`); diff --git a/pagefind/integration_tests/multisite/multisite_filters/background.toolproof.yml b/pagefind/integration_tests/multisite/multisite_filters/background.toolproof.yml new file mode 100644 index 00000000..f929f31f --- /dev/null +++ b/pagefind/integration_tests/multisite/multisite_filters/background.toolproof.yml @@ -0,0 +1,25 @@ +name: multisite/multisite_filters > Multisite Filters > Background +type: reference +steps: + - step: I have a "root/index.html" file with the content {html} + html: >- +

Nothing

+ - step: I have a "root/website_a/hello/index.html" file with the content {html} + html: |- +

web world

+ apple + red + - step: I have a "root/website_b/lorem/index.html" file with the content {html} + html: |- +

web ipsum

+ banana + happy + - step: I run "%pagefind_exec_path% --site root/website_a" + - step: stdout should contain "Running Pagefind" + - step: The file "root/website_a/pagefind/pagefind.js" should not be empty + - step: I run "%pagefind_exec_path% --site root/website_b" + - step: stdout should contain "Running Pagefind" + - step: The file "root/website_b/pagefind/pagefind.js" should not be empty + - step: I serve the directory "root" + - step: In my browser, I load "/" diff --git a/pagefind/integration_tests/multisite/multisite_filters/pagefind-can-search-across-multiple-sites-with-common-filters.toolproof.yml b/pagefind/integration_tests/multisite/multisite_filters/pagefind-can-search-across-multiple-sites-with-common-filters.toolproof.yml new file mode 100644 index 00000000..249a5cae --- /dev/null +++ b/pagefind/integration_tests/multisite/multisite_filters/pagefind-can-search-across-multiple-sites-with-common-filters.toolproof.yml @@ -0,0 +1,28 @@ +name: >- + Multisite Filters > Pagefind can search across multiple sites with common + filters +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/website_a/pagefind/pagefind.js"); + + await pagefind.mergeIndex("/website_b/pagefind/"); + + + let search = await pagefind.search("web", { + filters: { + fruit: "apple" + } + }); + + + let pages = await Promise.all(search.results.map(r => r.data())); + + document.querySelector('[data-result]').innerText = pages.map(p => + p.url).join(", "); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `/website_a/hello/`); diff --git a/pagefind/integration_tests/multisite/multisite_filters/pagefind-can-search-across-multiple-sites-with-synthetic-filters.toolproof.yml b/pagefind/integration_tests/multisite/multisite_filters/pagefind-can-search-across-multiple-sites-with-synthetic-filters.toolproof.yml new file mode 100644 index 00000000..2d1a4083 --- /dev/null +++ b/pagefind/integration_tests/multisite/multisite_filters/pagefind-can-search-across-multiple-sites-with-synthetic-filters.toolproof.yml @@ -0,0 +1,44 @@ +name: >- + Multisite Filters > Pagefind can search across multiple sites with synthetic + filters +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/website_a/pagefind/pagefind.js"); + await pagefind.options({ + mergeFilter: { + site: "A" + } + }); + await pagefind.mergeIndex("/website_b/pagefind/", { + mergeFilter: { + site: ["B", "C"] + } + }); + + let search_a = await pagefind.search("web", { + filters: { + site: "A" + } + }); + let pages_a = await Promise.all(search_a.results.map(r => r.data())); + + let search_b = await pagefind.search("web", { + filters: { + site: "B" + } + }); + let pages_b = await Promise.all(search_b.results.map(r => r.data())); + + document.querySelector('[data-result]').innerText = [ + pages_a.map(p => p.url).join(", "), + pages_b.map(p => p.url).join(", "), + ].join(' — '); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: >- + let val = await toolproof.querySelector("[data-result]"); + + toolproof.assert_eq(val.innerHTML, `/website_a/hello/ — + /website_b/lorem/`); diff --git a/pagefind/integration_tests/multisite/multisite_filters/pagefind-can-search-across-multiple-sites-with-unique-filters.toolproof.yml b/pagefind/integration_tests/multisite/multisite_filters/pagefind-can-search-across-multiple-sites-with-unique-filters.toolproof.yml new file mode 100644 index 00000000..b8e5cbab --- /dev/null +++ b/pagefind/integration_tests/multisite/multisite_filters/pagefind-can-search-across-multiple-sites-with-unique-filters.toolproof.yml @@ -0,0 +1,28 @@ +name: >- + Multisite Filters > Pagefind can search across multiple sites with unique + filters +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/website_a/pagefind/pagefind.js"); + + await pagefind.mergeIndex("/website_b/pagefind/"); + + + let search = await pagefind.search("web", { + filters: { + emote: "happy" + } + }); + + + let pages = await Promise.all(search.results.map(r => r.data())); + + document.querySelector('[data-result]').innerText = pages.map(p => + p.url).join(", "); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `/website_b/lorem/`); diff --git a/pagefind/integration_tests/multisite/multisite_lang/background.toolproof.yml b/pagefind/integration_tests/multisite/multisite_lang/background.toolproof.yml new file mode 100644 index 00000000..371171db --- /dev/null +++ b/pagefind/integration_tests/multisite/multisite_lang/background.toolproof.yml @@ -0,0 +1,43 @@ +name: multisite/multisite_lang > Multisite Search Languages > Background +type: reference +steps: + - step: I have a "root/index.html" file with the content {html} + html: >- +

Nothing

+ - step: I have a "root/website_a/en/1/index.html" file with the content {html} + html: |- + + + + +

Website site A English

+ + + - step: I have a "root/website_b/pt/1/index.html" file with the content {html} + html: |- + + + + +

Website site B Portuguese

+ + + - step: I have a "root/website_b/pt/2/index.html" file with the content {html} + html: |- + + + + +

Website site B Portuguese

+ + + - step: I have a "root/website_b/en/1/index.html" file with the content {html} + html: |- + + + + +

Website site B English

+ + diff --git a/pagefind/integration_tests/multisite/multisite_lang/language-of-merged-indexes-can-be-selected.toolproof.yml b/pagefind/integration_tests/multisite/multisite_lang/language-of-merged-indexes-can-be-selected.toolproof.yml new file mode 100644 index 00000000..c67f1b84 --- /dev/null +++ b/pagefind/integration_tests/multisite/multisite_lang/language-of-merged-indexes-can-be-selected.toolproof.yml @@ -0,0 +1,34 @@ +name: Multisite Search Languages > Language of merged indexes can be selected +steps: + - ref: ./background.toolproof.yml + - step: I run "%pagefind_exec_path% --site root/website_a" + - step: stdout should contain "Running Pagefind" + - step: The file "root/website_a/pagefind/pagefind.js" should not be empty + - step: I run "%pagefind_exec_path% --site root/website_b" + - step: stdout should contain "Running Pagefind" + - step: The file "root/website_b/pagefind/pagefind.js" should not be empty + - step: I serve the directory "root" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/website_a/pagefind/pagefind.js"); + + await pagefind.mergeIndex("/website_b/pagefind/", { + language: "pt-br" + }); + + + let search = await pagefind.search("web"); + + + let pages = await Promise.all(search.results.map(r => r.data())); + + document.querySelector('[data-result]').innerText = pages.map(p => + p.url).sort().join(", "); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: >- + let val = await toolproof.querySelector("[data-result]"); + + toolproof.assert_eq(val.innerHTML, `/website_a/en/1/, /website_b/pt/1/, + /website_b/pt/2/`); diff --git a/pagefind/integration_tests/multisite/multisite_lang/pagefind-picks-the-same-language-across-multiple-sites.toolproof.yml b/pagefind/integration_tests/multisite/multisite_lang/pagefind-picks-the-same-language-across-multiple-sites.toolproof.yml new file mode 100644 index 00000000..c920cfb1 --- /dev/null +++ b/pagefind/integration_tests/multisite/multisite_lang/pagefind-picks-the-same-language-across-multiple-sites.toolproof.yml @@ -0,0 +1,33 @@ +name: >- + Multisite Search Languages > Pagefind picks the same language across multiple + sites +steps: + - ref: ./background.toolproof.yml + - step: I run "%pagefind_exec_path% --site root/website_a" + - step: stdout should contain "Running Pagefind" + - step: The file "root/website_a/pagefind/pagefind.js" should not be empty + - step: I run "%pagefind_exec_path% --site root/website_b" + - step: stdout should contain "Running Pagefind" + - step: The file "root/website_b/pagefind/pagefind.js" should not be empty + - step: I serve the directory "root" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/website_a/pagefind/pagefind.js"); + + await pagefind.mergeIndex("/website_b/pagefind/"); + + + let search = await pagefind.search("web"); // <-- TODO search for + "website" + + + let pages = await Promise.all(search.results.map(r => r.data())); + + document.querySelector('[data-result]').innerText = pages.map(p => + p.url).join(", "); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `/website_a/en/1/, /website_b/en/1/`); diff --git a/pagefind/integration_tests/multisite/multisite_sort/background.toolproof.yml b/pagefind/integration_tests/multisite/multisite_sort/background.toolproof.yml new file mode 100644 index 00000000..222f5687 --- /dev/null +++ b/pagefind/integration_tests/multisite/multisite_sort/background.toolproof.yml @@ -0,0 +1,31 @@ +name: multisite/multisite_sort > Multisite Result Scoring > Background +type: reference +steps: + - step: I have a "root/index.html" file with the content {html} + html: >- +

Nothing

+ - step: I have a "root/website_a/twowebs/index.html" file with the content {html} + html: >- +

my page on the web + web

+ - step: I have a "root/website_a/oneweb/index.html" file with the content {html} + html: >- +

my page on the world + web

+ - step: I have a "root/website_a/longdoc/index.html" file with the content {html} + html: >- +

Aenean lacinia + bibendum nulla sed consectetur. Duis mollis, est non commodo luctus, nisi + erat porttitor ligula, eget lacinia odio sem nec elit.

+ - step: >- + I have a "root/website_b/threewebs/index.html" file with the content + {html} + html: >- +

my web web web + page

+ - step: I have a "root/website_b/longdoc/index.html" file with the content {html} + html: >- +

Aenean lacinia + bibendum nulla sed consectetur. Duis mollis, est non commodo luctus, nisi + erat porttitor ligula, eget lacinia odio sem nec elit.

diff --git a/pagefind/integration_tests/multisite/multisite_sort/multiple-indexes-can-be-weighted-separately.toolproof.yml b/pagefind/integration_tests/multisite/multisite_sort/multiple-indexes-can-be-weighted-separately.toolproof.yml new file mode 100644 index 00000000..470c3b5f --- /dev/null +++ b/pagefind/integration_tests/multisite/multisite_sort/multiple-indexes-can-be-weighted-separately.toolproof.yml @@ -0,0 +1,34 @@ +name: Multisite Result Scoring > Multiple indexes can be weighted separately +steps: + - ref: ./background.toolproof.yml + - step: I run "%pagefind_exec_path% --site root/website_a" + - step: stdout should contain "Running Pagefind" + - step: The file "root/website_a/pagefind/pagefind.js" should not be empty + - step: I run "%pagefind_exec_path% --site root/website_b" + - step: stdout should contain "Running Pagefind" + - step: The file "root/website_b/pagefind/pagefind.js" should not be empty + - step: I serve the directory "root" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/website_b/pagefind/pagefind.js"); + + await pagefind.mergeIndex("/website_a/pagefind/", { + indexWeight: 20 + }); + + + let search = await pagefind.search("web"); + + + let pages = await Promise.all(search.results.map(r => r.data())); + + document.querySelector('[data-result]').innerText = pages.map(p => + p.url).join(", "); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: >- + let val = await toolproof.querySelector("[data-result]"); + + toolproof.assert_eq(val.innerHTML, `/website_a/twowebs/, + /website_a/oneweb/, /website_b/threewebs/`); diff --git a/pagefind/integration_tests/multisite/multisite_sort/pages-are-scored-correctly-across-indexes.toolproof.yml b/pagefind/integration_tests/multisite/multisite_sort/pages-are-scored-correctly-across-indexes.toolproof.yml new file mode 100644 index 00000000..2b88e12f --- /dev/null +++ b/pagefind/integration_tests/multisite/multisite_sort/pages-are-scored-correctly-across-indexes.toolproof.yml @@ -0,0 +1,32 @@ +name: Multisite Result Scoring > Pages are scored correctly across indexes +steps: + - ref: ./background.toolproof.yml + - step: I run "%pagefind_exec_path% --site root/website_a" + - step: stdout should contain "Running Pagefind" + - step: The file "root/website_a/pagefind/pagefind.js" should not be empty + - step: I run "%pagefind_exec_path% --site root/website_b" + - step: stdout should contain "Running Pagefind" + - step: The file "root/website_b/pagefind/pagefind.js" should not be empty + - step: I serve the directory "root" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/website_a/pagefind/pagefind.js"); + + await pagefind.mergeIndex("/website_b/pagefind/"); + + + let search = await pagefind.search("web"); + + + let pages = await Promise.all(search.results.map(r => r.data())); + + document.querySelector('[data-result]').innerText = pages.map(p => + p.url).join(", "); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: >- + let val = await toolproof.querySelector("[data-result]"); + + toolproof.assert_eq(val.innerHTML, `/website_b/threewebs/, + /website_a/twowebs/, /website_a/oneweb/`); diff --git a/pagefind/integration_tests/node_api/node_base/an-index-is-not-consumed-on-write.toolproof.yml b/pagefind/integration_tests/node_api/node_base/an-index-is-not-consumed-on-write.toolproof.yml new file mode 100644 index 00000000..c83c5b59 --- /dev/null +++ b/pagefind/integration_tests/node_api/node_base/an-index-is-not-consumed-on-write.toolproof.yml @@ -0,0 +1,65 @@ +name: Node API Base Tests > An index is not consumed on write +steps: + - ref: ./background.toolproof.yml + - step: I have a "output/index.html" file with the content {html} + html: >- +

Nothing

+ - step: I have a "public/index.js" file with the content {js} + js: |2- + import * as pagefind from "pagefind"; + + const run = async () => { + const { index } = await pagefind.createIndex(); + await index.addHTMLFile({sourcePath: "dogs/index.html", content: "

Testing, testing

"}); + await index.writeFiles({ outputPath: "../output/pagefind" }); + + await index.addHTMLFile({sourcePath: "rabbits/index.html", content: "

Testing, testing

"}); + const { files } = await index.getFiles(); + + const fragments = files.filter(file => file.path.includes("fragment")); + console.log(`${fragments.length} fragment(s)`); + + await index.addHTMLFile({sourcePath: "cats/index.html", content: "

Testing, testing

"}); + await index.writeFiles({ outputPath: "./pagefind" }); + + console.log(`Successfully wrote files`); + } + + run(); + - step: >- + I run "cd public && npm i && PAGEFIND_BINARY_PATH=%pagefind_exec_path% + node index.js" + - step: stdout should contain "Successfully wrote files" + - step: stdout should contain "2 fragment(s)" + - step: The file "output/pagefind/pagefind.js" should not be empty + - step: I serve the directory "output" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/pagefind/pagefind.js"); + + let search = await pagefind.search("testing"); + + let pages = await Promise.all(search.results.map(r => r.data())); + document.querySelector('[data-url]').innerText = pages.map(p => p.url).sort().join(", "); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-url]"); + toolproof.assert_eq(val.innerHTML, `/dogs/`); + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/pagefind/pagefind.js"); + + let search = await pagefind.search("testing"); + + let pages = await Promise.all(search.results.map(r => r.data())); + document.querySelector('[data-url]').innerText = pages.map(p => p.url).sort().join(", "); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-url]"); + toolproof.assert_eq(val.innerHTML, `/cats/, /dogs/, /rabbits/`); diff --git a/pagefind/integration_tests/node_api/node_base/background.toolproof.yml b/pagefind/integration_tests/node_api/node_base/background.toolproof.yml new file mode 100644 index 00000000..3316a59d --- /dev/null +++ b/pagefind/integration_tests/node_api/node_base/background.toolproof.yml @@ -0,0 +1,18 @@ +name: node_api/node_base > Node API Base Tests > Background +type: reference +steps: + - step: I have a "public/index.html" file with the content {html} + html: >- +

Nothing

+ - step: I have a "public/package.json" file with the content {json} + json: |- + { + "name": "test", + "type": "module", + "version": "1.0.0", + "main": "index.js", + "dependencies": { + "pagefind": "file:%repo_wd%/wrappers/node" + } + } diff --git a/pagefind/integration_tests/node_api/node_base/build-a-blended-index-to-memory-via-the-api.toolproof.yml b/pagefind/integration_tests/node_api/node_base/build-a-blended-index-to-memory-via-the-api.toolproof.yml new file mode 100644 index 00000000..3a23f56f --- /dev/null +++ b/pagefind/integration_tests/node_api/node_base/build-a-blended-index-to-memory-via-the-api.toolproof.yml @@ -0,0 +1,58 @@ +name: Node API Base Tests > Build a blended index to memory via the api +steps: + - ref: ./background.toolproof.yml + - step: >- + I have a "public/custom_files/real/index.html" file with the content + {html} + html: >- +

A testing file that + exists on disk

+ - step: I have a "public/index.js" file with the content {js} + js: |2- + import * as pagefind from "pagefind"; + import fs from "fs"; + import path from "path"; + + const run = async () => { + const { index } = await pagefind.createIndex(); + await index.addDirectory({ path: "custom_files" }); + await index.addCustomRecord({ + url: "/synth/", + content: "A testing file that doesn't exist.", + language: "en" + }); + const { files } = await index.getFiles(); + + for (const file of files) { + const output_path = path.join("pagefind", file.path); + const dir = path.dirname(output_path); + if (!fs.existsSync(dir)){ + fs.mkdirSync(dir, { recursive: true }); + } + + fs.writeFileSync(output_path, file.content); + } + console.log("Donezo!"); + } + + run(); + - step: >- + I run "cd public && npm i && PAGEFIND_BINARY_PATH=%pagefind_exec_path% + node index.js" + - step: stdout should contain "Donezo!" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/pagefind/pagefind.js"); + + let search = await pagefind.search("testing"); + + let pages = await Promise.all(search.results.map(r => r.data())); + document.querySelector('[data-url]').innerText = pages.map(p => p.url).sort().join(", "); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-url]"); + toolproof.assert_eq(val.innerHTML, `/real/, /synth/`); diff --git a/pagefind/integration_tests/node_api/node_base/build-a-synthetic-index-to-disk-via-the-api.toolproof.yml b/pagefind/integration_tests/node_api/node_base/build-a-synthetic-index-to-disk-via-the-api.toolproof.yml new file mode 100644 index 00000000..7eaf16e5 --- /dev/null +++ b/pagefind/integration_tests/node_api/node_base/build-a-synthetic-index-to-disk-via-the-api.toolproof.yml @@ -0,0 +1,35 @@ +name: Node API Base Tests > Build a synthetic index to disk via the api +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.js" file with the content {js} + js: |2- + import * as pagefind from "pagefind"; + + const run = async () => { + const { index } = await pagefind.createIndex(); + await index.addHTMLFile({sourcePath: "dogs/index.html", content: "

Testing, testing

"}); + await index.writeFiles(); + console.log(`Successfully wrote files`); + } + + run(); + - step: >- + I run "cd public && npm i && PAGEFIND_BINARY_PATH=%pagefind_exec_path% + node index.js" + - step: stdout should contain "Successfully wrote files" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/pagefind/pagefind.js"); + + let search = await pagefind.search("testing"); + + let data = await search.results[0].data(); + document.querySelector('[data-url]').innerText = data.url; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-url]"); + toolproof.assert_eq(val.innerHTML, `/dogs/`); diff --git a/pagefind/integration_tests/node_api/node_base/build-a-synthetic-index-to-memory-via-the-api.toolproof.yml b/pagefind/integration_tests/node_api/node_base/build-a-synthetic-index-to-memory-via-the-api.toolproof.yml new file mode 100644 index 00000000..39495c02 --- /dev/null +++ b/pagefind/integration_tests/node_api/node_base/build-a-synthetic-index-to-memory-via-the-api.toolproof.yml @@ -0,0 +1,30 @@ +name: Node API Base Tests > Build a synthetic index to memory via the api +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.js" file with the content {js} + js: |2- + import * as pagefind from "pagefind"; + + const run = async () => { + const { index } = await pagefind.createIndex(); + await index.addHTMLFile({sourcePath: "dogs/index.html", content: "

Testing, testing

"}); + const { files } = await index.getFiles(); + + const jsFile = files.filter(file => file.path.includes("pagefind.js"))[0]; + console.log(jsFile.content.toString()); + + console.log(`JS is at ${jsFile.path}`); + + const fragments = files.filter(file => file.path.includes("fragment")); + console.log(`${fragments.length} fragment(s)`); + } + + run(); + - step: >- + I run "cd public && npm i && PAGEFIND_BINARY_PATH=%pagefind_exec_path% + node index.js" + - step: stdout should contain "pagefind_version=" + - step: stdout should contain "JS is at pagefind.js" + - step: stdout should contain "1 fragment(s)" + - step: I run "ls -lh public/pagefind/pagefind.js" and expect it to fail + notes: 'TODO: Build a file existence check into toolproof' diff --git a/pagefind/integration_tests/node_api/node_base/build-a-synthetic-index-with-overridden-urls-to-disk-via-the-api.toolproof.yml b/pagefind/integration_tests/node_api/node_base/build-a-synthetic-index-with-overridden-urls-to-disk-via-the-api.toolproof.yml new file mode 100644 index 00000000..5b74de6a --- /dev/null +++ b/pagefind/integration_tests/node_api/node_base/build-a-synthetic-index-with-overridden-urls-to-disk-via-the-api.toolproof.yml @@ -0,0 +1,37 @@ +name: >- + Node API Base Tests > Build a synthetic index with overridden urls to disk via + the api +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.js" file with the content {js} + js: |2- + import * as pagefind from "pagefind"; + + const run = async () => { + const { index } = await pagefind.createIndex(); + await index.addHTMLFile({url: "/my-custom-url/", content: "

Testing, testing

"}); + await index.writeFiles(); + console.log(`Successfully wrote files`); + } + + run(); + - step: >- + I run "cd public && npm i && PAGEFIND_BINARY_PATH=%pagefind_exec_path% + node index.js" + - step: stdout should contain "Successfully wrote files" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/pagefind/pagefind.js"); + + let search = await pagefind.search("testing"); + + let data = await search.results[0].data(); + document.querySelector('[data-url]').innerText = data.url; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-url]"); + toolproof.assert_eq(val.innerHTML, `/my-custom-url/`); diff --git a/pagefind/integration_tests/node_api/node_base/build-a-true-index-to-disk-via-the-api.toolproof.yml b/pagefind/integration_tests/node_api/node_base/build-a-true-index-to-disk-via-the-api.toolproof.yml new file mode 100644 index 00000000..d6f834bb --- /dev/null +++ b/pagefind/integration_tests/node_api/node_base/build-a-true-index-to-disk-via-the-api.toolproof.yml @@ -0,0 +1,41 @@ +name: Node API Base Tests > Build a true index to disk via the api +steps: + - ref: ./background.toolproof.yml + - step: >- + I have a "public/custom_files/real/index.html" file with the content + {html} + html: >- +

A testing file that + exists on disk

+ - step: I have a "public/index.js" file with the content {js} + js: |2- + import * as pagefind from "pagefind"; + + const run = async () => { + const { index } = await pagefind.createIndex(); + await index.addDirectory({path: "custom_files"}); + await index.writeFiles(); + console.log(`Successfully wrote files`); + } + + run(); + - step: >- + I run "cd public && npm i && PAGEFIND_BINARY_PATH=%pagefind_exec_path% + node index.js" + - step: stdout should contain "Successfully wrote files" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/pagefind/pagefind.js"); + + let search = await pagefind.search("testing"); + + let data = await search.results[0].data(); + document.querySelector('[data-url]').innerText = data.url; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-url]"); + toolproof.assert_eq(val.innerHTML, `/real/`); diff --git a/pagefind/integration_tests/node_api/node_base/build-an-index-to-a-custom-disk-location-via-the-api.toolproof.yml b/pagefind/integration_tests/node_api/node_base/build-an-index-to-a-custom-disk-location-via-the-api.toolproof.yml new file mode 100644 index 00000000..1854c087 --- /dev/null +++ b/pagefind/integration_tests/node_api/node_base/build-an-index-to-a-custom-disk-location-via-the-api.toolproof.yml @@ -0,0 +1,39 @@ +name: Node API Base Tests > Build an index to a custom disk location via the api +steps: + - ref: ./background.toolproof.yml + - step: I have a "output/index.html" file with the content {html} + html: >- +

Nothing

+ - step: I have a "public/index.js" file with the content {js} + js: |2- + import * as pagefind from "pagefind"; + + const run = async () => { + const { index } = await pagefind.createIndex(); + await index.addHTMLFile({sourcePath: "dogs/index.html", content: "

Testing, testing

"}); + await index.writeFiles({ outputPath: "../output/pagefind" }); + console.log(`Successfully wrote files`); + } + + run(); + - step: >- + I run "cd public && npm i && PAGEFIND_BINARY_PATH=%pagefind_exec_path% + node index.js" + - step: stdout should contain "Successfully wrote files" + - step: The file "output/pagefind/pagefind.js" should not be empty + - step: I serve the directory "output" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/pagefind/pagefind.js"); + + let search = await pagefind.search("testing"); + + let data = await search.results[0].data(); + document.querySelector('[data-url]').innerText = data.url; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-url]"); + toolproof.assert_eq(val.innerHTML, `/dogs/`); diff --git a/pagefind/integration_tests/node_api/node_base/close-the-pagefind-backend.toolproof.yml b/pagefind/integration_tests/node_api/node_base/close-the-pagefind-backend.toolproof.yml new file mode 100644 index 00000000..df646df6 --- /dev/null +++ b/pagefind/integration_tests/node_api/node_base/close-the-pagefind-backend.toolproof.yml @@ -0,0 +1,23 @@ +name: Node API Base Tests > Close the Pagefind backend +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.js" file with the content {js} + js: |2- + import * as pagefind from "pagefind"; + + const run = async () => { + const { index } = await pagefind.createIndex(); + const { errors, files } = await index.getFiles(); + console.log(files.map(f => f.path).join(', ')); + await pagefind.close(); + const { errors: es } = await index.getFiles(); + console.log(`After close: ${es.join(',')}`); + } + run(); + - step: >- + I run "cd public && npm i && PAGEFIND_BINARY_PATH=%pagefind_exec_path% + node index.js" + - step: stdout should contain "pagefind.js" + - step: >- + stdout should contain "After close: Invalid index, does not yet exist in + the Pagefind service" diff --git a/pagefind/integration_tests/node_api/node_base/force-language-takes-precedence-over-records.toolproof.yml b/pagefind/integration_tests/node_api/node_base/force-language-takes-precedence-over-records.toolproof.yml new file mode 100644 index 00000000..6c11dfe9 --- /dev/null +++ b/pagefind/integration_tests/node_api/node_base/force-language-takes-precedence-over-records.toolproof.yml @@ -0,0 +1,38 @@ +name: Node API Base Tests > Force language takes precedence over records +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.js" file with the content {js} + js: |- + import * as pagefind from "pagefind"; + import fs from "fs"; + import path from "path"; + + const run = async () => { + const { index } = await pagefind.createIndex({ + forceLanguage: "fr" + }); + await index.addCustomRecord({ + url: "/one/", + content: "Testing file #1", + language: "pt" + }); + await index.addHTMLFile({sourcePath: "two/index.html", content: "

Testing file #2

"}); + await index.writeFiles(); + + console.log("✨!"); + } + + run(); + - step: >- + I run "cd public && npm i && PAGEFIND_BINARY_PATH=%pagefind_exec_path% + node index.js" + - step: stdout should contain "✨!" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I run "ls -lh public/pagefind/wasm.unknown.pagefind" + notes: 'TODO: Build a file existence check into toolproof' + - step: I run "ls -lh public/pagefind/wasm.fr.pagefind" + notes: 'TODO: Build a file existence check into toolproof' + - step: I run "ls -lh public/pagefind/wasm.pt.pagefind" and expect it to fail + notes: 'TODO: Build a file existence check into toolproof' + - step: I run "ls -lh public/pagefind/wasm.en.pagefind" and expect it to fail + notes: 'TODO: Build a file existence check into toolproof' diff --git a/pagefind/integration_tests/node_api/node_base/pagefind-empty-index-returns-assets.toolproof.yml b/pagefind/integration_tests/node_api/node_base/pagefind-empty-index-returns-assets.toolproof.yml new file mode 100644 index 00000000..8cfe5018 --- /dev/null +++ b/pagefind/integration_tests/node_api/node_base/pagefind-empty-index-returns-assets.toolproof.yml @@ -0,0 +1,22 @@ +name: Node API Base Tests > Pagefind empty index returns assets +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.js" file with the content {js} + js: |2- + import * as pagefind from "pagefind"; + + const run = async () => { + const { index } = await pagefind.createIndex(); + const { errors, files } = await index.getFiles(); + console.log(files.map(f => f.path).join(', ')); + } + run(); + - step: >- + I run "cd public && npm i && PAGEFIND_BINARY_PATH=%pagefind_exec_path% + node index.js" + - step: stdout should contain "pagefind.js" + - step: stdout should contain "pagefind-ui.js" + - step: stdout should contain "pagefind-ui.css" + - step: stdout should contain "pagefind-modular-ui.js" + - step: stdout should contain "pagefind-modular-ui.css" + - step: stdout should contain "wasm.unknown.pagefind" diff --git a/pagefind/integration_tests/node_api/node_base/pagefind-error-handling.toolproof.yml b/pagefind/integration_tests/node_api/node_base/pagefind-error-handling.toolproof.yml new file mode 100644 index 00000000..1679f396 --- /dev/null +++ b/pagefind/integration_tests/node_api/node_base/pagefind-error-handling.toolproof.yml @@ -0,0 +1,29 @@ +name: Node API Base Tests > Pagefind error handling +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.js" file with the content {js} + js: |2- + import * as pagefind from "pagefind"; + + const bad = async () => { + const { index } = await pagefind.createIndex(); + await index.deleteIndex(); + const { errors, files } = await index.getFiles(); + console.log(JSON.stringify(errors)); + + try { + const response = await pagefind.createIndex({ + rootSelector: 5 + }); + } catch(e) { + console.log(e.toString()); + } + } + bad(); + - step: >- + I run "cd public && npm i && PAGEFIND_BINARY_PATH=%pagefind_exec_path% + node index.js" + - step: 'stdout should contain "invalid type: integer `5`"' + - step: >- + stdout should contain "Index has been deleted from the Pagefind service + and no longer exists" diff --git a/pagefind/integration_tests/node_api/node_base/pagefind-service-config.toolproof.yml b/pagefind/integration_tests/node_api/node_base/pagefind-service-config.toolproof.yml new file mode 100644 index 00000000..d1335725 --- /dev/null +++ b/pagefind/integration_tests/node_api/node_base/pagefind-service-config.toolproof.yml @@ -0,0 +1,39 @@ +name: Node API Base Tests > Pagefind service config +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.js" file with the content {js} + js: |2- + import * as pagefind from "pagefind"; + + const run = async () => { + const { index } = await pagefind.createIndex({ + rootSelector: "h1", + excludeSelectors: ["span"], + keepIndexUrl: true, + }); + await index.addHTMLFile({sourcePath: "dogs/index.html", content: "

Testing, testing

"}); + await index.writeFiles(); + console.log(`Successfully wrote files`); + } + + run(); + - step: >- + I run "cd public && npm i && PAGEFIND_BINARY_PATH=%pagefind_exec_path% + node index.js" + - step: stdout should contain "Successfully wrote files" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/pagefind/pagefind.js"); + + let search = await pagefind.search("testing"); + + let data = await search.results[0].data(); + document.querySelector('[data-url]').innerText = `${data.url} • ${data.content}`; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-url]"); + toolproof.assert_eq(val.innerHTML, `/dogs/index.html • Testing,`); diff --git a/pagefind/integration_tests/partial_matching/background.toolproof.yml b/pagefind/integration_tests/partial_matching/background.toolproof.yml new file mode 100644 index 00000000..9dfece36 --- /dev/null +++ b/pagefind/integration_tests/partial_matching/background.toolproof.yml @@ -0,0 +1,4 @@ +name: partial_matching > Partial Matching > Background +type: reference +steps: + - step: I have the environment variable "PAGEFIND_SITE" set to "public" diff --git a/pagefind/integration_tests/partial_matching/search-will-return-pages-that-match---out-of---words.toolproof.yml b/pagefind/integration_tests/partial_matching/search-will-return-pages-that-match---out-of---words.toolproof.yml new file mode 100644 index 00000000..18dec2cc --- /dev/null +++ b/pagefind/integration_tests/partial_matching/search-will-return-pages-that-match---out-of---words.toolproof.yml @@ -0,0 +1,28 @@ +#TODO: This is an intentionally skipped test — add skipping to toolproof. + +type: reference +name: Partial Matching > Search will return pages that match 2 out of 3 words +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/cat/index.html" file with the content {html} + html: >- +

hello + world

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/pagefind/pagefind.js"); + + let search = await pagefind.search("hello there world"); + + let data = await search.results[0].data(); + document.querySelector('[data-url]').innerText = data.url; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-url]"); + toolproof.assert_eq(val.innerHTML, `/cat/`); diff --git a/pagefind/integration_tests/sanity/cli-tests-are-working.toolproof.yml b/pagefind/integration_tests/sanity/cli-tests-are-working.toolproof.yml new file mode 100644 index 00000000..bf41224e --- /dev/null +++ b/pagefind/integration_tests/sanity/cli-tests-are-working.toolproof.yml @@ -0,0 +1,6 @@ +name: Sanity Tests > CLI tests are working +steps: + - step: I have a "public/index.html" file with the content {html} + html:

a

+ - step: I run "%pagefind_exec_path% --site public" + - step: stdout should contain "Running Pagefind" diff --git a/pagefind/integration_tests/sanity/web-tests-are-working.toolproof.yml b/pagefind/integration_tests/sanity/web-tests-are-working.toolproof.yml new file mode 100644 index 00000000..dbf1e445 --- /dev/null +++ b/pagefind/integration_tests/sanity/web-tests-are-working.toolproof.yml @@ -0,0 +1,12 @@ +name: Sanity Tests > Web tests are working +steps: + - step: I have a "public/index.html" file with the content {html} + html: >- +

Hello!

+ - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("h1"); + toolproof.assert_eq(val.innerHTML, `Hello!`); diff --git a/pagefind/integration_tests/scoring_custom/background.toolproof.yml b/pagefind/integration_tests/scoring_custom/background.toolproof.yml new file mode 100644 index 00000000..9e5a3de7 --- /dev/null +++ b/pagefind/integration_tests/scoring_custom/background.toolproof.yml @@ -0,0 +1,29 @@ +name: scoring_custom > Result Scoring > Background +type: reference +steps: + - step: I have the environment variable "PAGEFIND_SITE" set to "public" + - step: I have a "public/index.html" file with the content {html} + html: |- + + - step: I have a "public/latin-1/index.html" file with the content {html} + html: >- +

Maecenas sed diam + eget risus varius blandit sit amet non common

+ - step: I have a "public/latin-2/index.html" file with the content {html} + html: >- +

Cras justo odio, + common ac facilisis in, egestas eget quam.

+ - step: I have a "public/latin-3/index.html" file with the content {html} + html: >- +

Donec sed odio + dui.

+ - step: I have a "public/latin-4/index.html" file with the content {html} + html: >- +

Vivamus sagittis + lacus vel augue laoreet rutrum faucibus dolor auctor.

+ - step: I have a "public/latin-5/index.html" file with the content {html} + html: >- +

Integer posuere erat + a ante venenatis dapibus posuere velit aliquet..

diff --git a/pagefind/integration_tests/scoring_custom/page-length-ranking-can-be-configured.toolproof.yml b/pagefind/integration_tests/scoring_custom/page-length-ranking-can-be-configured.toolproof.yml new file mode 100644 index 00000000..3173c2c1 --- /dev/null +++ b/pagefind/integration_tests/scoring_custom/page-length-ranking-can-be-configured.toolproof.yml @@ -0,0 +1,81 @@ +name: Result Scoring > Page length ranking can be configured +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/longer/index.html" file with the content {html} + html: >- +

This post is quite + long, and talks about terracotta at length.

+ +

Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum + nibh, ut fermentum terracotta justo sit amet risus. Donec sed odio dui. + Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis + vestibulum. Nulla vitae elit libero, a pharetra augue. Aenean lacinia + bibendum nulla sed consectetur. Donec id elit non mi porta gravida at eget + metus. Maecenas faucibus mollis interdum.

+ +

Integer terracotta erat a ante venenatis dapibus posuere velit aliquet. + Vivamus sagittis lacus vel augue laoreet rutrum faucibus terracotta + auctor. Nullam quis risus eget urna mollis ornare vel eu leo. Aenean + lacinia bibendum nulla sed consectetur.

+ +

Praesent commodo cursus magna, vel scelerisque terracotta consectetur + et. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum + nibh, ut fermentum massa justo sit amet risus. Lorem ipsum dolor sit amet, + consectetur adipiscing elit. Curabitur blandit tempus + porttitor.

+ - step: I have a "public/shorter/index.html" file with the content {html} + html: >- +

This is a shorter + terracotta page.

+ +

Sed posuere consectetur est at lobortis.

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + await pagefind.options({ + ranking: { + pageLength: 1.0 + } + }); + + + let search = await pagefind.search(`terracotta`); + + + let data = await Promise.all(search.results.map(result => result.data())); + + document.querySelector('[data-result]').innerText = data.map(d => + d.url).join(', '); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `/shorter/, /longer/`); + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + await pagefind.options({ + ranking: { + pageLength: 0.0 + } + }); + + + let search = await pagefind.search(`terracotta`); + + + let data = await Promise.all(search.results.map(result => result.data())); + + document.querySelector('[data-result]').innerText = data.map(d => + d.url).join(', '); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `/longer/, /shorter/`); diff --git a/pagefind/integration_tests/scoring_custom/term-frequency-vs-raw-count-can-be-configured.toolproof.yml b/pagefind/integration_tests/scoring_custom/term-frequency-vs-raw-count-can-be-configured.toolproof.yml new file mode 100644 index 00000000..ae453ad3 --- /dev/null +++ b/pagefind/integration_tests/scoring_custom/term-frequency-vs-raw-count-can-be-configured.toolproof.yml @@ -0,0 +1,73 @@ +name: Result Scoring > Term frequency vs raw count can be configured +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/longer/index.html" file with the content {html} + html: >- +

This post is quite + long, and talks about terracotta at length.

+ +

Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum + nibh, ut fermentum terracotta justo sit amet risus. Donec sed odio dui. + Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis + vestibulum. Nulla vitae elit libero, a pharetra augue. Aenean lacinia + bibendum nulla sed consectetur. Donec id elit non mi porta gravida at eget + metus. Maecenas faucibus mollis interdum.

+ +

Integer erat a ante venenatis dapibus posuere velit aliquet. Vivamus + sagittis lacus vel augue laoreet rutrum faucibus auctor. Nullam quis risus + eget urna mollis ornare vel eu leo. Aenean lacinia bibendum nulla sed + consectetur.

+ +

Praesent commodo cursus magna, vel scelerisque consectetur et. Fusce + dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut + fermentum massa justo sit amet risus. Lorem ipsum dolor sit amet, + consectetur adipiscing elit. Curabitur blandit tempus + porttitor.

+ - step: I have a "public/shorter/index.html" file with the content {html} + html: >- +

This is a shorter + terracotta page.

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search(`terracotta`); + + + let data = await Promise.all(search.results.map(result => result.data())); + + document.querySelector('[data-result]').innerText = data.map(d => + d.url).join(', '); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `/shorter/, /longer/`); + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + await pagefind.options({ + ranking: { + termFrequency: 0.0 + } + }); + + + let search = await pagefind.search(`terracotta`); + + + let data = await Promise.all(search.results.map(result => result.data())); + + document.querySelector('[data-result]').innerText = data.map(d => + d.url).join(', '); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `/longer/, /shorter/`); diff --git a/pagefind/integration_tests/scoring_custom/term-saturation-can-be-configured.toolproof.yml b/pagefind/integration_tests/scoring_custom/term-saturation-can-be-configured.toolproof.yml new file mode 100644 index 00000000..2ad7d52b --- /dev/null +++ b/pagefind/integration_tests/scoring_custom/term-saturation-can-be-configured.toolproof.yml @@ -0,0 +1,63 @@ +name: Result Scoring > Term saturation can be configured +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/lots/index.html" file with the content {html} + html: |- +

post

+

common and common and common and unrelated

+ - step: >- + I have a "public/slightly-less-than-lots/index.html" file with the content + {html} + html: |- +

post

+

common and common and unrelated and unrelated

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + await pagefind.options({ + ranking: { + termSaturation: 2.0 + } + }); + + + let search = await pagefind.search(`common post`); + + + let data = await Promise.all(search.results.map(result => result.data())); + + document.querySelector('[data-result]').innerText = data.map(d => + d.url).join(', '); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `/slightly-less-than-lots/, /lots/`); + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + await pagefind.options({ + ranking: { + termSaturation: 0.1 + } + }); + + + let search = await pagefind.search(`common post`); + + + let data = await Promise.all(search.results.map(result => result.data())); + + document.querySelector('[data-result]').innerText = data.map(d => + d.url).join(', '); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `/lots/, /slightly-less-than-lots/`); diff --git a/pagefind/integration_tests/scoring_custom/term-similarity-ranking-can-be-configured.toolproof.yml b/pagefind/integration_tests/scoring_custom/term-similarity-ranking-can-be-configured.toolproof.yml new file mode 100644 index 00000000..21c50bb7 --- /dev/null +++ b/pagefind/integration_tests/scoring_custom/term-similarity-ranking-can-be-configured.toolproof.yml @@ -0,0 +1,55 @@ +name: Result Scoring > Term similarity ranking can be configured +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/similar-term/index.html" file with the content {html} + html: >- +

This post talks about + abcdef once

+ - step: I have a "public/dissimilar-term/index.html" file with the content {html} + html: >- +

This post talks about + abcdefghijklmnopqrstuv — twice! abcdefghijklmnopqrstuv

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search(`abcdef`); + + + let data = await Promise.all(search.results.map(result => result.data())); + + document.querySelector('[data-result]').innerText = data.map(d => + d.url).join(', '); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `/similar-term/, /dissimilar-term/`); + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + await pagefind.options({ + ranking: { + termSimilarity: 0.0 + } + }); + + + let search = await pagefind.search(`abcdef`); + + + let data = await Promise.all(search.results.map(result => result.data())); + + document.querySelector('[data-result]').innerText = data.map(d => + d.url).join(', '); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `/dissimilar-term/, /similar-term/`); diff --git a/pagefind/integration_tests/scoring_defaults/background.toolproof.yml b/pagefind/integration_tests/scoring_defaults/background.toolproof.yml new file mode 100644 index 00000000..08c70f42 --- /dev/null +++ b/pagefind/integration_tests/scoring_defaults/background.toolproof.yml @@ -0,0 +1,22 @@ +name: scoring_defaults > Result Scoring > Background +type: reference +steps: + - step: I have the environment variable "PAGEFIND_SITE" set to "public" + - step: I have a "public/index.html" file with the content {html} + html: |- + + - step: I have a "public/cat/index.html" file with the content {html} + html: >- +

Happy cat post, that + later mentions dogs in the context of cats

+ - step: I have a "public/dog/index.html" file with the content {html} + html: >- +

A post about dogs vs + cats (but mainly dogs)

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: I serve the directory "public" + - step: In my browser, I load "/" diff --git a/pagefind/integration_tests/scoring_defaults/search-results-are-ranked-by-word-frequency.toolproof.yml b/pagefind/integration_tests/scoring_defaults/search-results-are-ranked-by-word-frequency.toolproof.yml new file mode 100644 index 00000000..8da1572f --- /dev/null +++ b/pagefind/integration_tests/scoring_defaults/search-results-are-ranked-by-word-frequency.toolproof.yml @@ -0,0 +1,51 @@ +name: Result Scoring > Search results are ranked by word frequency +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search(`cat`); + + + document.querySelector('[data-count]').innerText = + `${search.results.length} result(s)`; + + let data = await Promise.all(search.results.map(result => result.data())); + + document.querySelector('[data-result]').innerText = data.map(d => + d.url).join(', '); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-count]"); + toolproof.assert_eq(val.innerHTML, `2 result(s)`); + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `/cat/, /dog/`); + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search(`dog`); + + + document.querySelector('[data-count]').innerText = + `${search.results.length} result(s)`; + + let data = await Promise.all(search.results.map(result => result.data())); + + document.querySelector('[data-result]').innerText = data.map(d => + d.url).join(', '); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-count]"); + toolproof.assert_eq(val.innerHTML, `2 result(s)`); + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `/dog/, /cat/`); diff --git a/pagefind/integration_tests/scoring_defaults/search-terms-in-close-proximity-rank-higher-in-results.toolproof.yml b/pagefind/integration_tests/scoring_defaults/search-terms-in-close-proximity-rank-higher-in-results.toolproof.yml new file mode 100644 index 00000000..3f8b912d --- /dev/null +++ b/pagefind/integration_tests/scoring_defaults/search-terms-in-close-proximity-rank-higher-in-results.toolproof.yml @@ -0,0 +1,54 @@ +#TODO: This is an intentionally skipped test — add skipping to toolproof. + +type: reference +name: Result Scoring > Search terms in close proximity rank higher in results +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search(`cats dogs`); + + + document.querySelector('[data-count]').innerText = + `${search.results.length} result(s)`; + + let data = await Promise.all(search.results.map(result => result.data())); + + document.querySelector('[data-result]').innerText = data.map(d => + d.url).join(', '); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-count]"); + toolproof.assert_eq(val.innerHTML, `2 result(s)`); + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `/dog/, /cat/`); + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search(`cats posts`); + + + document.querySelector('[data-count]').innerText = + `${search.results.length} result(s)`; + + let data = await Promise.all(search.results.map(result => result.data())); + + document.querySelector('[data-result]').innerText = data.map(d => + d.url).join(', '); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-count]"); + toolproof.assert_eq(val.innerHTML, `2 result(s)`); + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `/cat/, /dog/`); diff --git a/pagefind/integration_tests/search_options/background.toolproof.yml b/pagefind/integration_tests/search_options/background.toolproof.yml new file mode 100644 index 00000000..e30303c5 --- /dev/null +++ b/pagefind/integration_tests/search_options/background.toolproof.yml @@ -0,0 +1,4 @@ +name: search_options > Search Options > Background +type: reference +steps: + - step: I have the environment variable "PAGEFIND_SITE" set to "public" diff --git a/pagefind/integration_tests/search_options/base-url-auto-detects-the-default-directory-being-moved.toolproof.yml b/pagefind/integration_tests/search_options/base-url-auto-detects-the-default-directory-being-moved.toolproof.yml new file mode 100644 index 00000000..8bb67b68 --- /dev/null +++ b/pagefind/integration_tests/search_options/base-url-auto-detects-the-default-directory-being-moved.toolproof.yml @@ -0,0 +1,29 @@ +name: Search Options > Base URL auto-detects the default directory being moved +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.html" file with the content {html} + html: >- +

Nothing

+ - step: I have a "public/cat/index.html" file with the content {html} + html: >- +

world

+ - step: I run "%pagefind_exec_path% --output-subdir blog/pagefind" + - step: stdout should contain "Running Pagefind" + - step: The file "public/blog/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/blog/pagefind/pagefind.js"); + + let search = await pagefind.search("world"); + + let data = await search.results[0].data(); + document.querySelector('[data-url]').innerText = data.url; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-url]"); + toolproof.assert_eq(val.innerHTML, `/blog/cat/`); diff --git a/pagefind/integration_tests/search_options/base-url-can-be-configured.toolproof.yml b/pagefind/integration_tests/search_options/base-url-can-be-configured.toolproof.yml new file mode 100644 index 00000000..28f859f0 --- /dev/null +++ b/pagefind/integration_tests/search_options/base-url-can-be-configured.toolproof.yml @@ -0,0 +1,32 @@ +name: Search Options > Base URL can be configured +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.html" file with the content {html} + html: >- +

Nothing

+ - step: I have a "public/cat/index.html" file with the content {html} + html: >- +

world

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/pagefind/pagefind.js"); + await pagefind.options({ + baseUrl: "/docs/" + }); + + let search = await pagefind.search("world"); + + let data = await search.results[0].data(); + document.querySelector('[data-url]').innerText = data.url; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-url]"); + toolproof.assert_eq(val.innerHTML, `/docs/cat/`); diff --git a/pagefind/integration_tests/search_options/keep-index-url-can-be-configured.toolproof.yml b/pagefind/integration_tests/search_options/keep-index-url-can-be-configured.toolproof.yml new file mode 100644 index 00000000..200a46af --- /dev/null +++ b/pagefind/integration_tests/search_options/keep-index-url-can-be-configured.toolproof.yml @@ -0,0 +1,31 @@ +name: Search Options > Keep Index URL can be configured +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.html" file with the content {html} + html: >- +

Nothing

+ - step: I have a "public/cat/index.html" file with the content {html} + html: >- +

world

+ - step: >- + I run "%pagefind_exec_path% --output-subdir blog/pagefind + --keep-index-url" + - step: stdout should contain "Running Pagefind" + - step: The file "public/blog/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/blog/pagefind/pagefind.js"); + + let search = await pagefind.search("world"); + + let data = await search.results[0].data(); + document.querySelector('[data-url]').innerText = data.url; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-url]"); + toolproof.assert_eq(val.innerHTML, `/blog/cat/index.html`); diff --git a/pagefind/integration_tests/sentences/background.toolproof.yml b/pagefind/integration_tests/sentences/background.toolproof.yml new file mode 100644 index 00000000..9ac7b0a9 --- /dev/null +++ b/pagefind/integration_tests/sentences/background.toolproof.yml @@ -0,0 +1,8 @@ +name: sentences > Sentence Building Tests > Background +type: reference +steps: + - step: I have the environment variable "PAGEFIND_SITE" set to "public" + - step: I have a "public/index.html" file with the content {html} + html: >- +

Nothing

diff --git a/pagefind/integration_tests/sentences/pagefind-doesn-t-join-inline-elements-as-sentences.toolproof.yml b/pagefind/integration_tests/sentences/pagefind-doesn-t-join-inline-elements-as-sentences.toolproof.yml new file mode 100644 index 00000000..d9e68001 --- /dev/null +++ b/pagefind/integration_tests/sentences/pagefind-doesn-t-join-inline-elements-as-sentences.toolproof.yml @@ -0,0 +1,29 @@ +name: Sentence Building Tests > Pagefind doesn't join inline elements as sentences +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/apiary/index.html" file with the content {html} + html: >- + HelloWorld + - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search("h"); + + + let pages = await Promise.all(search.results.map(r => r.data())); + + document.querySelector('[data-result]').innerText = pages.map(p => + p.content).join(", "); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `HelloWorld`); diff --git a/pagefind/integration_tests/sentences/pagefind-ignores-redundant-zero-width-spaces.toolproof.yml b/pagefind/integration_tests/sentences/pagefind-ignores-redundant-zero-width-spaces.toolproof.yml new file mode 100644 index 00000000..578f6f74 --- /dev/null +++ b/pagefind/integration_tests/sentences/pagefind-ignores-redundant-zero-width-spaces.toolproof.yml @@ -0,0 +1,29 @@ +name: Sentence Building Tests > Pagefind ignores redundant zero-width spaces +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/apiary/index.html" file with the content {html} + html: >- +

Hello ​ + World

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search("w"); + + + let pages = await Promise.all(search.results.map(r => r.data())); + + document.querySelector('[data-result]').innerHTML = pages.map(p => + p.excerpt).join(", "); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `Hello World.`); diff --git a/pagefind/integration_tests/sentences/pagefind-joins-block-elements-as-sentences.toolproof.yml b/pagefind/integration_tests/sentences/pagefind-joins-block-elements-as-sentences.toolproof.yml new file mode 100644 index 00000000..45f51fd1 --- /dev/null +++ b/pagefind/integration_tests/sentences/pagefind-joins-block-elements-as-sentences.toolproof.yml @@ -0,0 +1,29 @@ +name: Sentence Building Tests > Pagefind joins block elements as sentences +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/apiary/index.html" file with the content {html} + html: >- +

Hello

World

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search("h"); + + + let pages = await Promise.all(search.results.map(r => r.data())); + + document.querySelector('[data-result]').innerText = pages.map(p => + p.content).join(", "); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `Hello. World.`); diff --git a/pagefind/integration_tests/sentences/pagefind-treats-br-tags-as-spaces.toolproof.yml b/pagefind/integration_tests/sentences/pagefind-treats-br-tags-as-spaces.toolproof.yml new file mode 100644 index 00000000..40ff4004 --- /dev/null +++ b/pagefind/integration_tests/sentences/pagefind-treats-br-tags-as-spaces.toolproof.yml @@ -0,0 +1,29 @@ +name: Sentence Building Tests > Pagefind treats br tags as spaces +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/apiary/index.html" file with the content {html} + html: >- +

Hello
World

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search("w"); + + + let pages = await Promise.all(search.results.map(r => r.data())); + + document.querySelector('[data-result]').innerText = pages.map(p => + p.content).join(", "); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `Hello World.`); diff --git a/pagefind/integration_tests/sorting/background.toolproof.yml b/pagefind/integration_tests/sorting/background.toolproof.yml new file mode 100644 index 00000000..d5df66f1 --- /dev/null +++ b/pagefind/integration_tests/sorting/background.toolproof.yml @@ -0,0 +1,46 @@ +name: sorting > Result Sorting > Background +type: reference +steps: + - step: I have the environment variable "PAGEFIND_SITE" set to "public" + - step: I have a "public/index.html" file with the content {html} + html: |- +

+

+ - step: I have a "public/robe/painte/index.html" file with the content {html} + html: >- + + +

Robe Painte ™️

+ + + + 1 + + black + - step: I have a "public/robe/megapointe/index.html" file with the content {html} + html: >- + + +

Robe MegaPointe ™️

+ + + + 9.5 + + white + - step: I have a "public/robe/superspikie/index.html" file with the content {html} + html: >- + 5105 + +

Robe SuperSpikie ™️

+ + + + 10 + - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: I serve the directory "public" + - step: In my browser, I load "/" diff --git a/pagefind/integration_tests/sorting/pagefind-can-sort-results-by-an-alphabetical-attribute.toolproof.yml b/pagefind/integration_tests/sorting/pagefind-can-sort-results-by-an-alphabetical-attribute.toolproof.yml new file mode 100644 index 00000000..7568d78d --- /dev/null +++ b/pagefind/integration_tests/sorting/pagefind-can-sort-results-by-an-alphabetical-attribute.toolproof.yml @@ -0,0 +1,39 @@ +name: Result Sorting > Pagefind can sort results by an alphabetical attribute +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let asc_search = await pagefind.search("Robe", { sort: { model: "asc" } + }); + + let asc_data = await Promise.all(asc_search.results.map(result => + result.data())); + + document.querySelector('[data-asc]').innerText = asc_data.map(d => + d.url).join(', '); + + + let desc_search = await pagefind.search("Robe", { sort: { model: "desc" } + }); + + let desc_data = await Promise.all(desc_search.results.map(result => + result.data())); + + document.querySelector('[data-desc]').innerText = desc_data.map(d => + d.url).join(', '); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: >- + let val = await toolproof.querySelector("[data-asc]"); + + toolproof.assert_eq(val.innerHTML, `/robe/megapointe/, /robe/painte/, + /robe/superspikie/`); + - step: In my browser, I evaluate {js} + js: >- + let val = await toolproof.querySelector("[data-desc]"); + + toolproof.assert_eq(val.innerHTML, `/robe/superspikie/, /robe/painte/, + /robe/megapointe/`); diff --git a/pagefind/integration_tests/sorting/pagefind-can-sort-results-by-an-automatically-detected-float.toolproof.yml b/pagefind/integration_tests/sorting/pagefind-can-sort-results-by-an-automatically-detected-float.toolproof.yml new file mode 100644 index 00000000..ba90a7b5 --- /dev/null +++ b/pagefind/integration_tests/sorting/pagefind-can-sort-results-by-an-automatically-detected-float.toolproof.yml @@ -0,0 +1,39 @@ +name: Result Sorting > Pagefind can sort results by an automatically detected float +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let asc_search = await pagefind.search("Robe", { sort: { weight: "asc" } + }); + + let asc_data = await Promise.all(asc_search.results.map(result => + result.data())); + + document.querySelector('[data-asc]').innerText = asc_data.map(d => + d.url).join(', '); + + + let desc_search = await pagefind.search("Robe", { sort: { weight: "desc" } + }); + + let desc_data = await Promise.all(desc_search.results.map(result => + result.data())); + + document.querySelector('[data-desc]').innerText = desc_data.map(d => + d.url).join(', '); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: >- + let val = await toolproof.querySelector("[data-asc]"); + + toolproof.assert_eq(val.innerHTML, `/robe/painte/, /robe/megapointe/, + /robe/superspikie/`); + - step: In my browser, I evaluate {js} + js: >- + let val = await toolproof.querySelector("[data-desc]"); + + toolproof.assert_eq(val.innerHTML, `/robe/superspikie/, /robe/megapointe/, + /robe/painte/`); diff --git a/pagefind/integration_tests/sorting/pagefind-can-sort-results-by-an-automatically-detected-integer.toolproof.yml b/pagefind/integration_tests/sorting/pagefind-can-sort-results-by-an-automatically-detected-integer.toolproof.yml new file mode 100644 index 00000000..94c22c0e --- /dev/null +++ b/pagefind/integration_tests/sorting/pagefind-can-sort-results-by-an-automatically-detected-integer.toolproof.yml @@ -0,0 +1,41 @@ +name: >- + Result Sorting > Pagefind can sort results by an automatically detected + integer +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let asc_search = await pagefind.search("Robe", { sort: { lumens: "asc" } + }); + + let asc_data = await Promise.all(asc_search.results.map(result => + result.data())); + + document.querySelector('[data-asc]').innerText = asc_data.map(d => + d.url).join(', '); + + + let desc_search = await pagefind.search("Robe", { sort: { lumens: "desc" } + }); + + let desc_data = await Promise.all(desc_search.results.map(result => + result.data())); + + document.querySelector('[data-desc]').innerText = desc_data.map(d => + d.url).join(', '); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: >- + let val = await toolproof.querySelector("[data-asc]"); + + toolproof.assert_eq(val.innerHTML, `/robe/superspikie/, /robe/megapointe/, + /robe/painte/`); + - step: In my browser, I evaluate {js} + js: >- + let val = await toolproof.querySelector("[data-desc]"); + + toolproof.assert_eq(val.innerHTML, `/robe/painte/, /robe/megapointe/, + /robe/superspikie/`); diff --git a/pagefind/integration_tests/sorting/pagefind-can-sort-results-by-mixed-floats-and-integers.toolproof.yml b/pagefind/integration_tests/sorting/pagefind-can-sort-results-by-mixed-floats-and-integers.toolproof.yml new file mode 100644 index 00000000..d1d3e1bc --- /dev/null +++ b/pagefind/integration_tests/sorting/pagefind-can-sort-results-by-mixed-floats-and-integers.toolproof.yml @@ -0,0 +1,39 @@ +name: Result Sorting > Pagefind can sort results by mixed floats and integers +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let asc_search = await pagefind.search("Robe", { sort: { mixed: "asc" } + }); + + let asc_data = await Promise.all(asc_search.results.map(result => + result.data())); + + document.querySelector('[data-asc]').innerText = asc_data.map(d => + d.url).join(', '); + + + let desc_search = await pagefind.search("Robe", { sort: { mixed: "desc" } + }); + + let desc_data = await Promise.all(desc_search.results.map(result => + result.data())); + + document.querySelector('[data-desc]').innerText = desc_data.map(d => + d.url).join(', '); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: >- + let val = await toolproof.querySelector("[data-asc]"); + + toolproof.assert_eq(val.innerHTML, `/robe/painte/, /robe/megapointe/, + /robe/superspikie/`); + - step: In my browser, I evaluate {js} + js: >- + let val = await toolproof.querySelector("[data-desc]"); + + toolproof.assert_eq(val.innerHTML, `/robe/superspikie/, /robe/megapointe/, + /robe/painte/`); diff --git a/pagefind/integration_tests/sorting/pagefind-excludes-pages-that-aren-t-tagged-with-the-provided-sort-option.toolproof.yml b/pagefind/integration_tests/sorting/pagefind-excludes-pages-that-aren-t-tagged-with-the-provided-sort-option.toolproof.yml new file mode 100644 index 00000000..1079bfd8 --- /dev/null +++ b/pagefind/integration_tests/sorting/pagefind-excludes-pages-that-aren-t-tagged-with-the-provided-sort-option.toolproof.yml @@ -0,0 +1,37 @@ +name: >- + Result Sorting > Pagefind excludes pages that aren't tagged with the provided + sort option +steps: + - ref: ./background.toolproof.yml + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let asc_search = await pagefind.search("Robe", { sort: { color: "asc" } + }); + + let asc_data = await Promise.all(asc_search.results.map(result => + result.data())); + + document.querySelector('[data-asc]').innerText = asc_data.map(d => + d.url).join(', '); + + + let desc_search = await pagefind.search("Robe", { sort: { color: "desc" } + }); + + let desc_data = await Promise.all(desc_search.results.map(result => + result.data())); + + document.querySelector('[data-desc]').innerText = desc_data.map(d => + d.url).join(', '); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-asc]"); + toolproof.assert_eq(val.innerHTML, `/robe/painte/, /robe/megapointe/`); + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-desc]"); + toolproof.assert_eq(val.innerHTML, `/robe/megapointe/, /robe/painte/`); diff --git a/pagefind/integration_tests/stemming/background.toolproof.yml b/pagefind/integration_tests/stemming/background.toolproof.yml new file mode 100644 index 00000000..8f087e44 --- /dev/null +++ b/pagefind/integration_tests/stemming/background.toolproof.yml @@ -0,0 +1,9 @@ +name: stemming > Word Stemming > Background +type: reference +steps: + - step: I have the environment variable "PAGEFIND_SITE" set to "public" + - step: I have a "public/index.html" file with the content {html} + html: |- + diff --git a/pagefind/integration_tests/stemming/search-is-case-independent.toolproof.yml b/pagefind/integration_tests/stemming/search-is-case-independent.toolproof.yml new file mode 100644 index 00000000..f242da54 --- /dev/null +++ b/pagefind/integration_tests/stemming/search-is-case-independent.toolproof.yml @@ -0,0 +1,25 @@ +name: Word Stemming > Search is case independent +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/cat/index.html" file with the content {html} + html: >- +

the cat is + Meowing

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/pagefind/pagefind.js"); + + let search = await pagefind.search("meOWings"); + + let data = await search.results[0].data(); + document.querySelector('[data-result]').innerText = data.url; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `/cat/`); diff --git a/pagefind/integration_tests/stemming/search-is-punctuation-independent.toolproof.yml b/pagefind/integration_tests/stemming/search-is-punctuation-independent.toolproof.yml new file mode 100644 index 00000000..39162434 --- /dev/null +++ b/pagefind/integration_tests/stemming/search-is-punctuation-independent.toolproof.yml @@ -0,0 +1,25 @@ +name: Word Stemming > Search is punctuation independent +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/apple/index.html" file with the content {html} + html: >- +

My laptop doesn't + have a USB-A port

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/pagefind/pagefind.js"); + + let search = await pagefind.search("usb[a"); + + let data = await search.results[0].data(); + document.querySelector('[data-result]').innerText = data.url; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `/apple/`); diff --git a/pagefind/integration_tests/stemming/searching-for-a-word-will-match-against-the-stem-of-that-word.toolproof.yml b/pagefind/integration_tests/stemming/searching-for-a-word-will-match-against-the-stem-of-that-word.toolproof.yml new file mode 100644 index 00000000..93004fe9 --- /dev/null +++ b/pagefind/integration_tests/stemming/searching-for-a-word-will-match-against-the-stem-of-that-word.toolproof.yml @@ -0,0 +1,25 @@ +name: Word Stemming > Searching for a word will match against the stem of that word +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/cat/index.html" file with the content {html} + html: >- +

the cat is + meowing

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/pagefind/pagefind.js"); + + let search = await pagefind.search("meowed"); + + let data = await search.results[0].data(); + document.querySelector('[data-result]').innerText = data.url; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `/cat/`); diff --git a/pagefind/integration_tests/stemming/searching-will-backtrack-a-word-to-find-a-prefix.toolproof.yml b/pagefind/integration_tests/stemming/searching-will-backtrack-a-word-to-find-a-prefix.toolproof.yml new file mode 100644 index 00000000..8309de56 --- /dev/null +++ b/pagefind/integration_tests/stemming/searching-will-backtrack-a-word-to-find-a-prefix.toolproof.yml @@ -0,0 +1,31 @@ +name: Word Stemming > Searching will backtrack a word to find a prefix +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/doc/index.html" file with the content {html} + html: >- +

a doc about + installation

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search("documentation"); + + + let results = await Promise.all(search.results.map(r => r.data())); + + document.querySelector('[data-result]').innerText = results.map(r => + `${r.url} • ${r.excerpt}`).join(', '); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: >- + let val = await toolproof.querySelector("[data-result]"); + + toolproof.assert_eq(val.innerHTML, `/doc/ • a <mark>doc</mark> + about installation.`); diff --git a/pagefind/integration_tests/stemming/searching-will-backtrack-a-word-to-find-a-stem.toolproof.yml b/pagefind/integration_tests/stemming/searching-will-backtrack-a-word-to-find-a-stem.toolproof.yml new file mode 100644 index 00000000..36c8e03f --- /dev/null +++ b/pagefind/integration_tests/stemming/searching-will-backtrack-a-word-to-find-a-stem.toolproof.yml @@ -0,0 +1,31 @@ +name: Word Stemming > Searching will backtrack a word to find a stem +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/doc/index.html" file with the content {html} + html: >- +

a doc about + installation

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search("installat"); + + + let results = await Promise.all(search.results.map(r => r.data())); + + document.querySelector('[data-result]').innerText = results.map(r => + `${r.url} • ${r.excerpt}`).join(', '); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: >- + let val = await toolproof.querySelector("[data-result]"); + + toolproof.assert_eq(val.innerHTML, `/doc/ • a doc about + <mark>installation.</mark>`); diff --git a/pagefind/integration_tests/suggestions/background.toolproof.yml b/pagefind/integration_tests/suggestions/background.toolproof.yml new file mode 100644 index 00000000..b72d831f --- /dev/null +++ b/pagefind/integration_tests/suggestions/background.toolproof.yml @@ -0,0 +1,9 @@ +name: suggestions > Spellcheck > Background +type: reference +steps: + - step: I have the environment variable "PAGEFIND_SITE" set to "public" + - step: I have a "public/index.html" file with the content {html} + html: |- + diff --git a/pagefind/integration_tests/suggestions/search-results-will-be-returned-for-all-extensions-of-the-word.toolproof.yml b/pagefind/integration_tests/suggestions/search-results-will-be-returned-for-all-extensions-of-the-word.toolproof.yml new file mode 100644 index 00000000..c01bccdb --- /dev/null +++ b/pagefind/integration_tests/suggestions/search-results-will-be-returned-for-all-extensions-of-the-word.toolproof.yml @@ -0,0 +1,33 @@ +name: Spellcheck > Search results will be returned for all extensions of the word +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/one/index.html" file with the content {html} + html: >- +

Hello + World

+ - step: I have a "public/two/index.html" file with the content {html} + html: >- +

Hello + Wow

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search("w"); + + + let results = await Promise.all(search.results.map(r => r.data())); + + document.querySelector('[data-result]').innerText = results.map(r => + r.url).join(', '); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-result]"); + toolproof.assert_eq(val.innerHTML, `/two/, /one/`); diff --git a/pagefind/integration_tests/suggestions/spelling-correction-can-be-returned-for-the-unique-words-in-the-dataset.toolproof.yml b/pagefind/integration_tests/suggestions/spelling-correction-can-be-returned-for-the-unique-words-in-the-dataset.toolproof.yml new file mode 100644 index 00000000..cadb0ba4 --- /dev/null +++ b/pagefind/integration_tests/suggestions/spelling-correction-can-be-returned-for-the-unique-words-in-the-dataset.toolproof.yml @@ -0,0 +1,8 @@ +#TODO: This is an intentionally skipped test — add skipping to toolproof. + +type: reference +name: >- + Spellcheck > Spelling correction can be returned for the unique words in the + dataset +steps: + - ref: ./background.toolproof.yml diff --git a/pagefind/integration_tests/ui/ui_base/background.toolproof.yml b/pagefind/integration_tests/ui/ui_base/background.toolproof.yml new file mode 100644 index 00000000..cb98b159 --- /dev/null +++ b/pagefind/integration_tests/ui/ui_base/background.toolproof.yml @@ -0,0 +1,12 @@ +name: ui/ui_base > Base UI Tests > Background +type: reference +steps: + - step: I have the environment variable "PAGEFIND_SITE" set to "public" + - step: I have a "public/index.html" file with the content {html} + html: |- + + + + diff --git a/pagefind/integration_tests/ui/ui_base/pagefind-ui-can-programmatically-filter.toolproof.yml b/pagefind/integration_tests/ui/ui_base/pagefind-ui-can-programmatically-filter.toolproof.yml new file mode 100644 index 00000000..df3c07cc --- /dev/null +++ b/pagefind/integration_tests/ui/ui_base/pagefind-ui-can-programmatically-filter.toolproof.yml @@ -0,0 +1,38 @@ +name: Base UI Tests > Pagefind UI can programmatically filter +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/res-zero/index.html" file with the content {html} + html: >- +

title title + title

+ - step: I have a "public/res-one/index.html" file with the content {html} + html: >- +

title res one

+ - step: I have a "public/res-two/index.html" file with the content {html} + html: >- +

title res two

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: |- + window.pui.triggerFilters({ "bucket": "a" }); + window.pui.triggerSearch("title"); + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector(".pagefind-ui__result-link"); + toolproof.assert_eq(val.innerHTML, `title res one`); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + window.pui.triggerFilters({ "bucket": ["b"] }); + await toolproof.waitFor(() => /res two/.test(document.querySelector(".pagefind-ui__result-link")?.innerText)); + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector(".pagefind-ui__result-link"); + toolproof.assert_eq(val.innerHTML, `title res two`); + - step: In my browser, the console should be empty diff --git a/pagefind/integration_tests/ui/ui_base/pagefind-ui-loads.toolproof.yml b/pagefind/integration_tests/ui/ui_base/pagefind-ui-loads.toolproof.yml new file mode 100644 index 00000000..096620a6 --- /dev/null +++ b/pagefind/integration_tests/ui/ui_base/pagefind-ui-loads.toolproof.yml @@ -0,0 +1,17 @@ +name: Base UI Tests > Pagefind UI loads +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/cat/index.html" file with the content {html} + html: >- +

world

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let el = await toolproof.querySelector(".pagefind-ui"); + toolproof.assert(el); diff --git a/pagefind/integration_tests/ui/ui_base/pagefind-ui-searches.toolproof.yml b/pagefind/integration_tests/ui/ui_base/pagefind-ui-searches.toolproof.yml new file mode 100644 index 00000000..54041037 --- /dev/null +++ b/pagefind/integration_tests/ui/ui_base/pagefind-ui-searches.toolproof.yml @@ -0,0 +1,19 @@ +name: Base UI Tests > Pagefind UI searches +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/cat/index.html" file with the content {html} + html: >- +

world

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: window.pui.triggerSearch("world"); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector(".pagefind-ui__result-link"); + toolproof.assert_eq(val.innerHTML, `world`); diff --git a/pagefind/integration_tests/ui/ui_highlight/background.toolproof.yml b/pagefind/integration_tests/ui/ui_highlight/background.toolproof.yml new file mode 100644 index 00000000..e8cf3d73 --- /dev/null +++ b/pagefind/integration_tests/ui/ui_highlight/background.toolproof.yml @@ -0,0 +1,4 @@ +name: ui/ui_highlight > Base UI Tests > Background +type: reference +steps: + - step: I have the environment variable "PAGEFIND_SITE" set to "public" diff --git a/pagefind/integration_tests/ui/ui_highlight/pagefind-ui-adds-highlight-query-params.toolproof.yml b/pagefind/integration_tests/ui/ui_highlight/pagefind-ui-adds-highlight-query-params.toolproof.yml new file mode 100644 index 00000000..3829fbb6 --- /dev/null +++ b/pagefind/integration_tests/ui/ui_highlight/pagefind-ui-adds-highlight-query-params.toolproof.yml @@ -0,0 +1,48 @@ +name: Base UI Tests > Pagefind UI adds highlight query params +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.html" file with the content {html} + html: >- + + + + + - step: I have a "public/cat/index.html" file with the content {html} + html: |- +

hello world

+

Hello world! How are you

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: window.pui.triggerSearch("world"); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: >- + let val = await + toolproof.querySelector(".pagefind-ui__result-link[href$='?pagefind-highlight=world']"); + + toolproof.assert_eq(val.innerHTML, `hello world`); + - step: In my browser, I evaluate {js} + js: window.pui.triggerSearch("hello world"); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: >- + let val = await + toolproof.querySelector(".pagefind-ui__result-link[href$='?pagefind-highlight=hello&pagefind-highlight=world']"); + + toolproof.assert_eq(val.innerHTML, `hello world`); + - step: In my browser, I evaluate {js} + js: window.pui.triggerSearch("hello world!"); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: >- + let val = await + toolproof.querySelector(".pagefind-ui__result-link[href$='?pagefind-highlight=hello&pagefind-highlight=world']"); + + toolproof.assert_eq(val.innerHTML, `hello world`); diff --git a/pagefind/integration_tests/ui/ui_highlight/pagefind-ui-does-not-add-highlight-query-params-by-default.toolproof.yml b/pagefind/integration_tests/ui/ui_highlight/pagefind-ui-does-not-add-highlight-query-params-by-default.toolproof.yml new file mode 100644 index 00000000..09abb551 --- /dev/null +++ b/pagefind/integration_tests/ui/ui_highlight/pagefind-ui-does-not-add-highlight-query-params-by-default.toolproof.yml @@ -0,0 +1,39 @@ +name: Base UI Tests > Pagefind UI does not add highlight query params by default +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.html" file with the content {html} + html: >- + + + + + - step: I have a "public/cat/index.html" file with the content {html} + html: |- +

hello world

+

Hello world! How are you

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: window.pui.triggerSearch("world"); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: >- + let val = await + toolproof.querySelector(".pagefind-ui__result-link[href$='/']"); + + toolproof.assert_eq(val.innerHTML, `hello world`); + - step: In my browser, I evaluate {js} + js: window.pui.triggerSearch("hello world"); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: >- + let val = await + toolproof.querySelector(".pagefind-ui__result-link[href$='/']"); + + toolproof.assert_eq(val.innerHTML, `hello world`); diff --git a/pagefind/integration_tests/ui/ui_highlight/pagefind-ui-uses-custom-highlight-query-param-name.toolproof.yml b/pagefind/integration_tests/ui/ui_highlight/pagefind-ui-uses-custom-highlight-query-param-name.toolproof.yml new file mode 100644 index 00000000..42c7cb79 --- /dev/null +++ b/pagefind/integration_tests/ui/ui_highlight/pagefind-ui-uses-custom-highlight-query-param-name.toolproof.yml @@ -0,0 +1,39 @@ +name: Base UI Tests > Pagefind UI uses custom highlight query param name +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.html" file with the content {html} + html: >- + + + + + - step: I have a "public/cat/index.html" file with the content {html} + html: |- +

hello world

+

Hello world! How are you

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: window.pui.triggerSearch("world"); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: >- + let val = await + toolproof.querySelector(".pagefind-ui__result-link[href$='?custom-param=world']"); + + toolproof.assert_eq(val.innerHTML, `hello world`); + - step: In my browser, I evaluate {js} + js: window.pui.triggerSearch("hello world"); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: >- + let val = await + toolproof.querySelector(".pagefind-ui__result-link[href$='?custom-param=hello&custom-param=world']"); + + toolproof.assert_eq(val.innerHTML, `hello world`); diff --git a/pagefind/integration_tests/ui/ui_hooks/background.toolproof.yml b/pagefind/integration_tests/ui/ui_hooks/background.toolproof.yml new file mode 100644 index 00000000..d56e3d77 --- /dev/null +++ b/pagefind/integration_tests/ui/ui_hooks/background.toolproof.yml @@ -0,0 +1,4 @@ +name: ui/ui_hooks > UI Hooks > Background +type: reference +steps: + - step: I have the environment variable "PAGEFIND_SITE" set to "public" diff --git a/pagefind/integration_tests/ui/ui_hooks/pagefind-ui-can-provide-a-hook-to-process-results.toolproof.yml b/pagefind/integration_tests/ui/ui_hooks/pagefind-ui-can-provide-a-hook-to-process-results.toolproof.yml new file mode 100644 index 00000000..d3a29062 --- /dev/null +++ b/pagefind/integration_tests/ui/ui_hooks/pagefind-ui-can-provide-a-hook-to-process-results.toolproof.yml @@ -0,0 +1,33 @@ +name: UI Hooks > Pagefind UI can provide a hook to process results +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.html" file with the content {html} + html: |- +

Search

+ + + + + + - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: |- + window.pui.triggerSearch("search"); + + let el = await toolproof.querySelector(".pagefind-ui__result-image"); + if (el.getAttribute("src") !== "/example/absolute/my.png") { + throw new Error("Path should have been updated by processResult"); + } + - step: In my browser, the console should be empty diff --git a/pagefind/integration_tests/ui/ui_hooks/pagefind-ui-can-provide-a-hook-to-process-search-terms.toolproof.yml b/pagefind/integration_tests/ui/ui_hooks/pagefind-ui-can-provide-a-hook-to-process-search-terms.toolproof.yml new file mode 100644 index 00000000..4cf4ff27 --- /dev/null +++ b/pagefind/integration_tests/ui/ui_hooks/pagefind-ui-can-provide-a-hook-to-process-search-terms.toolproof.yml @@ -0,0 +1,29 @@ +name: UI Hooks > Pagefind UI can provide a hook to process search terms +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.html" file with the content {html} + html: |- +

Search

+ + + + + - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: |- + window.pui.triggerSearch("word"); + + let el = await toolproof.querySelector(".pagefind-ui__result-link"); + if (el.getAttribute("href") !== "/") { + throw new Error(`Search term should have been normalized by processTerm. href: ${el.getAttribute("href")}`); + } + - step: In my browser, the console should be empty diff --git a/pagefind/integration_tests/ui/ui_scoring/background.toolproof.yml b/pagefind/integration_tests/ui/ui_scoring/background.toolproof.yml new file mode 100644 index 00000000..16cda05f --- /dev/null +++ b/pagefind/integration_tests/ui/ui_scoring/background.toolproof.yml @@ -0,0 +1,4 @@ +name: ui/ui_scoring > UI Scoring > Background +type: reference +steps: + - step: I have the environment variable "PAGEFIND_SITE" set to "public" diff --git a/pagefind/integration_tests/ui/ui_scoring/pagefind-ui-can-customize-scoring.toolproof.yml b/pagefind/integration_tests/ui/ui_scoring/pagefind-ui-can-customize-scoring.toolproof.yml new file mode 100644 index 00000000..d1ebc50b --- /dev/null +++ b/pagefind/integration_tests/ui/ui_scoring/pagefind-ui-can-customize-scoring.toolproof.yml @@ -0,0 +1,83 @@ +name: UI Scoring > Pagefind UI can customize scoring +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/unrelated/index.html" file with the content {html} + html: >- +

unrelated

+ +

Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus + ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa + justo sit amet risus. Nullam quis risus eget urna mollis ornare vel eu + leo. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec + sed odio dui. Cras mattis consectetur purus sit amet + fermentum.

+ - step: I have a "public/longer/index.html" file with the content {html} + html: >- +

longer

+ +

This post is quite long, and talks about terracotta at length.

+ +

Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum + nibh, ut fermentum terracotta justo sit amet risus. Donec sed odio dui. + Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis + vestibulum. Nulla vitae elit libero, a pharetra augue. Aenean lacinia + bibendum nulla sed consectetur. Donec id elit non mi porta gravida at eget + metus. Maecenas faucibus mollis interdum.

+ +

Integer erat a ante venenatis dapibus posuere velit aliquet. Vivamus + sagittis lacus vel augue laoreet rutrum faucibus auctor. Nullam quis risus + eget urna mollis ornare vel eu leo. Aenean lacinia bibendum nulla sed + consectetur.

+ +

Praesent commodo cursus magna, vel scelerisque consectetur et. Fusce + dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut + fermentum massa justo sit amet risus. Lorem ipsum dolor sit amet, + consectetur adipiscing elit. Curabitur blandit tempus + porttitor.

+ - step: I have a "public/shorter/index.html" file with the content {html} + html: |- +

shorter

+

This is a shorter terracotta page.

+ - step: I have a "public/a.html" file with the content {html} + html: |- + + + + + - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/a.html" + - step: In my browser, I evaluate {js} + js: window.pui.triggerSearch("terracotta"); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector(".pagefind-ui__result-link"); + toolproof.assert_eq(val.innerHTML, `shorter`); + - step: I have a "public/b.html" file with the content {html} + html: |- + + + + + - step: In my browser, I load "/b.html" + - step: In my browser, I evaluate {js} + js: window.pui.triggerSearch("terracotta"); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector(".pagefind-ui__result-link"); + toolproof.assert_eq(val.innerHTML, `longer`); diff --git a/pagefind/integration_tests/ui/ui_strings/background.toolproof.yml b/pagefind/integration_tests/ui/ui_strings/background.toolproof.yml new file mode 100644 index 00000000..47454d80 --- /dev/null +++ b/pagefind/integration_tests/ui/ui_strings/background.toolproof.yml @@ -0,0 +1,4 @@ +name: ui/ui_strings > UI Test Strings > Background +type: reference +steps: + - step: I have the environment variable "PAGEFIND_SITE" set to "public" diff --git a/pagefind/integration_tests/ui/ui_strings/pagefind-ui-can-load-custom-translations.toolproof.yml b/pagefind/integration_tests/ui/ui_strings/pagefind-ui-can-load-custom-translations.toolproof.yml new file mode 100644 index 00000000..9b1d2b37 --- /dev/null +++ b/pagefind/integration_tests/ui/ui_strings/pagefind-ui-can-load-custom-translations.toolproof.yml @@ -0,0 +1,35 @@ +name: UI Test Strings > Pagefind UI can load custom translations +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.html" file with the content {html} + html: |- + + + + +

Search

+ + + + + + + - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: window.pui.triggerSearch("garbage"); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector(".pagefind-ui__message"); + toolproof.assert_eq(val.innerHTML, `garbage is oh no`); diff --git a/pagefind/integration_tests/ui/ui_strings/pagefind-ui-loads-automatic-translations.toolproof.yml b/pagefind/integration_tests/ui/ui_strings/pagefind-ui-loads-automatic-translations.toolproof.yml new file mode 100644 index 00000000..ca98e175 --- /dev/null +++ b/pagefind/integration_tests/ui/ui_strings/pagefind-ui-loads-automatic-translations.toolproof.yml @@ -0,0 +1,32 @@ +name: UI Test Strings > Pagefind UI loads automatic translations +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.html" file with the content {html} + html: |- + + + + +

Search

+ + + + + + + - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: window.pui.triggerSearch("garbage"); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: >- + let val = await toolproof.querySelector(".pagefind-ui__message"); + + toolproof.assert_eq(val.innerHTML, `Nenhum resultado encontrado para + garbage`); diff --git a/pagefind/integration_tests/urls/background.toolproof.yml b/pagefind/integration_tests/urls/background.toolproof.yml new file mode 100644 index 00000000..383a450a --- /dev/null +++ b/pagefind/integration_tests/urls/background.toolproof.yml @@ -0,0 +1,19 @@ +name: urls > URL tests > Background +type: reference +steps: + - step: I have the environment variable "PAGEFIND_SITE" set to "public" + - step: I have a "public/index.html" file with the content {html} + html: >- +

Nothing

+ - step: I have a "public/package.json" file with the content {json} + json: |- + { + "name": "test", + "type": "module", + "version": "1.0.0", + "main": "index.js", + "dependencies": { + "pagefind": "file:%repo_wd%/wrappers/node" + } + } diff --git a/pagefind/integration_tests/urls/tag-pages-as-external-urls.toolproof.yml b/pagefind/integration_tests/urls/tag-pages-as-external-urls.toolproof.yml new file mode 100644 index 00000000..63e06ba8 --- /dev/null +++ b/pagefind/integration_tests/urls/tag-pages-as-external-urls.toolproof.yml @@ -0,0 +1,39 @@ +name: URL tests > Tag pages as external URLs +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/index.js" file with the content {js} + js: |2- + import * as pagefind from "pagefind"; + + const run = async () => { + const { index } = await pagefind.createIndex(); + await index.addCustomRecord({ + url: "https://example.com/external-url/", + content: "Hello World!", + language: "en" + }); + await index.writeFiles(); + console.log(`Successfully wrote files`); + } + + run(); + - step: >- + I run "cd public && npm i && PAGEFIND_BINARY_PATH=%pagefind_exec_path% + node index.js" + - step: stdout should contain "Successfully wrote files" + - step: The file "public/pagefind/pagefind.js" should not be empty + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/pagefind/pagefind.js"); + + let search = await pagefind.search("world"); + + let data = await search.results[0].data(); + document.querySelector('[data-url]').innerText = data.url; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("[data-url]"); + toolproof.assert_eq(val.innerHTML, `https://example.com/external-url/`); diff --git a/pagefind/integration_tests/weighting/background.toolproof.yml b/pagefind/integration_tests/weighting/background.toolproof.yml new file mode 100644 index 00000000..a160c14a --- /dev/null +++ b/pagefind/integration_tests/weighting/background.toolproof.yml @@ -0,0 +1,8 @@ +name: weighting > Word Weighting > Background +type: reference +steps: + - step: I have the environment variable "PAGEFIND_SITE" set to "public" + - step: I have a "public/index.html" file with the content {html} + html: >- +

no + results

diff --git a/pagefind/integration_tests/weighting/compound-words-are-implicitly-weighted-lower.toolproof.yml b/pagefind/integration_tests/weighting/compound-words-are-implicitly-weighted-lower.toolproof.yml new file mode 100644 index 00000000..782e2f13 --- /dev/null +++ b/pagefind/integration_tests/weighting/compound-words-are-implicitly-weighted-lower.toolproof.yml @@ -0,0 +1,37 @@ +name: Word Weighting > Compound words are implicitly weighted lower +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/r1/index.html" file with the content {html} + html: >- +

A single reference to + antelope

+ - step: I have a "public/r2/index.html" file with the content {html} + html: >- +

Two references to + SomeLongFiveWordAntelope SomeLongFiveWordAntelope

+ - step: I have a "public/r3/index.html" file with the content {html} + html: >- +

A single reference to + the TwoAntelope

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/pagefind/pagefind.js"); + await pagefind.options({ + ranking: { + termFrequency: 0.0 + } + }); + + let search = await pagefind.search(`antelope`); + + let data = await Promise.all(search.results.map(result => result.data())); + document.querySelector('p').innerText = data.map(d => d.url).join(', '); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("p"); + toolproof.assert_eq(val.innerHTML, `/r1/, /r3/, /r2/`); diff --git a/pagefind/integration_tests/weighting/compound-words-matched-as-full-words-use-the-full-weight.toolproof.yml b/pagefind/integration_tests/weighting/compound-words-matched-as-full-words-use-the-full-weight.toolproof.yml new file mode 100644 index 00000000..f4d0fdb4 --- /dev/null +++ b/pagefind/integration_tests/weighting/compound-words-matched-as-full-words-use-the-full-weight.toolproof.yml @@ -0,0 +1,30 @@ +name: Word Weighting > Compound words matched as full words use the full weight +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/r1/index.html" file with the content {html} + html: >- +

A single reference to + ThreeAntelopes

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search(`threea`); + + let data = await search.results[0].data(); + + let weights = data.weighted_locations.map(l => + `weight:${l.weight}/bal:${l.balanced_score.toFixed(2)}/loc:${l.location}`).join(' + • '); + + document.querySelector('p').innerText = weights; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("p"); + toolproof.assert_eq(val.innerHTML, `weight:1/bal:212.36/loc:4`); diff --git a/pagefind/integration_tests/weighting/compound-words-prefixes-prioritise-the-lower-weight.toolproof.yml b/pagefind/integration_tests/weighting/compound-words-prefixes-prioritise-the-lower-weight.toolproof.yml new file mode 100644 index 00000000..587363af --- /dev/null +++ b/pagefind/integration_tests/weighting/compound-words-prefixes-prioritise-the-lower-weight.toolproof.yml @@ -0,0 +1,30 @@ +name: Word Weighting > Compound words prefixes prioritise the lower weight +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/r1/index.html" file with the content {html} + html: >- +

A single reference to + ThreeAntelopes

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search(`three`); + + let data = await search.results[0].data(); + + let weights = data.weighted_locations.map(l => + `weight:${l.weight}/bal:${l.balanced_score.toFixed(2)}/loc:${l.location}`).join(' + • '); + + document.querySelector('p').innerText = weights; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("p"); + toolproof.assert_eq(val.innerHTML, `weight:0.5/bal:128.04/loc:4`); diff --git a/pagefind/integration_tests/weighting/compound-words-sum-to-a-full-weight.toolproof.yml b/pagefind/integration_tests/weighting/compound-words-sum-to-a-full-weight.toolproof.yml new file mode 100644 index 00000000..b74d0864 --- /dev/null +++ b/pagefind/integration_tests/weighting/compound-words-sum-to-a-full-weight.toolproof.yml @@ -0,0 +1,30 @@ +name: Word Weighting > Compound words sum to a full weight +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/r1/index.html" file with the content {html} + html: >- +

A single reference to + ThreeAntelopes

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: >- + let pagefind = await import("/pagefind/pagefind.js"); + + + let search = await pagefind.search(`three antelopes`); + + let data = await search.results[0].data(); + + let weights = data.weighted_locations.map(l => + `weight:${l.weight}/bal:${l.balanced_score.toFixed(2)}/loc:${l.location}`).join(' + • '); + + document.querySelector('p').innerText = weights; + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("p"); + toolproof.assert_eq(val.innerHTML, `weight:1/bal:512.14/loc:4`); diff --git a/pagefind/integration_tests/weighting/headings-are-automatically-favoured-over-standard-text.toolproof.yml b/pagefind/integration_tests/weighting/headings-are-automatically-favoured-over-standard-text.toolproof.yml new file mode 100644 index 00000000..a13c3705 --- /dev/null +++ b/pagefind/integration_tests/weighting/headings-are-automatically-favoured-over-standard-text.toolproof.yml @@ -0,0 +1,43 @@ +name: Word Weighting > Headings are automatically favoured over standard text +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/r1/index.html" file with the content {html} + html: |- +

Antelope

+

Antelope Antelope Antelope Antelope

+

Other text again

+ - step: I have a "public/r2/index.html" file with the content {html} + html: |- +

Antelope

+

Antelope Antelope Antelope Notantelope

+

Other text again

+ - step: I have a "public/r3/index.html" file with the content {html} + html: |- +
Antelope
+

Antelope Antelope Antelope Notantelope

+

Other text again

+ - step: I have a "public/r4/index.html" file with the content {html} + html: |- +

Antelope

+

Other text, totalling eight words of content

+ - step: I have a "public/r5/index.html" file with the content {html} + html: |- +

Antelope

+

Other antelope antelope text, of a similar length

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/pagefind/pagefind.js"); + + let search = await pagefind.search(`antelope`); + + let data = await Promise.all(search.results.map(result => result.data())); + document.querySelector('p').innerText = data.map(d => d.url).join(', '); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("p"); + toolproof.assert_eq(val.innerHTML, `/r4/, /r5/, /r3/, /r1/, /r2/`); diff --git a/pagefind/integration_tests/weighting/text-can-be-explicitly-weighted-higher.toolproof.yml b/pagefind/integration_tests/weighting/text-can-be-explicitly-weighted-higher.toolproof.yml new file mode 100644 index 00000000..d32dabd1 --- /dev/null +++ b/pagefind/integration_tests/weighting/text-can-be-explicitly-weighted-higher.toolproof.yml @@ -0,0 +1,38 @@ +name: Word Weighting > Text can be explicitly weighted higher +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/r1/index.html" file with the content {html} + html: |- +

Antelope

+

Antelope Antelope Not

+ - step: I have a "public/r2/index.html" file with the content {html} + html: |- +

Antelope

+

Antelope Not

+ - step: I have a "public/r3/index.html" file with the content {html} + html: >- +

Antelope

+ +

Antelope Not

+ - step: I have a "public/r4/index.html" file with the content {html} + html: |- +

Antelope

+

Antelope Antelope Antelope Antelope

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/pagefind/pagefind.js"); + + let search = await pagefind.search(`antelope`); + + let data = await Promise.all(search.results.map(result => result.data())); + document.querySelector('p').innerText = data.map(d => d.url).join(', '); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("p"); + toolproof.assert_eq(val.innerHTML, `/r3/, /r4/, /r1/, /r2/`); diff --git a/pagefind/integration_tests/weighting/text-can-be-explicitly-weighted-lower.toolproof.yml b/pagefind/integration_tests/weighting/text-can-be-explicitly-weighted-lower.toolproof.yml new file mode 100644 index 00000000..c5375c55 --- /dev/null +++ b/pagefind/integration_tests/weighting/text-can-be-explicitly-weighted-lower.toolproof.yml @@ -0,0 +1,32 @@ +name: Word Weighting > Text can be explicitly weighted lower +steps: + - ref: ./background.toolproof.yml + - step: I have a "public/r1/index.html" file with the content {html} + html: >- +

Antelope Antelope all about Antelope

+ +

More text about other stuff

+ - step: I have a "public/r2/index.html" file with the content {html} + html: >- +

Five words that + aren't related

+ +

One solitary mention of antelope

+ - step: I run "%pagefind_exec_path%" + - step: stdout should contain "Running Pagefind" + - step: I serve the directory "public" + - step: In my browser, I load "/" + - step: In my browser, I evaluate {js} + js: |- + let pagefind = await import("/pagefind/pagefind.js"); + + let search = await pagefind.search(`antelope`); + + let data = await Promise.all(search.results.map(result => result.data())); + document.querySelector('p').innerText = data.map(d => d.url).join(', '); + - step: In my browser, the console should be empty + - step: In my browser, I evaluate {js} + js: |- + let val = await toolproof.querySelector("p"); + toolproof.assert_eq(val.innerHTML, `/r2/, /r1/`); diff --git a/test_ci.sh b/test_ci.sh new file mode 100755 index 00000000..7a6e6bc7 --- /dev/null +++ b/test_ci.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +cd $SCRIPT_DIR + +PAGEFIND=$(realpath "$SCRIPT_DIR/target/release/pagefind") +REPO_WD=$(realpath "$SCRIPT_DIR") + +npx -y toolproof --placeholders pagefind_exec_path="$PAGEFIND" repo_wd="$REPO_WD"