a3b55d0a1b
Check Deno code / Check Deno code (pull_request) Successful in 6s
Tests / Unit tests (pull_request) Successful in 11s
Tests / Integration tests (pull_request) Successful in 1m19s
Check Deno code / Check Deno code (push) Successful in 6s
Tests / Unit tests (push) Successful in 11s
Tests / Integration tests (push) Successful in 1m7s
43 lines
1.3 KiB
TypeScript
43 lines
1.3 KiB
TypeScript
// #115 - E2E tests for GET /permissions
|
|
// Handler statique (pas de DB), test direct du handler
|
|
|
|
import { assertEquals, assertExists } from "@std/assert";
|
|
import { makeEmployeeContext, makeGetRequest } from "../helpers/handler.ts";
|
|
import { handler as permissionsHandler } from "$apps/admin/api/permissions.ts";
|
|
|
|
Deno.test({
|
|
name: "e2e permissions: GET /permissions returns all 9 permissions",
|
|
fn() {
|
|
const res = permissionsHandler.GET!(
|
|
makeGetRequest("/permissions"),
|
|
makeEmployeeContext(),
|
|
);
|
|
assertEquals(res.status, 200);
|
|
return res.text().then((text) => {
|
|
const data = JSON.parse(text);
|
|
assertEquals(data.length, 9);
|
|
assertExists(data.find((p: { id: string }) => p.id === "student_read"));
|
|
assertExists(data.find((p: { id: string }) => p.id === "role_write"));
|
|
});
|
|
},
|
|
sanitizeResources: false,
|
|
sanitizeOps: false,
|
|
});
|
|
|
|
Deno.test({
|
|
name: "e2e permissions: GET /permissions - all entries have id and nom",
|
|
async fn() {
|
|
const res = permissionsHandler.GET!(
|
|
makeGetRequest("/permissions"),
|
|
makeEmployeeContext(),
|
|
);
|
|
const data: { id: string; nom: string }[] = await res.json();
|
|
for (const p of data) {
|
|
assertEquals(typeof p.id, "string");
|
|
assertEquals(typeof p.nom, "string");
|
|
}
|
|
},
|
|
sanitizeResources: false,
|
|
sanitizeOps: false,
|
|
});
|