@@ -2229,6 +2229,15 @@ mod test {
22292229 } )
22302230 }
22312231
2232+ fn parse_release_links_from_menu ( body : & str ) -> Vec < String > {
2233+ kuchikiki:: parse_html ( )
2234+ . one ( body)
2235+ . select ( r#"ul > li > a"# )
2236+ . expect ( "invalid selector" )
2237+ . map ( |elem| elem. attributes . borrow ( ) . get ( "href" ) . unwrap ( ) . to_string ( ) )
2238+ . collect ( )
2239+ }
2240+
22322241 #[ test_case( true ) ]
22332242 #[ test_case( false ) ]
22342243 fn test_version_link_goes_to_docs ( archive_storage : bool ) {
@@ -2244,6 +2253,7 @@ mod test {
22442253 . version ( "0.3.1" )
22452254 . archive_storage ( archive_storage)
22462255 . rustdoc_file ( "hexponent/index.html" )
2256+ . rustdoc_file ( "hexponent/something.html" )
22472257 . create ( ) ?;
22482258
22492259 // test rustdoc pages stay on the documentation
@@ -2253,14 +2263,27 @@ mod test {
22532263 . send ( ) ?;
22542264 assert ! ( releases_response. status( ) . is_success( ) ) ;
22552265 assert_cache_control ( & releases_response, CachePolicy :: ForeverInCdn , & env. config ( ) ) ;
2256- let page = kuchikiki:: parse_html ( ) . one ( releases_response. text ( ) ?) ;
2257- let selector =
2258- r#"ul > li a[href="/crate/hexponent/0.3.1/target-redirect/hexponent/index.html"]"#
2259- . to_string ( ) ;
22602266 assert_eq ! (
2261- page. select( & selector) . unwrap( ) . count( ) ,
2262- 1 ,
2263- "link to /target-redirect/ not found"
2267+ parse_release_links_from_menu( & releases_response. text( ) ?) ,
2268+ vec![
2269+ "/crate/hexponent/0.3.1/target-redirect/hexponent/index.html" . to_owned( ) ,
2270+ "/crate/hexponent/0.3.0/target-redirect/hexponent/index.html" . to_owned( ) ,
2271+ ]
2272+ ) ;
2273+
2274+ // test if target-redirect inludes path
2275+ let releases_response = env
2276+ . frontend ( )
2277+ . get ( "/crate/hexponent/0.3.1/menus/releases/hexponent/something.html" )
2278+ . send ( ) ?;
2279+ assert ! ( releases_response. status( ) . is_success( ) ) ;
2280+ assert_cache_control ( & releases_response, CachePolicy :: ForeverInCdn , & env. config ( ) ) ;
2281+ assert_eq ! (
2282+ parse_release_links_from_menu( & releases_response. text( ) ?) ,
2283+ vec![
2284+ "/crate/hexponent/0.3.1/target-redirect/hexponent/something.html" . to_owned( ) ,
2285+ "/crate/hexponent/0.3.0/target-redirect/hexponent/something.html" . to_owned( ) ,
2286+ ]
22642287 ) ;
22652288
22662289 // test /crate pages stay on /crate
0 commit comments