Permet de copier une journée vers un autre jour
Bouton copier sur l'en-tête de chaque jour : les entrées affichées sont
recopiées à la date choisie avec les mêmes heures, projet et note
(POST /ui/jours/{date}/dupliquer, tout ou rien). L'entrée en cours est
ignorée ; projet archivé ou même jour refusés.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3164fa8048
commit
e6a1dd7e4b
7 files changed
+204
-2
No files matched your search
@@ -845,3 +845,87 @@ async fn restart_entry_from_list() {
|
||||
.count();
|
||||
assert_eq!(open, 1);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn duplicate_day() {
|
||||
let app = app().await;
|
||||
let a = project(&app, "Acme", "Site web").await;
|
||||
let b = project(&app, "Globex", "API").await;
|
||||
add_entry(
|
||||
&app,
|
||||
a,
|
||||
local(2026, 3, 10, 9, 0),
|
||||
local(2026, 3, 10, 10, 15),
|
||||
)
|
||||
.await; // 1
|
||||
add_entry(
|
||||
&app,
|
||||
b,
|
||||
local(2026, 3, 10, 14, 0),
|
||||
local(2026, 3, 10, 16, 0),
|
||||
)
|
||||
.await; // 2
|
||||
|
||||
// The day header carries the listed ids and posts to the copy route.
|
||||
let (_, html) = get_html(&app, "/entries?from=2026-03-10&to=2026-03-10").await;
|
||||
assert!(html.contains("hx-post=\"/ui/jours/2026-03-10/dupliquer\""));
|
||||
// The self-refreshing list must not pass hx-select & co. down to row buttons
|
||||
// (inline edit would swap in an empty row).
|
||||
assert!(html.contains("id=\"entries-list\" hx-disinherit=\"*\""));
|
||||
assert!(html.contains("name=\"ids\" value=\"2,1\""));
|
||||
|
||||
let (status, _) = send_form(
|
||||
&app,
|
||||
"/ui/jours/2026-03-10/dupliquer",
|
||||
"ids=2,1&vers=2026-03-12",
|
||||
)
|
||||
.await;
|
||||
assert_eq!(status, StatusCode::OK);
|
||||
let (_, list) = send(
|
||||
&app,
|
||||
"GET",
|
||||
"/api/entries?from=2026-03-12&to=2026-03-12",
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
let list = list.as_array().unwrap();
|
||||
assert_eq!(list.len(), 2);
|
||||
assert_eq!(list[0]["project_id"], b);
|
||||
let parse = |v: &Value| chrono::DateTime::parse_from_rfc3339(v.as_str().unwrap()).unwrap();
|
||||
assert_eq!(
|
||||
parse(&list[1]["started_at"]),
|
||||
parse(&json!(local(2026, 3, 12, 9, 0)))
|
||||
);
|
||||
assert_eq!(list[1]["seconds"], 4500);
|
||||
|
||||
// Same day, or an archived project: refused, nothing copied.
|
||||
let (status, _) = send_form(
|
||||
&app,
|
||||
"/ui/jours/2026-03-10/dupliquer",
|
||||
"ids=1&vers=2026-03-10",
|
||||
)
|
||||
.await;
|
||||
assert_eq!(status, StatusCode::UNPROCESSABLE_ENTITY);
|
||||
send(
|
||||
&app,
|
||||
"PATCH",
|
||||
&format!("/api/projects/{b}"),
|
||||
Some(json!({ "archived": true })),
|
||||
)
|
||||
.await;
|
||||
let (status, _) = send_form(
|
||||
&app,
|
||||
"/ui/jours/2026-03-10/dupliquer",
|
||||
"ids=2,1&vers=2026-03-13",
|
||||
)
|
||||
.await;
|
||||
assert_eq!(status, StatusCode::UNPROCESSABLE_ENTITY);
|
||||
let (_, list) = send(
|
||||
&app,
|
||||
"GET",
|
||||
"/api/entries?from=2026-03-13&to=2026-03-13",
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
assert!(list.as_array().unwrap().is_empty());
|
||||
}
|
||||
Reference in new issue
Block a user