Add a playwright test that checks static generation (#2608)

* add a playwright test that checks static generation

* add playwright-static-generation to the workspace

* fix static-generation name in CLI
This commit is contained in:
Evan Almloff authored and GitHub committed 2024-07-10 12:43:02 -07:00
1 parent f07ab370b9
commit b13236cd38
8 files changed
+90 -1

No files matched your search

@@ -0,0 +1,3 @@
.dioxus
dist
target
@@ -0,0 +1,17 @@
[package]
name = "dioxus-playwright-static-generation-test"
version = "0.1.0"
edition = "2021"
publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
dioxus = { workspace = true, features = ["fullstack"] }
serde = "1.0.159"
tokio = { workspace = true, features = ["full"], optional = true }
[features]
default = []
server = ["dioxus/axum", "tokio"]
web = ["dioxus/web"]
@@ -0,0 +1,29 @@
// This test is used by playwright configured in the root of the repo
// Tests:
// - Static Generation
// - Simple Suspense
// - Hydration
#![allow(non_snake_case)]
use dioxus::prelude::*;
fn main() {
LaunchBuilder::static_generation().launch(app);
}
fn app() -> Element {
let mut count = use_signal(|| 12345);
let server_data = use_server_future(get_server_data)?;
rsx! {
h1 { "hello axum! {count}" }
button { class: "increment-button", onclick: move |_| count += 1, "Increment" }
"Server said: {server_data:?}"
}
}
#[server(GetServerData)]
async fn get_server_data() -> Result<String, ServerFnError> {
tokio::time::sleep(std::time::Duration::from_millis(100)).await;
Ok("Hello from the server!".to_string())
}