stack/apps/e2e/tests/backend/endpoints/api/v1/projects.test.ts
Konsti Wohlwend b0f233a44c
More backend endpoint implementations (#126)
Co-authored-by: Zai Shi <fomalhautb@users.noreply.github.com>
2024-07-13 22:04:53 -07:00

66 lines
1.9 KiB
TypeScript

import { describe } from "vitest";
import { it } from "../../../../helpers";
import { InternalProjectKeys, backendContext, niceBackendFetch } from "../../../backend-helpers";
describe("without project access", () => {
backendContext.set({
projectKeys: 'no-project'
});
it("should not have have access to the project", async ({ expect }) => {
const response = await niceBackendFetch("/api/v1/projects/current", { accessType: "client" });
expect(response).toMatchInlineSnapshot(`
NiceResponse {
"status": 400,
"body": {
"code": "REQUEST_TYPE_WITHOUT_PROJECT_ID",
"details": { "request_type": "client" },
"error": "The x-stack-request-type header was 'client', but the x-stack-project-id header was not provided.",
},
"headers": Headers {
"x-stack-known-error": "REQUEST_TYPE_WITHOUT_PROJECT_ID",
<some fields may have been hidden>,
},
}
`);
});
});
describe("with internal project keys", () => {
backendContext.set({
projectKeys: InternalProjectKeys,
});
it("Get project", async ({ expect }) => {
const response = await niceBackendFetch("/api/v1/projects/current", { accessType: "client" });
expect(response).toMatchInlineSnapshot(`
NiceResponse {
"status": 200,
"body": {
"config": {
"credential_enabled": true,
"magic_link_enabled": true,
"oauth_providers": [
{ "id": "facebook" },
{ "id": "github" },
{ "id": "google" },
{ "id": "microsoft" },
],
},
"display_name": "Stack Dashboard",
"id": "internal",
},
"headers": Headers { <some fields may have been hidden> },
}
`);
});
});
describe("with new project keys", () => {
backendContext.set({
projectKeys: 'no-project'
});
it.todo("Get project");
});