init projectmycelium

This commit is contained in:
mik-tf
2025-09-01 21:37:01 -04:00
commit b41efb0e99
319 changed files with 128160 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
//! Shared helpers for frontend UX integration tests
use std::fs;
use std::panic::{catch_unwind, AssertUnwindSafe};
/// Cleanup test user data JSON file for a given email
pub fn cleanup_test_user_data(user_email: &str) {
let encoded_email = user_email.replace("@", "_at_").replace(".", "_");
let file_path = format!("user_data/{}.json", encoded_email);
if std::path::Path::new(&file_path).exists() {
let _ = fs::remove_file(&file_path);
}
}
/// Run a named step, catching panics to allow the test to continue and collect failures
pub fn run_step<F: FnOnce()>(name: &str, f: F, failures: &mut Vec<String>) {
println!("🔧 {}", name);
match catch_unwind(AssertUnwindSafe(f)) {
Ok(_) => println!("{} - OK", name),
Err(err) => {
let msg = if let Some(s) = err.downcast_ref::<&str>() {
s.to_string()
} else if let Some(s) = err.downcast_ref::<String>() {
s.clone()
} else {
"unknown panic".to_string()
};
println!("{} - FAILED: {}", name, msg);
failures.push(format!("{}: {}", name, msg));
}
}
}