Fix playwright tests (#2695)

This commit is contained in:
Evan Almloff authored and GitHub committed 2024-07-24 12:48:30 -07:00
1 parent 9479d2376d
commit bd484842bd
28 files changed
+477 -330

No files matched your search

+14 -3
View File
@@ -42,11 +42,22 @@ pub fn launch(
// Serve the program if we are running with cargo
if std::env::var_os("CARGO").is_some() || std::env::var_os("DIOXUS_ACTIVE").is_some() {
// Get the address the server should run on. If the CLI is running, the CLI proxies static generation into the main address
// and we use the generated address the CLI gives us
let cli_args = dioxus_cli_config::RuntimeCLIArguments::from_cli();
let address = cli_args
.as_ref()
.map(|args| args.fullstack_address().address())
.unwrap_or_else(|| std::net::SocketAddr::from(([127, 0, 0, 1], 8080)));
// Point the user to the CLI address if the CLI is running or the fullstack address if not
let serve_address = cli_args
.map(|args| args.cli_address())
.unwrap_or_else(|| address);
println!(
"Serving static files from {} at http://127.0.0.1:8080",
"Serving static files from {} at http://{serve_address}",
path.display()
);
let addr = std::net::SocketAddr::from(([127, 0, 0, 1], 8080));
let mut serve_dir =
ServeDir::new(path.clone()).call_fallback_on_method_not_allowed(true);
@@ -66,7 +77,7 @@ pub fn launch(
})))
};
let listener = tokio::net::TcpListener::bind(addr).await.unwrap();
let listener = tokio::net::TcpListener::bind(address).await.unwrap();
axum::serve(listener, router.into_make_service())
.await
.unwrap();
+4 -1
View File
@@ -111,6 +111,8 @@ async fn prerender_route(
let context = server_context_for_route(&route);
let wrapper = config.fullstack_template();
let mut virtual_dom = VirtualDom::new(app);
let document = std::rc::Rc::new(dioxus_fullstack::document::ServerDocument::default());
virtual_dom.provide_root_context(document.clone() as std::rc::Rc<dyn Document>);
with_server_context(context.clone(), || {
tokio::task::block_in_place(|| virtual_dom.rebuild_in_place());
});
@@ -119,10 +121,11 @@ async fn prerender_route(
let mut wrapped = String::new();
// Render everything before the body
wrapper.render_before_body(&mut wrapped)?;
wrapper.render_head(&mut wrapped, &virtual_dom)?;
renderer.render_to(&mut wrapped, &virtual_dom)?;
wrapper.render_after_main(&mut wrapped, &virtual_dom)?;
wrapper.render_after_body(&mut wrapped)?;
cache.cache(route, wrapped)