Skip to content

Commit

Permalink
Move visual tests folder
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielleHuisman committed Mar 31, 2024
1 parent dd7767d commit 9ad1404
Show file tree
Hide file tree
Showing 17 changed files with 12 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
members = ["packages/*", "packages/*/example", "packages/*/test/*"]
members = ["packages/*", "packages/*/example", "packages/*/tests/*"]
resolver = "2"

[workspace.package]
Expand Down
26 changes: 11 additions & 15 deletions packages/leptos/tests/playwright.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ use std::{env, fs, path::Path, process::Command};
pub fn playwright() {
let repository_url = "https://github.com/floating-ui/floating-ui";
let repository_path = Path::new(env!("CARGO_TARGET_TMPDIR")).join("floating-ui");
let repository_dom_path = repository_path.join("packages/dom");
let repository_playwright_config_path =
repository_dom_path.join("packages/dom/playwright.config.ts");

// if repository_path.exists() {
// fs::remove_dir_all(repository_path.clone()).expect("Removing repository failed.");
// }
let visual_test_path = Path::new(env!("CARGO_MANIFEST_DIR")).join("test/visual");

if !repository_path.exists() {
let status = Command::new("git")
Expand All @@ -34,24 +35,21 @@ pub fn playwright() {
assert!(status.success(), "Git pull failed.");
}

let config_path = repository_path.join("packages/dom/playwright.config.ts");
let mut config_content =
fs::read_to_string(config_path.clone()).expect("Reading Playwright config file failed.");
let mut config_content = fs::read_to_string(repository_playwright_config_path.clone())
.expect("Reading Playwright config file failed.");

config_content = config_content
.replace("retries: 3,", "retries: 0,")
.replace(
"command: 'pnpm run dev',",
&format!(
"command: 'trunk serve --port 1234',\n cwd: '{}',\n stdout: 'pipe',",
Path::new(env!("CARGO_MANIFEST_DIR"))
.join("test/visual")
.to_str()
.expect("Path should be valid.")
visual_test_path.to_str().expect("Path should be valid.")
),
);

fs::write(config_path, config_content).expect("Writing Playwright config file failed.");
fs::write(repository_playwright_config_path, config_content)
.expect("Writing Playwright config file failed.");

let status = Command::new("pnpm")
.arg("install")
Expand All @@ -60,8 +58,6 @@ pub fn playwright() {
.expect("pnpm install failed.");
assert!(status.success(), "pnpm install failed");

let dom_path = repository_path.clone().join("packages/dom");

let status = Command::new("pnpm")
.arg("run")
.arg("build")
Expand All @@ -78,7 +74,7 @@ pub fn playwright() {
let status = Command::new("npx")
.arg("playwright")
.arg("install")
.current_dir(dom_path.clone())
.current_dir(repository_dom_path.clone())
.status()
.expect("Playwright install failed.");
assert!(status.success(), "Playwright install failed.");
Expand All @@ -87,7 +83,7 @@ pub fn playwright() {
let status = Command::new("pnpm")
.arg("run")
.arg("playwright")
.current_dir(dom_path.clone())
.current_dir(repository_dom_path.clone())
.status()
.expect("Playwright tests failed.");
assert!(status.success(), "Playwright tests failed.");
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 9ad1404

Please sign in to comment.