diff --git a/tests/gui/books/redirect/README.md b/tests/gui/books/redirect/README.md new file mode 100644 index 00000000..7e0bb6fe --- /dev/null +++ b/tests/gui/books/redirect/README.md @@ -0,0 +1,3 @@ +# Redirect + +This GUI test book tests the redirect configuration. diff --git a/tests/gui/books/redirect/book.toml b/tests/gui/books/redirect/book.toml new file mode 100644 index 00000000..b1a3f1d3 --- /dev/null +++ b/tests/gui/books/redirect/book.toml @@ -0,0 +1,28 @@ +[book] +title = "redirect" + +[output.html.redirect] +"/inner/old.html" = "../new-chapter.html" + +# This is a source without a fragment, and one with a fragment that goes to +# the same place. The redirect with the fragment is not necessary, since that +# is the default behavior. +"/pointless-fragment.html" = "new-chapter.html" +"/pointless-fragment.html#foo" = "new-chapter.html#foo" + +"/rename-page-and-fragment.html" = "new-chapter.html" +"/rename-page-and-fragment.html#orig" = "new-chapter.html#new" + +"/rename-page-fragment-elsewhere.html" = "new-chapter.html" +"/rename-page-fragment-elsewhere.html#orig" = "other-chapter.html#new" + +# Rename fragment on an existing page. +"/new-chapter.html#orig" = "new-chapter.html#new" +# Rename fragment on an existing page to another page. +"/new-chapter.html#orig-new-chapter" = "other-chapter.html#new" + +"/full-url-with-fragment.html" = "https://www.rust-lang.org/#fragment" + +"/full-url-with-fragment-map.html" = "https://www.rust-lang.org/" +"/full-url-with-fragment-map.html#a" = "https://www.rust-lang.org/#new1" +"/full-url-with-fragment-map.html#b" = "https://www.rust-lang.org/#new2" diff --git a/tests/gui/books/redirect/src/SUMMARY.md b/tests/gui/books/redirect/src/SUMMARY.md new file mode 100644 index 00000000..e034ffe3 --- /dev/null +++ b/tests/gui/books/redirect/src/SUMMARY.md @@ -0,0 +1,4 @@ +# Summary + +- [New chapter](new-chapter.md) +- [Other chapter](other-chapter.md) diff --git a/tests/gui/books/redirect/src/chapter_1.md b/tests/gui/books/redirect/src/chapter_1.md new file mode 100644 index 00000000..b743fda3 --- /dev/null +++ b/tests/gui/books/redirect/src/chapter_1.md @@ -0,0 +1 @@ +# Chapter 1 diff --git a/tests/gui/books/redirect/src/new-chapter.md b/tests/gui/books/redirect/src/new-chapter.md new file mode 100644 index 00000000..cb233a60 --- /dev/null +++ b/tests/gui/books/redirect/src/new-chapter.md @@ -0,0 +1 @@ +# New chapter diff --git a/tests/gui/books/redirect/src/other-chapter.md b/tests/gui/books/redirect/src/other-chapter.md new file mode 100644 index 00000000..9d4d6853 --- /dev/null +++ b/tests/gui/books/redirect/src/other-chapter.md @@ -0,0 +1 @@ +# Other chapter diff --git a/tests/gui/books/test_book/book.toml b/tests/gui/books/test_book/book.toml index 854b5e7d..3bfa706a 100644 --- a/tests/gui/books/test_book/book.toml +++ b/tests/gui/books/test_book/book.toml @@ -23,29 +23,3 @@ boost-hierarchy = 2 boost-paragraph = 1 expand = true heading-split-level = 2 - -[output.html.redirect] -"/format/config.html" = "../prefix.html" - -# This is a source without a fragment, and one with a fragment that goes to -# the same place. The redirect with the fragment is not necessary, since that -# is the default behavior. -"/pointless-fragment.html" = "prefix.html" -"/pointless-fragment.html#foo" = "prefix.html#foo" - -"/rename-page-and-fragment.html" = "prefix.html" -"/rename-page-and-fragment.html#orig" = "prefix.html#new" - -"/rename-page-fragment-elsewhere.html" = "prefix.html" -"/rename-page-fragment-elsewhere.html#orig" = "suffix.html#new" - -# Rename fragment on an existing page. -"/prefix.html#orig" = "prefix.html#new" -# Rename fragment on an existing page to another page. -"/prefix.html#orig-new-page" = "suffix.html#new" - -"/full-url-with-fragment.html" = "https://www.rust-lang.org/#fragment" - -"/full-url-with-fragment-map.html" = "https://www.rust-lang.org/" -"/full-url-with-fragment-map.html#a" = "https://www.rust-lang.org/#new1" -"/full-url-with-fragment-map.html#b" = "https://www.rust-lang.org/#new2" diff --git a/tests/gui/redirect.goml b/tests/gui/redirect.goml index e11e7279..9bcd6835 100644 --- a/tests/gui/redirect.goml +++ b/tests/gui/redirect.goml @@ -1,41 +1,41 @@ -go-to: |DOC_PATH| + "test_book/format/config.html" -assert-window-property: ({"location": |DOC_PATH| + "test_book/prefix.html"}) +go-to: |DOC_PATH| + "redirect/inner/old.html" +assert-window-property: ({"location": |DOC_PATH| + "redirect/new-chapter.html"}) // Check that it preserves fragments when redirecting. -go-to: |DOC_PATH| + "test_book/format/config.html#fragment" -assert-window-property: ({"location": |DOC_PATH| + "test_book/prefix.html#fragment"}) +go-to: |DOC_PATH| + "redirect/inner/old.html#fragment" +assert-window-property: ({"location": |DOC_PATH| + "redirect/new-chapter.html#fragment"}) // The fragment one here isn't necessary, but should still work. -go-to: |DOC_PATH| + "test_book/pointless-fragment.html" -assert-window-property: ({"location": |DOC_PATH| + "test_book/prefix.html"}) -go-to: |DOC_PATH| + "test_book/pointless-fragment.html#foo" -assert-window-property: ({"location": |DOC_PATH| + "test_book/prefix.html#foo"}) +go-to: |DOC_PATH| + "redirect/pointless-fragment.html" +assert-window-property: ({"location": |DOC_PATH| + "redirect/new-chapter.html"}) +go-to: |DOC_PATH| + "redirect/pointless-fragment.html#foo" +assert-window-property: ({"location": |DOC_PATH| + "redirect/new-chapter.html#foo"}) // Page rename, and a fragment rename. -go-to: |DOC_PATH| + "test_book/rename-page-and-fragment.html" -assert-window-property: ({"location": |DOC_PATH| + "test_book/prefix.html"}) -go-to: |DOC_PATH| + "test_book/rename-page-and-fragment.html#orig" -assert-window-property: ({"location": |DOC_PATH| + "test_book/prefix.html#new"}) +go-to: |DOC_PATH| + "redirect/rename-page-and-fragment.html" +assert-window-property: ({"location": |DOC_PATH| + "redirect/new-chapter.html"}) +go-to: |DOC_PATH| + "redirect/rename-page-and-fragment.html#orig" +assert-window-property: ({"location": |DOC_PATH| + "redirect/new-chapter.html#new"}) // Page rename, and the fragment goes to a *different* page from the default. -go-to: |DOC_PATH| + "test_book/rename-page-fragment-elsewhere.html" -assert-window-property: ({"location": |DOC_PATH| + "test_book/prefix.html"}) -go-to: |DOC_PATH| + "test_book/rename-page-fragment-elsewhere.html#orig" -assert-window-property: ({"location": |DOC_PATH| + "test_book/suffix.html#new"}) +go-to: |DOC_PATH| + "redirect/rename-page-fragment-elsewhere.html" +assert-window-property: ({"location": |DOC_PATH| + "redirect/new-chapter.html"}) +go-to: |DOC_PATH| + "redirect/rename-page-fragment-elsewhere.html#orig" +assert-window-property: ({"location": |DOC_PATH| + "redirect/other-chapter.html#new"}) // Rename fragment on an existing page. -go-to: |DOC_PATH| + "test_book/prefix.html#orig" -assert-window-property: ({"location": |DOC_PATH| + "test_book/prefix.html#new"}) +go-to: |DOC_PATH| + "redirect/new-chapter.html#orig" +assert-window-property: ({"location": |DOC_PATH| + "redirect/new-chapter.html#new"}) // Other fragments aren't affected. -go-to: |DOC_PATH| + "test_book/index.html" // Reset page since redirects are processed on load. -go-to: |DOC_PATH| + "test_book/prefix.html" -assert-window-property: ({"location": |DOC_PATH| + "test_book/prefix.html"}) -go-to: |DOC_PATH| + "test_book/index.html" // Reset page since redirects are processed on load. -go-to: |DOC_PATH| + "test_book/prefix.html#dont-change" -assert-window-property: ({"location": |DOC_PATH| + "test_book/prefix.html#dont-change"}) +go-to: |DOC_PATH| + "redirect/index.html" // Reset page since redirects are processed on load. +go-to: |DOC_PATH| + "redirect/new-chapter.html" +assert-window-property: ({"location": |DOC_PATH| + "redirect/new-chapter.html"}) +go-to: |DOC_PATH| + "redirect/index.html" // Reset page since redirects are processed on load. +go-to: |DOC_PATH| + "redirect/new-chapter.html#dont-change" +assert-window-property: ({"location": |DOC_PATH| + "redirect/new-chapter.html#dont-change"}) // Rename fragment on an existing page to another page. -go-to: |DOC_PATH| + "test_book/index.html" // Reset page since redirects are processed on load. -go-to: |DOC_PATH| + "test_book/prefix.html#orig-new-page" -assert-window-property: ({"location": |DOC_PATH| + "test_book/suffix.html#new"}) +go-to: |DOC_PATH| + "redirect/index.html" // Reset page since redirects are processed on load. +go-to: |DOC_PATH| + "redirect/new-chapter.html#orig-new-chapter" +assert-window-property: ({"location": |DOC_PATH| + "redirect/other-chapter.html#new"})