Skip to content

Commit

Permalink
Ensure we don't break webapp links
Browse files Browse the repository at this point in the history
  • Loading branch information
Nadrieril committed Jan 26, 2025
1 parent a8dd30c commit c7efd96
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/rulesets/ty_based.rs
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ pub static KNOWN_TY_BASED_BUNDLES: &[BundleDoc<RuleOptions>] = &[
fallback_to_outer: FallbackToOuterBehavior::EatBoth,
..RuleOptions::STATELESS_2021
},
doc: "A backwards-compatible proposal by @dianne that behaves close to the\
doc: "A backwards-compatible proposal by @dianne that behaves close to the \
2024 stateless proposal.",
},
BundleDoc {
Expand Down
24 changes: 24 additions & 0 deletions src/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,30 @@ fn decode_base64<T: Decode>(x: JsValue) -> Option<T> {
Some(bincode::decode_from_slice(&bits, config).ok()?.0)
}

#[test]
/// Ensure we don't change the encoding of rulesets, as that would break saved links into the app.
fn ruleset_encodings() -> anyhow::Result<()> {
use std::fmt::Write;
let mut out = String::new();
for b in KNOWN_TY_BASED_BUNDLES {
let ruleset = RuleSetJs {
this_solver: true,
ty_based: b.ruleset,
bm_based: Conf::rfc2005(),
};
let _ = writeln!(&mut out, "{}: {}", b.name, ruleset.encode());
}
insta::with_settings!({
snapshot_path => "../tests/snapshots",
snapshot_suffix => "ruleset-encodings",
prepend_module_to_snapshot => false,
omit_expression => true,
}, {
insta::assert_snapshot!(out);
});
Ok(())
}

/// Like `RuleSet` but remembers the ruleset of the other solver to avoid losing state in the
/// frontend.
#[wasm_bindgen]
Expand Down

0 comments on commit c7efd96

Please sign in to comment.