From db810543512be4376dae7e33a29027894fb972dd Mon Sep 17 00:00:00 2001 From: Danielle Huisman Date: Fri, 5 Apr 2024 22:45:25 +0200 Subject: [PATCH] Fix arrow visual test --- packages/leptos/tests/playwright.rs | 11 ++++++++++ .../leptos/tests/visual/src/spec/arrow.rs | 8 ++++---- .../tests/visual/src/utils/use_scroll.rs | 20 +++++++++++-------- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/packages/leptos/tests/playwright.rs b/packages/leptos/tests/playwright.rs index e73d3a6..8fbbbfe 100644 --- a/packages/leptos/tests/playwright.rs +++ b/packages/leptos/tests/playwright.rs @@ -24,6 +24,7 @@ pub fn playwright() { let repository_dom_path = repository_path.join("packages/dom"); let repository_package_json_path = repository_dom_path.join("package.json"); let repository_playwright_config_path = repository_dom_path.join("playwright.config.ts"); + let repository_arrow_test_path = repository_dom_path.join("test/functional/arrow.test.ts"); let visual_test_path = Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/visual"); @@ -126,6 +127,16 @@ pub fn playwright() { fs::write(repository_playwright_config_path, config_content) .expect("Writing Playwright config file failed."); + let arrow_test_content = fs::read_to_string(repository_arrow_test_path.clone()) + .expect("Reading arrow test file failed.") + .replace( + // Match React test behaviour + "await click(page, `[data-testid=\"arrow-padding-${arrowPadding}\"]`);", + "if (arrowPadding !== 0) { await click(page, `[data-testid=\"arrow-padding-${arrowPadding}\"]`); }", + ); + fs::write(repository_arrow_test_path, arrow_test_content) + .expect("Writing arrow test file failed."); + let status = Command::new("pnpm") .arg("run") .arg("playwright") diff --git a/packages/leptos/tests/visual/src/spec/arrow.rs b/packages/leptos/tests/visual/src/spec/arrow.rs index c8b6673..9737024 100644 --- a/packages/leptos/tests/visual/src/spec/arrow.rs +++ b/packages/leptos/tests/visual/src/spec/arrow.rs @@ -80,13 +80,10 @@ pub fn Arrow() -> impl IntoView { rtl: None, }); - // Match React test behaviour let placement_update_scroll = update_scroll.clone(); let padding_update_scroll = update_scroll.clone(); let add_offset_update_scroll = update_scroll.clone(); - // _ = watch(placement, move |_, _, _| placement_update_scroll(), false); - // _ = watch(padding, move |_, _, _| padding_update_scroll(), false); - // _ = watch(add_offset, move |_, _, _| add_offset_update_scroll(), false); + let center_offset_update_scroll = update_scroll.clone(); view! {

Arrow

@@ -312,6 +309,7 @@ pub fn Arrow() -> impl IntoView { each=|| [true, false] key=|value| format!("{}", value) children=move |value| { + let center_offset_update_scroll = center_offset_update_scroll.clone(); view! {