Skip to content

Commit a58b65b

Browse files
committed
test: add pagination tests for listings
Enhance the existing listing test suite by adding pagination tests to verify the presence of pagination elements and their expected behaviour in the rendered output.
1 parent bfef90b commit a58b65b

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

tests/docs/listings/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
/.quarto/
2+
3+
**/*.quarto_ipynb

tests/smoke/site/render-listings.test.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,19 @@ import { dirname, join } from "../../../src/deno_ral/path.ts";
88
import { testQuartoCmd, Verify } from "../../test.ts";
99

1010
import { docs } from "../../utils.ts";
11-
import { ensureHtmlElements, fileExists } from "../../verify.ts";
11+
import { ensureFileRegexMatches, ensureHtmlElements, fileExists } from "../../verify.ts";
1212

1313
const input = docs("listings/index.qmd");
1414
const outputDir = join(docs("listings"), "_site");
1515
const htmlOutput = join(
1616
outputDir,
1717
"index.html",
1818
);
19+
const paginationHtmlOutput = join(
20+
outputDir,
21+
"pagination",
22+
"index.html",
23+
);
1924

2025
const verify: Verify[] = [];
2126
verify.push(fileExists(htmlOutput));
@@ -36,6 +41,27 @@ verify.push(ensureHtmlElements(htmlOutput, [
3641
'div#listing-other-reports .quarto-post div.thumbnail img[src$="2\.png"]',
3742
]));
3843

44+
// Pagination tests
45+
verify.push(fileExists(paginationHtmlOutput));
46+
verify.push(ensureHtmlElements(paginationHtmlOutput, [
47+
// 1. Testing listing type for each pagination listing
48+
"div#listing-default-pagination table.quarto-listing-table",
49+
"div#listing-custom-pagination .quarto-grid-item",
50+
"div#listing-zero-inner-window .quarto-listing-default",
51+
// 2. Testing pagination nav elements exist
52+
"nav#default-pagination-pagination.listing-pagination",
53+
"nav#custom-pagination-pagination.listing-pagination",
54+
"nav#zero-inner-window-pagination.listing-pagination",
55+
]));
56+
verify.push(ensureFileRegexMatches(paginationHtmlOutput, [
57+
// Default pagination uses innerWindow: 2 (default value)
58+
/pagination:\s*\{[^}]*innerWindow:\s*2/,
59+
// Custom pagination uses innerWindow: 1 and outerWindow: 1
60+
/pagination:\s*\{[^}]*innerWindow:\s*1[^}]*outerWindow:\s*1/,
61+
// Zero inner-window regression test: innerWindow: 0 must be output
62+
/pagination:\s*\{[^}]*innerWindow:\s*0/,
63+
]));
64+
3965
testQuartoCmd(
4066
"render",
4167
[

0 commit comments

Comments
 (0)