@@ -2249,6 +2249,15 @@ mod test {
2249
2249
} )
2250
2250
}
2251
2251
2252
+ fn parse_release_links_from_menu ( body : & str ) -> Vec < String > {
2253
+ kuchikiki:: parse_html ( )
2254
+ . one ( body)
2255
+ . select ( r#"ul > li > a"# )
2256
+ . expect ( "invalid selector" )
2257
+ . map ( |elem| elem. attributes . borrow ( ) . get ( "href" ) . unwrap ( ) . to_string ( ) )
2258
+ . collect ( )
2259
+ }
2260
+
2252
2261
#[ test_case( true ) ]
2253
2262
#[ test_case( false ) ]
2254
2263
fn test_version_link_goes_to_docs ( archive_storage : bool ) {
@@ -2264,6 +2273,7 @@ mod test {
2264
2273
. version ( "0.3.1" )
2265
2274
. archive_storage ( archive_storage)
2266
2275
. rustdoc_file ( "hexponent/index.html" )
2276
+ . rustdoc_file ( "hexponent/something.html" )
2267
2277
. create ( ) ?;
2268
2278
2269
2279
// test rustdoc pages stay on the documentation
@@ -2273,14 +2283,27 @@ mod test {
2273
2283
. send ( ) ?;
2274
2284
assert ! ( releases_response. status( ) . is_success( ) ) ;
2275
2285
assert_cache_control ( & releases_response, CachePolicy :: ForeverInCdn , & env. config ( ) ) ;
2276
- let page = kuchikiki:: parse_html ( ) . one ( releases_response. text ( ) ?) ;
2277
- let selector =
2278
- r#"ul > li a[href="/crate/hexponent/0.3.1/target-redirect/hexponent/index.html"]"#
2279
- . to_string ( ) ;
2280
2286
assert_eq ! (
2281
- page. select( & selector) . unwrap( ) . count( ) ,
2282
- 1 ,
2283
- "link to /target-redirect/ not found"
2287
+ parse_release_links_from_menu( & releases_response. text( ) ?) ,
2288
+ vec![
2289
+ "/crate/hexponent/0.3.1/target-redirect/hexponent/index.html" . to_owned( ) ,
2290
+ "/crate/hexponent/0.3.0/target-redirect/hexponent/index.html" . to_owned( ) ,
2291
+ ]
2292
+ ) ;
2293
+
2294
+ // test if target-redirect inludes path
2295
+ let releases_response = env
2296
+ . frontend ( )
2297
+ . get ( "/crate/hexponent/0.3.1/menus/releases/hexponent/something.html" )
2298
+ . send ( ) ?;
2299
+ assert ! ( releases_response. status( ) . is_success( ) ) ;
2300
+ assert_cache_control ( & releases_response, CachePolicy :: ForeverInCdn , & env. config ( ) ) ;
2301
+ assert_eq ! (
2302
+ parse_release_links_from_menu( & releases_response. text( ) ?) ,
2303
+ vec![
2304
+ "/crate/hexponent/0.3.1/target-redirect/hexponent/something.html" . to_owned( ) ,
2305
+ "/crate/hexponent/0.3.0/target-redirect/hexponent/something.html" . to_owned( ) ,
2306
+ ]
2284
2307
) ;
2285
2308
2286
2309
// test /crate pages stay on /crate
0 commit comments