mirror of
https://github.com/jjbrunton/Sauci.git
synced 2026-11-01 18:19:43 +00:00
feat(admin): preview response media
Show who-likely choices in human terms and provide protected photo and audio previews in activity and user response views. Fetch media by response ID through an authenticated Edge Function that enforces the view_responses permission.
This commit is contained in:
1 parent
7545289dd3
commit
650c81856f
8 files changed
+385
-3
No files matched your search
@@ -0,0 +1,30 @@
|
||||
import { assertEquals } from "std/assert/mod.ts";
|
||||
import {
|
||||
canViewResponseMedia,
|
||||
getResponseMediaDescriptor,
|
||||
} from "../functions/admin-response-media/helpers.ts";
|
||||
|
||||
Deno.test("response media access requires the response permission", () => {
|
||||
assertEquals(canViewResponseMedia("super_admin", null), true);
|
||||
assertEquals(canViewResponseMedia("pack_creator", ["view_responses"]), true);
|
||||
assertEquals(canViewResponseMedia("pack_creator", ["view_activity"]), false);
|
||||
});
|
||||
|
||||
Deno.test("response media is derived from the stored response payload", () => {
|
||||
assertEquals(
|
||||
getResponseMediaDescriptor({
|
||||
type: "photo",
|
||||
media_path:
|
||||
"https://example.supabase.co/storage/v1/object/sign/response-media/user/question.jpg?token=secret",
|
||||
}),
|
||||
{ type: "photo", path: "user/question.jpg" },
|
||||
);
|
||||
assertEquals(
|
||||
getResponseMediaDescriptor({ type: "text_answer", text: "hello" }),
|
||||
null,
|
||||
);
|
||||
assertEquals(
|
||||
getResponseMediaDescriptor({ type: "audio", media_path: "" }),
|
||||
null,
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user