diff --git a/src/templates/bulma/navbar.html b/src/templates/bulma/navbar.html
index 6240d01..b9f20d7 100644
--- a/src/templates/bulma/navbar.html
+++ b/src/templates/bulma/navbar.html
@@ -53,7 +53,7 @@
{%if support_path %}
-
+
{% endif %}
{% if enable_auth %}
diff --git a/tests/test_setup/helper.rs b/tests/test_setup/helper.rs
index 6ca0dbc..555391f 100644
--- a/tests/test_setup/helper.rs
+++ b/tests/test_setup/helper.rs
@@ -162,6 +162,16 @@ pub fn create_actix_admin_builder(
false,
);
+ let _support_route = admin_builder.add_support_handler("/support", web::get().to(support));
+ let _card_route = admin_builder.add_custom_handler("card", "/card/{id}", web::get().to(card), false);
+
+ let card_grid: Vec> = vec![
+ vec!["admin/card/1".to_string(), "admin/card/2".to_string()],
+ vec!["admin/card/3".to_string()],
+ ];
+ admin_builder.add_card_grid("Card Grid", "/my_card_grid", card_grid, true);
+
+
admin_builder
}
@@ -198,6 +208,15 @@ async fn edit_post_from_plaintext(
.await
}
+async fn support() -> Result {
+ let resp = ") -> Result {
+ let resp = format!("
SupportDiv
";
+ Ok(HttpResponse::Ok().content_type("text/html").body(resp))
+}
+
+async fn card(id: web::PathCard{}
", id);
+ Ok(HttpResponse::Ok().content_type("text/html").body(resp))
+}
pub trait BodyTest {
fn as_str(&self) -> &str;
}
diff --git a/tests/test_setup/mod.rs b/tests/test_setup/mod.rs
index b33b91c..ce7d629 100644
--- a/tests/test_setup/mod.rs
+++ b/tests/test_setup/mod.rs
@@ -12,12 +12,7 @@ pub use sample_with_tenant_id::Entity as SampleWithTenantId;
#[allow(dead_code)]
pub mod prelude {
- pub use super::comment;
- pub use super::post;
- pub use super::sample_with_tenant_id;
- pub use super::Comment;
- pub use super::Post;
- pub use super::SampleWithTenantId;
+ pub use super::*;
pub use crate::test_setup::webdriver:: { setup, teardown };
pub use crate::test_setup::helper::{create_actix_admin_builder, setup_db, BodyTest};
}
diff --git a/tests/webdriver_cardgrid.rs b/tests/webdriver_cardgrid.rs
new file mode 100644
index 0000000..3943d90
--- /dev/null
+++ b/tests/webdriver_cardgrid.rs
@@ -0,0 +1,37 @@
+use tokio::test as tokio_test;
+mod test_setup;
+use test_setup::prelude::*;
+use tokio;
+
+mod webdriver_tests {
+ use std::time::Duration;
+
+ use super::*;
+ use fantoccini::Locator;
+
+ #[tokio_test]
+ async fn webdriver_support() -> Result<(), fantoccini::error::CmdError> {
+ let (server_task, geckodriver, c) = setup(true).await.unwrap();
+
+ // Open the index page
+ c.goto("http://localhost:5555/admin/").await?;
+ let url = c.current_url().await?;
+ assert_eq!(url.as_ref(), "http://localhost:5555/admin/");
+
+ let html_source = c.source().await?;
+ assert_eq!(html_source.contains("Card1"), false, "Expected no Card1 on the page");
+
+ // Click on support question mark
+ c.find(Locator::LinkText("Card Grid")).await?.click().await?;
+ tokio::time::sleep(Duration::from_secs(1)).await;
+ let url = c.current_url().await?;
+ assert_eq!(url.as_ref(), "http://localhost:5555/admin/my_card_grid");
+
+ let html_source = c.source().await?;
+ assert!(html_source.contains("Card1"), "Expected Card1 on the page");
+ assert!(html_source.contains("Card2"), "Expected Card2 on the page");
+ assert!(html_source.contains("Card3"), "Expected Card3 on the page");
+
+ teardown(server_task, geckodriver, c).await
+ }
+}
diff --git a/tests/webdriver_support.rs b/tests/webdriver_support.rs
new file mode 100644
index 0000000..5b74a0b
--- /dev/null
+++ b/tests/webdriver_support.rs
@@ -0,0 +1,35 @@
+use tokio::test as tokio_test;
+mod test_setup;
+use test_setup::prelude::*;
+use tokio;
+
+mod webdriver_tests {
+ use std::time::Duration;
+
+ use super::*;
+ use fantoccini::Locator;
+
+ #[tokio_test]
+ async fn webdriver_support() -> Result<(), fantoccini::error::CmdError> {
+ let (server_task, geckodriver, c) = setup(true).await.unwrap();
+
+ // Open the index page
+ c.goto("http://localhost:5555/admin/").await?;
+ let url = c.current_url().await?;
+ assert_eq!(url.as_ref(), "http://localhost:5555/admin/");
+
+ let html_source = c.source().await?;
+ assert_eq!(html_source.contains("SupportDiv"), false, "Expected no SupportDiv on the page");
+
+ // Click on support question mark
+ c.find(Locator::Id("support_nav")).await?.click().await?;
+ tokio::time::sleep(Duration::from_secs(1)).await;
+ let url = c.current_url().await?;
+ assert_eq!(url.as_ref(), "http://localhost:5555/admin/#");
+
+ let html_source = c.source().await?;
+ assert!(html_source.contains("SupportDiv"), "Expected SupportDiv on the page");
+
+ teardown(server_task, geckodriver, c).await
+ }
+}