Skip to content

Fix eratic test for POST /api/pleroma/admin/reports/:id/notes

Ilja requested to merge ilja/pleroma:fix_eratic_test_for_report_notes into develop

I noticed this one while working on !3652 (closed)

There an eratic test. It retrieves two ReportNotes and then checkes one of them. But the order isn't guaranteed, while the test tested on the content of the first ReportNote.

I made the test on the content more generic.


This is the query I logged from when I fetch reports on that endpoint. AFAICT it orders on activity, which I assume are the reports. But it doesn't order on the report_notes.

SELECT a0."id", a0."data", a0."local", a0."actor", a0."recipients", a0."inserted_at", a0."updated_at", r1."id", r1."content", r1."user_id", r1."activity_id", r1."inserted_at", r1."updated_at" FROM "activities" AS a0 LEFT OUTER JOIN "report_notes" AS r1 ON a0."id" = r1."activity_id" WHERE (a0."data"->>'type' = $1) AND (a0."data"->>'state' = $2) AND (NOT (a0."actor" IN (SELECT su0."ap_id" FROM "users" AS su0 WHERE (su0."is_active" = FALSE) AND (NOT (su0."nickname" IS NULL)) AND (NOT (su0."nickname" LIKE 'internal.%'))))) AND (NOT (a0."actor" = ANY($3))) ORDER BY a0."id" desc nulls last LIMIT $4 OFFSET $5

I fetch with

curl 'http://localhost:4000/api/pleroma/admin/reports?state=open&page=1&page_size=50' -H 'Accept: application/json, text/plain, */*' -H 'Authorization: Bearer <bearer-token>'

To log the sql statement I added log_statement = 'all' to /etc/postgresql/11/main/postgresql.conf and did systemctl reload postgresql. Then i follow what happens with tail -f /var/log/postgresql/postgresql-11-main.log.

Edited by Ilja

Merge request reports