From b4d9d9ed9a641a2aa363f6c2d29db82ec3d8d51f Mon Sep 17 00:00:00 2001 From: Carson McManus Date: Thu, 19 Sep 2024 09:29:35 -0400 Subject: [PATCH] test(format/html): reenable snapshot tests (#3979) --- crates/biome_html_formatter/Cargo.toml | 2 +- crates/biome_html_formatter/tests/prettier_tests.rs | 2 +- crates/biome_html_formatter/tests/spec_test.rs | 4 ++-- crates/biome_html_formatter/tests/spec_tests.rs | 2 +- .../{attributes-break.html => html/attributes/break.html} | 0 .../attributes/break.html.snap} | 2 +- .../attributes/no-break.html} | 0 .../attributes/no-break.html.snap} | 2 +- .../attributes/self-closing.html} | 0 .../attributes/self-closing.html.snap} | 2 +- .../attributes/single-quotes.html} | 0 .../attributes/single-quotes.html.snap} | 4 ++-- .../biome_html_formatter/tests/specs/{ => html}/example.html | 0 .../tests/specs/{ => html}/example.html.snap | 0 .../tests/specs/{ => html}/long-content.html | 0 .../tests/specs/{ => html}/long-content.html.snap | 0 .../tests/specs/{ => html}/many-children.html | 0 .../tests/specs/{ => html}/many-children.html.snap | 0 .../tests/specs/{ => html}/self-closing.html | 0 .../tests/specs/{ => html}/self-closing.html.snap | 0 20 files changed, 10 insertions(+), 10 deletions(-) rename crates/biome_html_formatter/tests/specs/{attributes-break.html => html/attributes/break.html} (100%) rename crates/biome_html_formatter/tests/specs/{attributes-break.html.snap => html/attributes/break.html.snap} (93%) rename crates/biome_html_formatter/tests/specs/{attributes-no-break.html => html/attributes/no-break.html} (100%) rename crates/biome_html_formatter/tests/specs/{attributes-no-break.html.snap => html/attributes/no-break.html.snap} (91%) rename crates/biome_html_formatter/tests/specs/{attributes-self-closing.html => html/attributes/self-closing.html} (100%) rename crates/biome_html_formatter/tests/specs/{attributes-self-closing.html.snap => html/attributes/self-closing.html.snap} (89%) rename crates/biome_html_formatter/tests/specs/{attributes-single-quotes.html => html/attributes/single-quotes.html} (100%) rename crates/biome_html_formatter/tests/specs/{attributes-single-quotes.html.snap => html/attributes/single-quotes.html.snap} (76%) rename crates/biome_html_formatter/tests/specs/{ => html}/example.html (100%) rename crates/biome_html_formatter/tests/specs/{ => html}/example.html.snap (100%) rename crates/biome_html_formatter/tests/specs/{ => html}/long-content.html (100%) rename crates/biome_html_formatter/tests/specs/{ => html}/long-content.html.snap (100%) rename crates/biome_html_formatter/tests/specs/{ => html}/many-children.html (100%) rename crates/biome_html_formatter/tests/specs/{ => html}/many-children.html.snap (100%) rename crates/biome_html_formatter/tests/specs/{ => html}/self-closing.html (100%) rename crates/biome_html_formatter/tests/specs/{ => html}/self-closing.html.snap (100%) diff --git a/crates/biome_html_formatter/Cargo.toml b/crates/biome_html_formatter/Cargo.toml index 5288131cddf9..e54667e5ef74 100644 --- a/crates/biome_html_formatter/Cargo.toml +++ b/crates/biome_html_formatter/Cargo.toml @@ -21,7 +21,7 @@ biome_formatter_test = { workspace = true } biome_fs = { workspace = true } biome_html_parser = { workspace = true } biome_parser = { workspace = true } -biome_service = { workspace = true } +biome_service = { workspace = true, features = ["experimental-html"] } countme = { workspace = true, features = ["enable"] } tests_macros = { workspace = true } diff --git a/crates/biome_html_formatter/tests/prettier_tests.rs b/crates/biome_html_formatter/tests/prettier_tests.rs index 75b8cd3c13a5..f42abd1fbd0e 100644 --- a/crates/biome_html_formatter/tests/prettier_tests.rs +++ b/crates/biome_html_formatter/tests/prettier_tests.rs @@ -7,7 +7,7 @@ use biome_html_syntax::HtmlFileSource; mod language; -tests_macros::gen_tests! {"tests/specs/prettier/**/*.html", crate::test_snapshot, "script"} +tests_macros::gen_tests! {"tests/specs/prettier/**/*.html", crate::test_snapshot, ""} #[allow(dead_code)] fn test_snapshot(input: &'static str, _: &str, _: &str, _: &str) { diff --git a/crates/biome_html_formatter/tests/spec_test.rs b/crates/biome_html_formatter/tests/spec_test.rs index fea0ee2e56b9..ecfd4a4a7bf5 100644 --- a/crates/biome_html_formatter/tests/spec_test.rs +++ b/crates/biome_html_formatter/tests/spec_test.rs @@ -25,10 +25,10 @@ mod language { /// * `json/null` -> input: `tests/specs/json/null.json`, expected output: `tests/specs/json/null.json.snap` /// * `null` -> input: `tests/specs/null.json`, expected output: `tests/specs/null.json.snap` pub fn run(spec_input_file: &str, _expected_file: &str, test_directory: &str, _file_type: &str) { - let root_path = Path::new(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/specs/")); + let root_path = Path::new(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/specs/html")); let Some(test_file) = SpecTestFile::try_from_file(spec_input_file, root_path, None) else { - return; + panic!("Failed to set up snapshot test"); }; let source_type: HtmlFileSource = test_file.input_file().as_path().try_into().unwrap(); diff --git a/crates/biome_html_formatter/tests/spec_tests.rs b/crates/biome_html_formatter/tests/spec_tests.rs index 1023857cbe4d..1e2e624a4036 100644 --- a/crates/biome_html_formatter/tests/spec_tests.rs +++ b/crates/biome_html_formatter/tests/spec_tests.rs @@ -4,6 +4,6 @@ mod spec_test; mod formatter { mod html { - tests_macros::gen_tests! {"tests/specs/**/*.html", crate::spec_test::run, ""} + tests_macros::gen_tests! {"tests/specs/html/**/*.html", crate::spec_test::run, ""} } } diff --git a/crates/biome_html_formatter/tests/specs/attributes-break.html b/crates/biome_html_formatter/tests/specs/html/attributes/break.html similarity index 100% rename from crates/biome_html_formatter/tests/specs/attributes-break.html rename to crates/biome_html_formatter/tests/specs/html/attributes/break.html diff --git a/crates/biome_html_formatter/tests/specs/attributes-break.html.snap b/crates/biome_html_formatter/tests/specs/html/attributes/break.html.snap similarity index 93% rename from crates/biome_html_formatter/tests/specs/attributes-break.html.snap rename to crates/biome_html_formatter/tests/specs/html/attributes/break.html.snap index befbd8c3b1cb..e759ed258dbb 100644 --- a/crates/biome_html_formatter/tests/specs/attributes-break.html.snap +++ b/crates/biome_html_formatter/tests/specs/html/attributes/break.html.snap @@ -1,6 +1,6 @@ --- source: crates/biome_formatter_test/src/snapshot_builder.rs -info: attributes-break.html +info: attributes/break.html --- # Input diff --git a/crates/biome_html_formatter/tests/specs/attributes-no-break.html b/crates/biome_html_formatter/tests/specs/html/attributes/no-break.html similarity index 100% rename from crates/biome_html_formatter/tests/specs/attributes-no-break.html rename to crates/biome_html_formatter/tests/specs/html/attributes/no-break.html diff --git a/crates/biome_html_formatter/tests/specs/attributes-no-break.html.snap b/crates/biome_html_formatter/tests/specs/html/attributes/no-break.html.snap similarity index 91% rename from crates/biome_html_formatter/tests/specs/attributes-no-break.html.snap rename to crates/biome_html_formatter/tests/specs/html/attributes/no-break.html.snap index de5bb0ce15af..f54e1b647582 100644 --- a/crates/biome_html_formatter/tests/specs/attributes-no-break.html.snap +++ b/crates/biome_html_formatter/tests/specs/html/attributes/no-break.html.snap @@ -1,6 +1,6 @@ --- source: crates/biome_formatter_test/src/snapshot_builder.rs -info: attributes-no-break.html +info: attributes/no-break.html --- # Input diff --git a/crates/biome_html_formatter/tests/specs/attributes-self-closing.html b/crates/biome_html_formatter/tests/specs/html/attributes/self-closing.html similarity index 100% rename from crates/biome_html_formatter/tests/specs/attributes-self-closing.html rename to crates/biome_html_formatter/tests/specs/html/attributes/self-closing.html diff --git a/crates/biome_html_formatter/tests/specs/attributes-self-closing.html.snap b/crates/biome_html_formatter/tests/specs/html/attributes/self-closing.html.snap similarity index 89% rename from crates/biome_html_formatter/tests/specs/attributes-self-closing.html.snap rename to crates/biome_html_formatter/tests/specs/html/attributes/self-closing.html.snap index 8bd93c746836..4ee89251ba2d 100644 --- a/crates/biome_html_formatter/tests/specs/attributes-self-closing.html.snap +++ b/crates/biome_html_formatter/tests/specs/html/attributes/self-closing.html.snap @@ -1,6 +1,6 @@ --- source: crates/biome_formatter_test/src/snapshot_builder.rs -info: attributes-self-closing.html +info: attributes/self-closing.html --- # Input diff --git a/crates/biome_html_formatter/tests/specs/attributes-single-quotes.html b/crates/biome_html_formatter/tests/specs/html/attributes/single-quotes.html similarity index 100% rename from crates/biome_html_formatter/tests/specs/attributes-single-quotes.html rename to crates/biome_html_formatter/tests/specs/html/attributes/single-quotes.html diff --git a/crates/biome_html_formatter/tests/specs/attributes-single-quotes.html.snap b/crates/biome_html_formatter/tests/specs/html/attributes/single-quotes.html.snap similarity index 76% rename from crates/biome_html_formatter/tests/specs/attributes-single-quotes.html.snap rename to crates/biome_html_formatter/tests/specs/html/attributes/single-quotes.html.snap index 855e8962ba0e..2073db19c0cc 100644 --- a/crates/biome_html_formatter/tests/specs/attributes-single-quotes.html.snap +++ b/crates/biome_html_formatter/tests/specs/html/attributes/single-quotes.html.snap @@ -1,6 +1,6 @@ --- source: crates/biome_formatter_test/src/snapshot_builder.rs -info: attributes-single-quotes.html +info: attributes/single-quotes.html --- # Input @@ -25,4 +25,4 @@ Attribute Position: Auto ----- ```html -should keep "these" quotes``` +should keep "these" quotes``` diff --git a/crates/biome_html_formatter/tests/specs/example.html b/crates/biome_html_formatter/tests/specs/html/example.html similarity index 100% rename from crates/biome_html_formatter/tests/specs/example.html rename to crates/biome_html_formatter/tests/specs/html/example.html diff --git a/crates/biome_html_formatter/tests/specs/example.html.snap b/crates/biome_html_formatter/tests/specs/html/example.html.snap similarity index 100% rename from crates/biome_html_formatter/tests/specs/example.html.snap rename to crates/biome_html_formatter/tests/specs/html/example.html.snap diff --git a/crates/biome_html_formatter/tests/specs/long-content.html b/crates/biome_html_formatter/tests/specs/html/long-content.html similarity index 100% rename from crates/biome_html_formatter/tests/specs/long-content.html rename to crates/biome_html_formatter/tests/specs/html/long-content.html diff --git a/crates/biome_html_formatter/tests/specs/long-content.html.snap b/crates/biome_html_formatter/tests/specs/html/long-content.html.snap similarity index 100% rename from crates/biome_html_formatter/tests/specs/long-content.html.snap rename to crates/biome_html_formatter/tests/specs/html/long-content.html.snap diff --git a/crates/biome_html_formatter/tests/specs/many-children.html b/crates/biome_html_formatter/tests/specs/html/many-children.html similarity index 100% rename from crates/biome_html_formatter/tests/specs/many-children.html rename to crates/biome_html_formatter/tests/specs/html/many-children.html diff --git a/crates/biome_html_formatter/tests/specs/many-children.html.snap b/crates/biome_html_formatter/tests/specs/html/many-children.html.snap similarity index 100% rename from crates/biome_html_formatter/tests/specs/many-children.html.snap rename to crates/biome_html_formatter/tests/specs/html/many-children.html.snap diff --git a/crates/biome_html_formatter/tests/specs/self-closing.html b/crates/biome_html_formatter/tests/specs/html/self-closing.html similarity index 100% rename from crates/biome_html_formatter/tests/specs/self-closing.html rename to crates/biome_html_formatter/tests/specs/html/self-closing.html diff --git a/crates/biome_html_formatter/tests/specs/self-closing.html.snap b/crates/biome_html_formatter/tests/specs/html/self-closing.html.snap similarity index 100% rename from crates/biome_html_formatter/tests/specs/self-closing.html.snap rename to crates/biome_html_formatter/tests/specs/html/self-closing.html.snap