add interactive tests
This commit is contained in:
parent
373bdcd860
commit
d1459f8ae3
3 changed files with 178 additions and 5 deletions
|
@ -2,6 +2,7 @@ mod app;
|
|||
mod clipboard;
|
||||
mod event;
|
||||
mod window;
|
||||
mod dialog;
|
||||
|
||||
extern crate console_error_panic_hook;
|
||||
use std::future::Future;
|
||||
|
@ -58,6 +59,72 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "ci"))]
|
||||
#[component]
|
||||
pub async fn InteractiveTest<'a, G: Html, F>(cx: Scope<'a>, props: TestProps<'a, F>) -> View<G>
|
||||
where
|
||||
F: Future<Output = anyhow::Result<()>> + 'a,
|
||||
{
|
||||
let mut test = Some(props.test);
|
||||
let render_test = create_signal(cx, false);
|
||||
|
||||
let run_test = |_| {
|
||||
render_test.set(true);
|
||||
};
|
||||
|
||||
view! { cx,
|
||||
(if *render_test.get() {
|
||||
let test = test.take().unwrap();
|
||||
|
||||
let fallback = view! { cx,
|
||||
tr {
|
||||
td { code { (props.name.to_string()) } }
|
||||
td {
|
||||
"Running Test..."
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
view! { cx,
|
||||
Suspense(fallback=fallback) {
|
||||
Test(name=props.name, test=test)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
view! { cx,
|
||||
tr {
|
||||
td { code { (props.name.to_string()) } }
|
||||
td {
|
||||
button(on:click=run_test) { "Run Interactive Test"}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "ci")]
|
||||
#[component]
|
||||
pub async fn InteractiveTest<'a, G: Html, F>(cx: Scope<'a>, _props: TestProps<'a, F>) -> View<G>
|
||||
where
|
||||
F: Future<Output = anyhow::Result<()>> + 'a,
|
||||
{
|
||||
view! { cx, "Interactive tests are not run in CI mode" }
|
||||
}
|
||||
|
||||
#[component]
|
||||
pub async fn Terminate<'a, G: Html>(cx: Scope<'a>) -> View<G> {
|
||||
#[cfg(feature = "ci")]
|
||||
sycamore::suspense::await_suspense(cx, async {
|
||||
tauri_sys::process::exit(0).await;
|
||||
})
|
||||
.await;
|
||||
|
||||
view! {
|
||||
cx,
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
wasm_logger::init(wasm_logger::Config::default());
|
||||
|
||||
|
@ -69,11 +136,6 @@ fn main() {
|
|||
}));
|
||||
|
||||
sycamore::render(|cx| {
|
||||
#[cfg(feature = "ci")]
|
||||
sycamore::suspense::await_suspense(cx, async {
|
||||
tauri_sys::process::exit(0).await;
|
||||
});
|
||||
|
||||
view! { cx,
|
||||
table {
|
||||
tbody {
|
||||
|
@ -83,7 +145,18 @@ fn main() {
|
|||
Test(name="app::get_tauri_version",test=app::get_tauri_version())
|
||||
Test(name="clipboard::read_text | clipboard::write_text",test=clipboard::test())
|
||||
Test(name="event::emit",test=event::emit())
|
||||
InteractiveTest(name="dialog::message",test=dialog::message())
|
||||
InteractiveTest(name="dialog::ask",test=dialog::ask())
|
||||
InteractiveTest(name="dialog::confirm",test=dialog::confirm())
|
||||
InteractiveTest(name="dialog::pick_file",test=dialog::pick_file())
|
||||
InteractiveTest(name="dialog::pick_files",test=dialog::pick_files())
|
||||
InteractiveTest(name="dialog::pick_folder",test=dialog::pick_folder())
|
||||
InteractiveTest(name="dialog::pick_folders",test=dialog::pick_folders())
|
||||
InteractiveTest(name="dialog::save",test=dialog::save())
|
||||
|
||||
// Test(name="window::WebviewWindow::new",test=window::create_window())
|
||||
|
||||
Terminate
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue