name: Base UI Tests > Pagefind UI resolves image URLs against an absolute base URL steps: - ref: ./background.toolproof.yml - step: I have a "public/index.html" file with the content {html} html: |- - step: I have a "public/subs/index.html" file with the content {html} html: |- - step: I have a "public/blog/post/index.html" file with the content {html} html: >-

Relative Image

A page with a relative image URL.

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

Absolute Image

A page with an absolute image URL.

- macro: I run Pagefind - 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("image"); - step: In my browser, the console should be empty - snapshot: In my browser, the result of {js} js: |- await toolproof.waitFor(() => document.querySelectorAll(".pagefind-ui__result-image").length === 2); let items = Array.from(document.querySelectorAll(".pagefind-ui__result")); items.sort((a, b) => a.textContent.localeCompare(b.textContent)); return items.map(li => { let title = li.querySelector(".pagefind-ui__result-link").textContent; return title + ": " + li.querySelector(".pagefind-ui__result-image").getAttribute("src"); }).join("\n"); snapshot_content: |- ╎Absolute Image: https://example.com/images/hero.png ╎Relative Image: https://example.com/blog/post/images/header.png - step: In my browser, I load "/subs/" - step: In my browser, I evaluate {js} js: window.pui.triggerSearch("image"); - step: In my browser, the console should be empty - snapshot: In my browser, the result of {js} js: |- await toolproof.waitFor(() => document.querySelectorAll(".pagefind-ui__result-image").length === 2); let items = Array.from(document.querySelectorAll(".pagefind-ui__result")); items.sort((a, b) => a.textContent.localeCompare(b.textContent)); return items.map(li => { let title = li.querySelector(".pagefind-ui__result-link").textContent; return title + ": " + li.querySelector(".pagefind-ui__result-image").getAttribute("src"); }).join("\n"); snapshot_content: |- ╎Absolute Image: https://example.com/images/hero.png ╎Relative Image: https://example.com/blog/post/images/header.png