From 4a06e067c5980aa723c1a1193de6020ca5a76ea8 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Mon, 13 Oct 2025 21:12:05 -0700 Subject: [PATCH] Add a general-purpose summary GUI book This adds the all-summary GUI test book which can be used for general purpose tests that need a few pages to exercise all the different kinds of items. --- tests/gui/books/all-summary/README.md | 3 ++ tests/gui/books/all-summary/book.toml | 2 + tests/gui/books/all-summary/src/SUMMARY.md | 20 +++++++++ tests/gui/books/all-summary/src/intro.md | 1 + .../books/all-summary/src/part-1/chapter-1.md | 1 + .../books/all-summary/src/part-2/chapter-1.md | 1 + tests/gui/books/all-summary/src/prefix-1.md | 1 + tests/gui/books/all-summary/src/prefix-2.md | 1 + tests/gui/books/all-summary/src/suffix-1.md | 1 + tests/gui/books/all-summary/src/suffix-2.md | 1 + tests/gui/move-between-pages.goml | 45 +++++++++++-------- tests/gui/sidebar-active.goml | 16 +++---- tests/gui/sidebar.goml | 8 ++-- tests/gui/theme.goml | 4 +- 14 files changed, 72 insertions(+), 33 deletions(-) create mode 100644 tests/gui/books/all-summary/README.md create mode 100644 tests/gui/books/all-summary/book.toml create mode 100644 tests/gui/books/all-summary/src/SUMMARY.md create mode 100644 tests/gui/books/all-summary/src/intro.md create mode 100644 tests/gui/books/all-summary/src/part-1/chapter-1.md create mode 100644 tests/gui/books/all-summary/src/part-2/chapter-1.md create mode 100644 tests/gui/books/all-summary/src/prefix-1.md create mode 100644 tests/gui/books/all-summary/src/prefix-2.md create mode 100644 tests/gui/books/all-summary/src/suffix-1.md create mode 100644 tests/gui/books/all-summary/src/suffix-2.md diff --git a/tests/gui/books/all-summary/README.md b/tests/gui/books/all-summary/README.md new file mode 100644 index 00000000..41fe70ef --- /dev/null +++ b/tests/gui/books/all-summary/README.md @@ -0,0 +1,3 @@ +# All summary + +This GUI test book tests all the different kinds of book items in the summary. diff --git a/tests/gui/books/all-summary/book.toml b/tests/gui/books/all-summary/book.toml new file mode 100644 index 00000000..8351df2d --- /dev/null +++ b/tests/gui/books/all-summary/book.toml @@ -0,0 +1,2 @@ +[book] +title = "all-summary" diff --git a/tests/gui/books/all-summary/src/SUMMARY.md b/tests/gui/books/all-summary/src/SUMMARY.md new file mode 100644 index 00000000..5835e15c --- /dev/null +++ b/tests/gui/books/all-summary/src/SUMMARY.md @@ -0,0 +1,20 @@ +# Summary + +[Prefix 1](prefix-1.md) +[Prefix 2](prefix-2.md) + +- [Introduction](intro.md) +- [Draft]() + +# Part 1 + +- [P1 C1](part-1/chapter-1.md) + +--- + +# Part 2 + +- [P2 C1](part-2/chapter-1.md) + +[Suffix 1](suffix-1.md) +[Suffix 2](suffix-2.md) diff --git a/tests/gui/books/all-summary/src/intro.md b/tests/gui/books/all-summary/src/intro.md new file mode 100644 index 00000000..e10b99d0 --- /dev/null +++ b/tests/gui/books/all-summary/src/intro.md @@ -0,0 +1 @@ +# Introduction diff --git a/tests/gui/books/all-summary/src/part-1/chapter-1.md b/tests/gui/books/all-summary/src/part-1/chapter-1.md new file mode 100644 index 00000000..f054ae72 --- /dev/null +++ b/tests/gui/books/all-summary/src/part-1/chapter-1.md @@ -0,0 +1 @@ +# P1 C1 diff --git a/tests/gui/books/all-summary/src/part-2/chapter-1.md b/tests/gui/books/all-summary/src/part-2/chapter-1.md new file mode 100644 index 00000000..fd529e4e --- /dev/null +++ b/tests/gui/books/all-summary/src/part-2/chapter-1.md @@ -0,0 +1 @@ +# P2 C1 diff --git a/tests/gui/books/all-summary/src/prefix-1.md b/tests/gui/books/all-summary/src/prefix-1.md new file mode 100644 index 00000000..4ddb4143 --- /dev/null +++ b/tests/gui/books/all-summary/src/prefix-1.md @@ -0,0 +1 @@ +# Prefix 1 diff --git a/tests/gui/books/all-summary/src/prefix-2.md b/tests/gui/books/all-summary/src/prefix-2.md new file mode 100644 index 00000000..11ff4958 --- /dev/null +++ b/tests/gui/books/all-summary/src/prefix-2.md @@ -0,0 +1 @@ +# Prefix 2 diff --git a/tests/gui/books/all-summary/src/suffix-1.md b/tests/gui/books/all-summary/src/suffix-1.md new file mode 100644 index 00000000..59a81900 --- /dev/null +++ b/tests/gui/books/all-summary/src/suffix-1.md @@ -0,0 +1 @@ +# Suffix 1 diff --git a/tests/gui/books/all-summary/src/suffix-2.md b/tests/gui/books/all-summary/src/suffix-2.md new file mode 100644 index 00000000..2bf99ebe --- /dev/null +++ b/tests/gui/books/all-summary/src/suffix-2.md @@ -0,0 +1 @@ +# Suffix 2 diff --git a/tests/gui/move-between-pages.goml b/tests/gui/move-between-pages.goml index 93a4b9cc..227dcee6 100644 --- a/tests/gui/move-between-pages.goml +++ b/tests/gui/move-between-pages.goml @@ -1,36 +1,43 @@ // This tests pressing the left and right arrows moving to previous and next page. -go-to: |DOC_PATH| + "test_book/index.html" +go-to: |DOC_PATH| + "all-summary/index.html" -// default page is the first numbered page -assert-text: ("title", "Introduction - mdBook test book") - -// Moving left we get to the prefix page -press-key: 'ArrowLeft' -assert-text: ("title", "Prefix Chapter - mdBook test book") +// default page is the first chapter +assert-text: ("title", "Prefix 1 - all-summary") // Trying to move to the left beyond the prefix pages - nothing changes press-key: 'ArrowLeft' -assert-text: ("title", "Prefix Chapter - mdBook test book") +assert-text: ("title", "Prefix 1 - all-summary") -// Back to the main page +// Move left +go-to: |DOC_PATH| + "all-summary/intro.html" +assert-text: ("title", "Introduction - all-summary") + +press-key: 'ArrowLeft' +assert-text: ("title", "Prefix 2 - all-summary") + +press-key: 'ArrowLeft' +assert-text: ("title", "Prefix 1 - all-summary") + +// Move right press-key: 'ArrowRight' -assert-text: ("title", "Introduction - mdBook test book") +assert-text: ("title", "Prefix 2 - all-summary") press-key: 'ArrowRight' -assert-text: ("title", "Markdown Individual tags - mdBook test book") +assert-text: ("title", "Introduction - all-summary") press-key: 'ArrowRight' -assert-text: ("title", "Heading - mdBook test book") +assert-text: ("title", "P1 C1 - all-summary") -// Last numbered page -go-to: "../last.html" -assert-text: ("title", "Last numbered chapter - mdBook test book") - -// Go to the suffix chapter press-key: 'ArrowRight' -assert-text: ("title", "Suffix Chapter - mdBook test book") +assert-text: ("title", "P2 C1 - all-summary") + +press-key: 'ArrowRight' +assert-text: ("title", "Suffix 1 - all-summary") + +press-key: 'ArrowRight' +assert-text: ("title", "Suffix 2 - all-summary") // Try to go beyond the last page press-key: 'ArrowRight' -assert-text: ("title", "Suffix Chapter - mdBook test book") +assert-text: ("title", "Suffix 2 - all-summary") diff --git a/tests/gui/sidebar-active.goml b/tests/gui/sidebar-active.goml index 8f01a878..f132bad5 100644 --- a/tests/gui/sidebar-active.goml +++ b/tests/gui/sidebar-active.goml @@ -1,17 +1,17 @@ // This GUI test checks the active page sidebar highlight. -go-to: |DOC_PATH| + "test_book/index.html" +go-to: |DOC_PATH| + "all-summary/index.html" -assert-text: ("mdbook-sidebar-scrollbox a.active", "Prefix Chapter") +assert-text: ("mdbook-sidebar-scrollbox a.active", "Prefix 1") -go-to: |DOC_PATH| + "test_book/individual/index.html" +go-to: |DOC_PATH| + "all-summary/part-1/chapter-1.html" -assert-text: ("mdbook-sidebar-scrollbox a.active", "3. Markdown Individual tags") +assert-text: ("mdbook-sidebar-scrollbox a.active", "3. P1 C1") -go-to: |DOC_PATH| + "test_book/index.html?highlight=test" +go-to: |DOC_PATH| + "all-summary/index.html?highlight=test" -assert-text: ("mdbook-sidebar-scrollbox a.active", "Prefix Chapter") +assert-text: ("mdbook-sidebar-scrollbox a.active", "Prefix 1") -go-to: |DOC_PATH| + "test_book/individual/index.html?highlight=test" +go-to: |DOC_PATH| + "all-summary/part-1/chapter-1.html?highlight=test" -assert-text: ("mdbook-sidebar-scrollbox a.active", "3. Markdown Individual tags") +assert-text: ("mdbook-sidebar-scrollbox a.active", "3. P1 C1") diff --git a/tests/gui/sidebar.goml b/tests/gui/sidebar.goml index 663b84f2..50dc71a9 100644 --- a/tests/gui/sidebar.goml +++ b/tests/gui/sidebar.goml @@ -1,7 +1,7 @@ // This GUI test checks sidebar hide/show and also its behaviour on smaller // width. -go-to: |DOC_PATH| + "test_book/index.html" +go-to: |DOC_PATH| + "all-summary/index.html" set-window-size: (1100, 600) // Need to reload for the new size to be taken account by the JS. reload: @@ -44,13 +44,13 @@ define-function: ( ) // Since the sidebar is visible, we should be able to find this text. -assert-find-text: ("3.9. Links and Horizontal Rule", {"case-sensitive": true}) +assert-find-text: ("3. P1 C1", {"case-sensitive": true}) call-function: ("hide-sidebar", {}) // Text should not be findeable anymore since the sidebar is collapsed. -assert-find-text-false: ("3.9. Links and Horizontal Rule", {"case-sensitive": true}) +assert-find-text-false: ("3. P1 C1", {"case-sensitive": true}) call-function: ("show-sidebar", {}) // We should be able to find this text again. -assert-find-text: ("3.9. Links and Horizontal Rule", {"case-sensitive": true}) +assert-find-text: ("3. P1 C1", {"case-sensitive": true}) // We now test on smaller width to ensure that the sidebar is collapsed by default. set-window-size: (900, 600) diff --git a/tests/gui/theme.goml b/tests/gui/theme.goml index 683e69a9..6d4feedb 100644 --- a/tests/gui/theme.goml +++ b/tests/gui/theme.goml @@ -2,7 +2,7 @@ debug: true -go-to: |DOC_PATH| + "test_book/index.html" +go-to: |DOC_PATH| + "all-summary/index.html" // TODO: Dark mode is automatic, how to check that here? assert-css: ("#mdbook-theme-list", {"display": "none"}) @@ -31,5 +31,5 @@ press-key: 'Escape' assert-css: ("#mdbook-theme-list", {"display": "none"}) // Check for navigation retains theme. -go-to: "./rust/rust_codeblock.html" +go-to: "./part-1/chapter-1.html" assert-attribute: ("html", {"class": "rust js"})