Fold the colour tests into fewer, broader ones
Browse files at this commit3f07a50ccd8e5d98a6abf6b5a913f35fbb574c3fParent: 3637bc9- test
- fold the colour tests into fewer, broader ones
4 changed files +5 -27
- crates/forge-web/src/accent.rs +1 -5
- crates/forge-web/src/custom_colour.rs +2 -10
- crates/forge-web/src/pages/assets.rs +1 -5
- crates/forge-web/src/pages/settings_appearance.rs +1 -7
crates/forge-web/src/accent.rsmodified+1 -5
| @@ -292,7 +292,7 @@ mod tests { | ||
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | #[test] |
| 295 | - fn the_presets_are_offered_in_picker_order() { | |
| 295 | + fn the_presets_are_offered_in_picker_order_and_removed_ids_are_not() { | |
| 296 | 296 | assert_eq!( |
| 297 | 297 | ids().collect::<Vec<_>>(), |
| 298 | 298 | ["sage", "spark", "ocean", "plum", "rose", "gold"] |
| @@ -301,10 +301,6 @@ mod tests { | ||
| 301 | 301 | base_ids().collect::<Vec<_>>(), |
| 302 | 302 | ["fern", "spark", "graphite", "dusk", "ink"] |
| 303 | 303 | ); |
| 304 | - } | |
| 305 | - | |
| 306 | - #[test] | |
| 307 | - fn removed_ids_are_not_offered() { | |
| 308 | 304 | for id in ["ember", "ochre", "teal", "Sage", "sage ", "terracotta"] { |
| 309 | 305 | assert!(!is_offered(id), "{id}"); |
| 310 | 306 | } |
crates/forge-web/src/custom_colour.rsmodified+2 -10
| @@ -344,20 +344,16 @@ mod tests { | ||
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | #[test] |
| 347 | - fn the_extremes_are_exact() { | |
| 347 | + fn the_extremes_are_exact_and_a_preset_hue_reads_back() { | |
| 348 | 348 | assert_eq!(colour(1.0, 0.0, 0.0), "#FFFFFF"); |
| 349 | 349 | assert_eq!(colour(0.0, 0.0, 0.0), "#000000"); |
| 350 | - } | |
| 351 | - | |
| 352 | - #[test] | |
| 353 | - fn a_preset_hue_reads_back_from_its_colour() { | |
| 354 | 350 | // Sage is about 149 degrees; Ocean about 240. |
| 355 | 351 | assert_eq!(hex_hue("#5E7D63"), 149); |
| 356 | 352 | assert_eq!(hex_hue("#467799"), 240); |
| 357 | 353 | } |
| 358 | 354 | |
| 359 | 355 | #[test] |
| 360 | - fn every_hue_gives_hex_colours_with_the_right_token_names() { | |
| 356 | + fn every_hue_gives_hex_colours_with_the_right_token_names_and_keyed_rules() { | |
| 361 | 357 | for hue in 0..360 { |
| 362 | 358 | for dark in [false, true] { |
| 363 | 359 | let accent = accent_tokens(hue, dark); |
| @@ -376,10 +372,6 @@ mod tests { | ||
| 376 | 372 | } |
| 377 | 373 | } |
| 378 | 374 | } |
| 379 | - } | |
| 380 | - | |
| 381 | - #[test] | |
| 382 | - fn the_stylesheet_keys_each_rule_on_its_hue() { | |
| 383 | 375 | let css = stylesheet(Some(215), Some(215), None, Some(7)); |
| 384 | 376 | assert!( |
| 385 | 377 | css.contains(":root[data-accent-light=\"hue-215\"] {\n --accent: #"), |
crates/forge-web/src/pages/assets.rsmodified+1 -5
| @@ -434,7 +434,7 @@ mod tests { | ||
| 434 | 434 | } |
| 435 | 435 | |
| 436 | 436 | #[tokio::test] |
| 437 | - async fn custom_css_keys_the_hue_choices_and_ignores_the_rest() { | |
| 437 | + async fn custom_css_keys_the_hue_choices_and_is_empty_without_one() { | |
| 438 | 438 | let router: Router = Router::builder().discover().cookies().build(); |
| 439 | 439 | let req = Request::builder() |
| 440 | 440 | .method("GET") |
| @@ -459,11 +459,7 @@ mod tests { | ||
| 459 | 459 | assert!(css.contains(":root[data-base-light=\"hue-7\"] {"), "{css}"); |
| 460 | 460 | assert!(!css.contains("plum"), "{css}"); |
| 461 | 461 | assert!(!css.contains("hue-360"), "{css}"); |
| 462 | - } | |
| 463 | 462 | |
| 464 | - #[tokio::test] | |
| 465 | - async fn custom_css_with_no_hue_is_empty_and_never_an_error() { | |
| 466 | - let router: Router = Router::builder().discover().cookies().build(); | |
| 467 | 463 | for uri in ["/theme/custom.css", "/theme/custom.css?al=hue-x&bd=%00"] { |
| 468 | 464 | let req = Request::builder() |
| 469 | 465 | .method("GET") |
crates/forge-web/src/pages/settings_appearance.rsmodified+1 -7
| @@ -612,7 +612,7 @@ mod tests { | ||
| 612 | 612 | } |
| 613 | 613 | |
| 614 | 614 | #[test] |
| 615 | - fn a_stored_hue_checks_custom_and_sets_the_knob() { | |
| 615 | + fn a_stored_hue_checks_custom_and_a_stored_preset_moves_the_knob() { | |
| 616 | 616 | let group = colour_group(Lang::En, false, "hue-200", "hue-40"); |
| 617 | 617 | assert!(group.base_stripe.custom); |
| 618 | 618 | assert_eq!(group.base_stripe.hue, 200); |
| @@ -620,10 +620,7 @@ mod tests { | ||
| 620 | 620 | assert_eq!(group.accent_stripe.hue, 40); |
| 621 | 621 | assert!(group.bases.iter().all(|c| !c.selected)); |
| 622 | 622 | assert!(group.accents.iter().all(|c| !c.selected)); |
| 623 | - } | |
| 624 | 623 | |
| 625 | - #[test] | |
| 626 | - fn a_stored_preset_checks_the_preset_and_moves_the_knob_to_its_hue() { | |
| 627 | 624 | let group = colour_group(Lang::En, true, "ink", "plum"); |
| 628 | 625 | let plum_hue = preset_accent_hue("plum").unwrap(); |
| 629 | 626 | let ink_hue = preset_base_hue("ink").unwrap(); |
| @@ -634,10 +631,7 @@ mod tests { | ||
| 634 | 631 | let plum = group.accents.iter().find(|c| c.value == "plum").unwrap(); |
| 635 | 632 | assert!(plum.selected); |
| 636 | 633 | assert_eq!(plum.hue, plum_hue.to_string()); |
| 637 | - } | |
| 638 | 634 | |
| 639 | - #[test] | |
| 640 | - fn a_stored_hue_is_only_read_in_range() { | |
| 641 | 635 | assert_eq!(hue_of("hue-359"), Some(359)); |
| 642 | 636 | assert_eq!(hue_of("hue-360"), None); |
| 643 | 637 | assert_eq!(hue_of("hue-"), None); |