diff --git a/src/inbound/admin_ui/mod.rs b/src/inbound/admin_ui/mod.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/inbound/mod.rs b/src/inbound/mod.rs index 77eee09..ae20cb4 100644 --- a/src/inbound/mod.rs +++ b/src/inbound/mod.rs @@ -1,2 +1,5 @@ #[cfg(any(feature = "web", feature = "server"))] pub mod renderer; + +#[cfg(any(feature = "web", feature = "server"))] +pub mod admin_ui; diff --git a/src/inbound/renderer/mod.rs b/src/inbound/renderer/mod.rs index a6933b9..b81bd96 100644 --- a/src/inbound/renderer/mod.rs +++ b/src/inbound/renderer/mod.rs @@ -190,6 +190,8 @@ pub fn Post(page: String, id: String) -> Element { #[cfg(test)] mod tests { + use mockall::predicate; + use crate::{ domain::entities, outbound::services::site::{MockSiteService, SiteServiceProvider}, @@ -227,7 +229,7 @@ mod tests { fn single_gets_page_info() { let mut app = VirtualDom::new(|| { rsx! { - Single { page: "test".to_string() } + Single { page: "pagename".to_string() } } }); @@ -237,6 +239,7 @@ mod tests { mock_service .expect_get_page() .times(1) + .with(predicate::eq("test"), predicate::eq("pagename")) .returning(move |_, _| { Box::pin(async { Ok(entities::site::Page { @@ -263,4 +266,41 @@ mod tests { assert!(elem_str.contains("Test page name")); assert!(elem_str.contains("test content")); } + + #[test] + fn home_gets_page_info() { + let mut app = VirtualDom::new(|| { + rsx! { + Home {} + } + }); + + testing::add_test_site_context(&mut app); + + let mut mock_service = MockSiteService::new(); + mock_service + .expect_get_page() + .times(1) + .with(predicate::eq("test"), predicate::eq("/")) + .returning(move |_, _| { + Box::pin(async { + Ok(entities::site::Page { + info: entities::site::PageInfo { + title: "Test page name".to_string(), + name: "test".to_string(), + order: 0, + }, + content: PageContent::Single { + content: entities::site::Post { blocks: vec![] }, + }, + }) + }) + }); + + server_context().insert(SiteServiceProvider::with(mock_service)); + + app.rebuild_in_place(); + let elem_str = dioxus::ssr::render(&app); + assert!(elem_str.contains("Test page name")); + } } diff --git a/src/main.rs b/src/main.rs index 4078caf..67eab0b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,8 +3,6 @@ use dioxus_logger::tracing::Level; mod domain; mod inbound; - -#[cfg(feature = "server")] mod outbound; fn main() { diff --git a/src/outbound/mod.rs b/src/outbound/mod.rs index 31f34e8..ab6fa55 100644 --- a/src/outbound/mod.rs +++ b/src/outbound/mod.rs @@ -1,2 +1,4 @@ +#[cfg(feature = "server")] pub mod repository; + pub mod services; diff --git a/src/outbound/repository/adapters/mod.rs b/src/outbound/repository/adapters/mod.rs index eb29191..48ac732 100644 --- a/src/outbound/repository/adapters/mod.rs +++ b/src/outbound/repository/adapters/mod.rs @@ -1 +1,2 @@ +#[cfg(feature = "server")] pub mod memory; diff --git a/src/outbound/repository/mod.rs b/src/outbound/repository/mod.rs index 57bc502..b02da39 100644 --- a/src/outbound/repository/mod.rs +++ b/src/outbound/repository/mod.rs @@ -1,4 +1,2 @@ -pub mod site; - -#[cfg(feature = "server")] pub mod adapters; +pub mod site; diff --git a/src/outbound/services/mod.rs b/src/outbound/services/mod.rs index 4d481aa..56264fa 100644 --- a/src/outbound/services/mod.rs +++ b/src/outbound/services/mod.rs @@ -1 +1,2 @@ +#[cfg(feature = "server")] pub mod site;