test(files): pin move contract for drag-and-drop

This commit is contained in:
lgcosta committed 2026-11-07 19:13:44 -03:00
1 parent f6a74e1092
commit db14f75389
1 file changed
+12
+12
View File
@@ -187,6 +187,11 @@ func TestFilesAPI(t *testing.T) {
if mvd["folder"] != subID || mvd["note"] != note["id"].(string) || mvd["name"] != "guia-v2.md" {
t.Errorf("move result: %+v", mvd)
}
// arrastar-e-soltar depende do id estável: a referência na nota aponta
// para /api/files/static/{id} e não pode quebrar ao mover de pasta.
if mvd["id"] != mdID {
t.Errorf("move deveria preservar o id do arquivo: %+v", mvd)
}
// nota fantasma na associação → 400
bad := auth(t, srv, "PUT", "/api/files/"+mdID+"/move", `{"note":"naoexiste1"}`)
@@ -195,6 +200,13 @@ func TestFilesAPI(t *testing.T) {
}
bad.Body.Close()
// pasta fantasma no move → 400
badFolder := auth(t, srv, "PUT", "/api/files/"+mdID+"/move", `{"folder":"naoexiste1"}`)
if badFolder.StatusCode != http.StatusBadRequest {
t.Errorf("pasta fantasma no move: %s", badFolder.Status)
}
badFolder.Body.Close()
// excluir pasta raiz remove subtree e arquivos (png + md movido)
del := auth(t, srv, "DELETE", "/api/folders/"+fid, "")
if del.StatusCode != http.StatusNoContent {