import { urlString } from "@hexclave/shared/dist/utils/urls"; import { it } from "../../../../helpers"; import { Auth, Project, ProjectApiKey, Team, backendContext, bumpEmailAddress, niceBackendFetch } from "../../../backend-helpers"; async function createAndSwitchToAPIEnabledProject(allow_team_api_keys = true, allow_user_api_keys = true) { await Project.createAndSwitch({ config: { magic_link_enabled: true, allow_team_api_keys, allow_user_api_keys } }); } it("throws an error when user API keys are disabled and trying to use user API keys", async ({ expect }: { expect: any }) => { // Create a project with user API keys disabled await createAndSwitchToAPIEnabledProject(true, false); await Auth.fastSignUp(); // Try to create a user API key const createResponse = await niceBackendFetch("/api/v1/user-api-keys", { method: "POST", accessType: "client", body: { user_id: "me", description: "This should fail", expires_at_millis: null, }, }); expect(createResponse).toMatchInlineSnapshot(` NiceResponse { "status": 400, "body": "User API keys are not enabled for this project.", "headers": Headers {