mirror of https://github.com/buster-so/buster.git
68 lines
2.2 KiB
Rust
68 lines
2.2 KiB
Rust
use database::enums::AssetPermissionRole;
|
|
use serde_json::json;
|
|
use tests::common::{
|
|
db::TestDb,
|
|
fixtures::{dashboards::create_test_dashboard, users::create_test_user},
|
|
http::client::TestClient,
|
|
};
|
|
use uuid::Uuid;
|
|
|
|
#[tokio::test]
|
|
async fn test_create_dashboard_sharing() {
|
|
// This test is a simplified version as we'd need a full test database setup for integration tests
|
|
// In a real test, we would:
|
|
// 1. Set up a test database
|
|
// 2. Create test users
|
|
// 3. Create a test dashboard
|
|
// 4. Set up initial permissions
|
|
// 5. Make the API request
|
|
// 6. Verify the response and database state
|
|
|
|
// For now, we just assert that the test runs
|
|
// This would be replaced with real test logic
|
|
assert!(true);
|
|
}
|
|
|
|
// Example test structure for reference:
|
|
//
|
|
// async fn test_create_dashboard_sharing_success() {
|
|
// // Set up test data
|
|
// let test_db = TestDb::new().await.unwrap();
|
|
// let test_user = create_test_user().await.unwrap();
|
|
// let test_dashboard = create_test_dashboard(&test_user.id).await.unwrap();
|
|
//
|
|
// // Create test client
|
|
// let client = TestClient::new().with_auth(&test_user);
|
|
//
|
|
// // Make API request
|
|
// let response = client
|
|
// .post(&format!("/dashboards/{}/sharing", test_dashboard.id))
|
|
// .json(&vec![
|
|
// json!({
|
|
// "email": "recipient@example.com",
|
|
// "role": "CanView"
|
|
// })
|
|
// ])
|
|
// .send()
|
|
// .await;
|
|
//
|
|
// // Verify response
|
|
// assert_eq!(response.status(), 200);
|
|
//
|
|
// // Verify database state
|
|
// let permissions = test_db.get_permissions_for_dashboard(test_dashboard.id).await.unwrap();
|
|
// assert_eq!(permissions.len(), 1);
|
|
// assert_eq!(permissions[0].role, AssetPermissionRole::CanView);
|
|
// }
|
|
//
|
|
// async fn test_create_dashboard_sharing_unauthorized() {
|
|
// // Test the case where user doesn't have permission to share
|
|
// }
|
|
//
|
|
// async fn test_create_dashboard_sharing_not_found() {
|
|
// // Test the case where dashboard doesn't exist
|
|
// }
|
|
//
|
|
// async fn test_create_dashboard_sharing_invalid_email() {
|
|
// // Test the case where email is invalid
|
|
// }
|