test(saas): Phase 1 integration tests — billing + scheduled_task + knowledge (68 tests)
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
- Fix TIMESTAMPTZ decode errors: add ::TEXT cast to all SELECT queries
where Row structs use String for TIMESTAMPTZ columns (~22 locations)
- Fix Axum 0.7 route params: {id} → :id in billing/knowledge/scheduled_task routes
- Fix JSONB bind: scheduled_task INSERT uses ::jsonb cast for input_payload
- Add billing_test.rs (14 tests): plans, subscription, usage, payments, invoices
- Add scheduled_task_test.rs (12 tests): CRUD, validation, isolation
- Add knowledge_test.rs (20 tests): categories, items, versions, search, analytics, permissions
- Fix auth test regression: 6 tests were failing due to TIMESTAMPTZ type mismatch
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -58,12 +58,12 @@ pub async fn create_task(
|
||||
req: &CreateScheduledTaskRequest,
|
||||
) -> SaasResult<ScheduledTaskResponse> {
|
||||
let id = uuid::Uuid::new_v4().to_string();
|
||||
let now = chrono::Utc::now().to_rfc3339();
|
||||
let input_json = req.input.as_ref().map(|v| v.to_string());
|
||||
let now = chrono::Utc::now();
|
||||
let input_json: Option<String> = req.input.as_ref().map(|v| v.to_string());
|
||||
|
||||
sqlx::query(
|
||||
"INSERT INTO scheduled_tasks (id, account_id, name, description, schedule, schedule_type, target_type, target_id, enabled, input_payload, created_at, updated_at)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $11)"
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10::jsonb, $11, $11)"
|
||||
)
|
||||
.bind(&id)
|
||||
.bind(account_id)
|
||||
@@ -93,7 +93,7 @@ pub async fn create_task(
|
||||
last_result: None,
|
||||
last_error: None,
|
||||
last_duration_ms: None,
|
||||
created_at: now,
|
||||
created_at: now.to_rfc3339(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ pub async fn list_tasks(
|
||||
let rows: Vec<ScheduledTaskRow> = sqlx::query_as(
|
||||
"SELECT id, account_id, name, description, schedule, schedule_type,
|
||||
target_type, target_id, enabled, last_run_at, next_run_at,
|
||||
run_count, last_result, last_error, last_duration_ms, input_payload, created_at
|
||||
run_count, last_result, last_error, last_duration_ms, input_payload, created_at::TEXT
|
||||
FROM scheduled_tasks WHERE account_id = $1 ORDER BY created_at DESC"
|
||||
)
|
||||
.bind(account_id)
|
||||
@@ -124,7 +124,7 @@ pub async fn get_task(
|
||||
let row: Option<ScheduledTaskRow> = sqlx::query_as(
|
||||
"SELECT id, account_id, name, description, schedule, schedule_type,
|
||||
target_type, target_id, enabled, last_run_at, next_run_at,
|
||||
run_count, last_result, last_error, last_duration_ms, input_payload, created_at
|
||||
run_count, last_result, last_error, last_duration_ms, input_payload, created_at::TEXT
|
||||
FROM scheduled_tasks WHERE id = $1 AND account_id = $2"
|
||||
)
|
||||
.bind(task_id)
|
||||
@@ -151,7 +151,7 @@ pub async fn update_task(
|
||||
let schedule_type = req.schedule_type.as_deref().unwrap_or(&existing.schedule_type);
|
||||
let enabled = req.enabled.unwrap_or(existing.enabled);
|
||||
let description = req.description.as_deref().or(existing.description.as_deref());
|
||||
let now = chrono::Utc::now().to_rfc3339();
|
||||
let now = chrono::Utc::now();
|
||||
|
||||
let (target_type, target_id) = if let Some(ref target) = req.target {
|
||||
(target.target_type.as_str(), target.id.as_str())
|
||||
|
||||
Reference in New Issue
Block a user