f438e972d4
Lift duplicated test-harness code (User factories, TestConfig builder, login/CSRF flow, form/json helpers, case-directory seeding, URL path builders) into `server/tests/common/` so future API changes touch one file instead of every integration test. Migrated batches: csrf_attack, auth, login, magic_link, security_headers (28 tests); analyze, case_page, delete_recording, close_watermark, retention_sweep (67 tests). All 95 tests still green. Net line delta across these 10 files: +1113 / -1896 (~780 lines removed), plus ~500 lines of new shared infrastructure under tests/common/.
68 lines
2.2 KiB
Rust
68 lines
2.2 KiB
Rust
//! URL path constants and builders.
|
|
//!
|
|
//! Centralising these catches routing refactors at compile time (a
|
|
//! rename to the constant/fn shows up in every test file in one
|
|
//! `cargo check`) rather than as a scatter of 404s.
|
|
//!
|
|
//! The public `/api/*` surface lives in `doctate_common` and is
|
|
//! re-exported from there (see `ONELINERS_PATH`, `UPLOAD_PATH`).
|
|
|
|
pub use doctate_common::{ONELINERS_PATH, UPLOAD_PATH};
|
|
|
|
// -- /web/* --
|
|
|
|
/// `POST /web/login` — form login (slug, password).
|
|
pub const LOGIN: &str = "/web/login";
|
|
/// `POST /web/logout` — CSRF-protected logout.
|
|
pub const LOGOUT: &str = "/web/logout";
|
|
/// `GET /web/cases` — case list; also triggers the lazy retention sweep.
|
|
pub const CASES: &str = "/web/cases";
|
|
/// `POST /web/cases/bulk` — admin bulk action (close/analyze/reset).
|
|
pub const BULK: &str = "/web/cases/bulk";
|
|
/// `POST /web/cases/purge-closed` — admin hard-delete of closed cases.
|
|
pub const PURGE_CLOSED: &str = "/web/cases/purge-closed";
|
|
/// `GET /web/events` — SSE stream (per-user scoped).
|
|
pub const EVENTS: &str = "/web/events";
|
|
|
|
// -- per-case builders --
|
|
|
|
/// `/web/cases/{case_id}`.
|
|
pub fn case_detail(case_id: &str) -> String {
|
|
format!("/web/cases/{case_id}")
|
|
}
|
|
|
|
/// `/web/cases/{case_id}/recordings`.
|
|
pub fn case_recordings(case_id: &str) -> String {
|
|
format!("/web/cases/{case_id}/recordings")
|
|
}
|
|
|
|
/// `POST /web/cases/{case_id}/close`.
|
|
pub fn case_close(case_id: &str) -> String {
|
|
format!("/web/cases/{case_id}/close")
|
|
}
|
|
|
|
/// `POST /web/cases/{case_id}/reopen`.
|
|
pub fn case_reopen(case_id: &str) -> String {
|
|
format!("/web/cases/{case_id}/reopen")
|
|
}
|
|
|
|
/// `POST /web/cases/{case_id}/analyze`.
|
|
pub fn case_analyze(case_id: &str) -> String {
|
|
format!("/web/cases/{case_id}/analyze")
|
|
}
|
|
|
|
/// `POST /web/cases/{case_id}/reset` — admin-only hard-reset.
|
|
pub fn case_reset(case_id: &str) -> String {
|
|
format!("/web/cases/{case_id}/reset")
|
|
}
|
|
|
|
/// `POST /web/cases/{case_id}/recordings/delete` — per-recording delete.
|
|
pub fn recording_delete(case_id: &str) -> String {
|
|
format!("/web/cases/{case_id}/recordings/delete")
|
|
}
|
|
|
|
/// `GET /web/magic?token={token}` — magic-link consumption.
|
|
pub fn magic(token: &str) -> String {
|
|
format!("/web/magic?token={token}")
|
|
}
|