mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-10 06:34:20 +00:00
fix web playwright tests
This commit is contained in:
parent
1bbceac4e1
commit
c431429448
10 changed files with 21 additions and 11 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -2811,6 +2811,8 @@ version = "0.0.1"
|
|||
dependencies = [
|
||||
"dioxus",
|
||||
"serde_json",
|
||||
"tracing",
|
||||
"tracing-wasm",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
|
@ -66,7 +66,7 @@ dioxus-router-macro = { path = "packages/router-macro", version = "0.4.1" }
|
|||
dioxus-html = { path = "packages/html", version = "0.4.0" }
|
||||
dioxus-html-internal-macro = { path = "packages/html-internal-macro", version = "0.4.0" }
|
||||
dioxus-hooks = { path = "packages/hooks", version = "0.4.0" }
|
||||
dioxus-web = { path = "packages/web", version = "0.4.0", default-features = false }
|
||||
dioxus-web = { path = "packages/web", version = "0.4.0" }
|
||||
dioxus-ssr = { path = "packages/ssr", version = "0.4.0", default-features = false }
|
||||
dioxus-desktop = { path = "packages/desktop", version = "0.4.0" }
|
||||
dioxus-mobile = { path = "packages/mobile", version = "0.4.0" }
|
||||
|
|
|
@ -45,8 +45,9 @@ pub fn provide_context<T: 'static + Clone>(value: T) -> T {
|
|||
}
|
||||
|
||||
/// Provide a context to the root scope
|
||||
pub fn provide_root_context<T: 'static + Clone>(value: T) -> Option<T> {
|
||||
pub fn provide_root_context<T: 'static + Clone>(value: T) -> T {
|
||||
Runtime::with_current_scope(|cx| cx.provide_root_context(value))
|
||||
.expect("to be in a dioxus runtime")
|
||||
}
|
||||
|
||||
/// Suspends the current component
|
||||
|
|
|
@ -5,6 +5,6 @@ pub fn use_root_context<T: 'static + Clone>(new: impl FnOnce() -> T) -> T {
|
|||
use_hook(|| {
|
||||
try_consume_context::<T>()
|
||||
// If no context is provided, create a new one at the root
|
||||
.unwrap_or_else(|| provide_root_context(new()).expect(" A runtime to exist"))
|
||||
.unwrap_or_else(|| provide_root_context(new()))
|
||||
})
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -82,7 +82,7 @@ module.exports = defineConfig({
|
|||
},
|
||||
{
|
||||
cwd: path.join(process.cwd(), "web"),
|
||||
command: "cargo run --package dioxus-cli --release -- serve --skip-assets",
|
||||
command: "cargo run --package dioxus-cli --release -- serve",
|
||||
port: 8080,
|
||||
timeout: 20 * 60 * 1000,
|
||||
reuseExistingServer: !process.env.CI,
|
||||
|
@ -90,7 +90,7 @@ module.exports = defineConfig({
|
|||
},
|
||||
{
|
||||
cwd: path.join(process.cwd(), 'fullstack'),
|
||||
command: 'cargo run --package dioxus-cli --release -- serve --platform fullstack --skip-assets',
|
||||
command: 'cargo run --package dioxus-cli --release -- serve --platform fullstack',
|
||||
port: 3333,
|
||||
timeout: 20 * 60 * 1000,
|
||||
reuseExistingServer: !process.env.CI,
|
||||
|
|
|
@ -9,3 +9,5 @@ publish = false
|
|||
[dependencies]
|
||||
dioxus = { workspace = true, features = ["web"]}
|
||||
serde_json = "1.0.96"
|
||||
tracing.workspace = true
|
||||
tracing-wasm = "0.2.1"
|
||||
|
|
|
@ -43,5 +43,10 @@ fn app() -> Element {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
tracing_wasm::set_as_global_default_with_config(
|
||||
tracing_wasm::WASMLayerConfigBuilder::default()
|
||||
.set_max_level(tracing::Level::TRACE)
|
||||
.build(),
|
||||
);
|
||||
launch(app);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ pub(crate) fn get_global_context() -> GlobalSignalContext {
|
|||
let context = GlobalSignalContext {
|
||||
signal: Rc::new(RefCell::new(HashMap::new())),
|
||||
};
|
||||
provide_root_context(context).unwrap()
|
||||
provide_root_context(context)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use dioxus_core::ScopeId;
|
||||
use core::panic;
|
||||
use dioxus_html::prelude::{EvalError, EvalProvider, Evaluator};
|
||||
use futures_util::StreamExt;
|
||||
use generational_box::{AnyStorage, GenerationalBox, UnsyncStorage};
|
||||
|
@ -9,8 +9,8 @@ use wasm_bindgen::prelude::*;
|
|||
|
||||
/// Provides the WebEvalProvider through [`cx.provide_context`].
|
||||
pub fn init_eval() {
|
||||
let provider: Rc<dyn EvalProvider> = Rc::new(WebEvalProvider {});
|
||||
ScopeId::ROOT.provide_context(provider);
|
||||
let provider: Rc<dyn EvalProvider> = Rc::new(WebEvalProvider);
|
||||
dioxus_core::ScopeId::ROOT.provide_context(provider);
|
||||
}
|
||||
|
||||
/// Represents the web-target's provider of evaluators.
|
||||
|
|
Loading…
Reference in a new issue