@@ -2229,6 +2229,15 @@ mod test {
2229
2229
} )
2230
2230
}
2231
2231
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
+
2232
2241
#[ test_case( true ) ]
2233
2242
#[ test_case( false ) ]
2234
2243
fn test_version_link_goes_to_docs ( archive_storage : bool ) {
@@ -2244,6 +2253,7 @@ mod test {
2244
2253
. version ( "0.3.1" )
2245
2254
. archive_storage ( archive_storage)
2246
2255
. rustdoc_file ( "hexponent/index.html" )
2256
+ . rustdoc_file ( "hexponent/something.html" )
2247
2257
. create ( ) ?;
2248
2258
2249
2259
// test rustdoc pages stay on the documentation
@@ -2253,14 +2263,27 @@ mod test {
2253
2263
. send ( ) ?;
2254
2264
assert ! ( releases_response. status( ) . is_success( ) ) ;
2255
2265
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 ( ) ;
2260
2266
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
+ ]
2264
2287
) ;
2265
2288
2266
2289
// test /crate pages stay on /crate
0 commit comments