aboutsummaryrefslogtreecommitdiffstats
path: root/packages/e2e_tests/setup/seed.ts
blob: 9ab68499af59481041ec13a0bf46943b27997ae4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { GlobalSetupContext } from "vitest/node";

import { getTrpcClient } from "../utils/trpc";

export async function setup({ provide }: GlobalSetupContext) {
  const trpc = getTrpcClient();
  await trpc.users.create.mutate({
    name: "Test User",
    email: "admin@example.com",
    password: "test1234",
    confirmPassword: "test1234",
  });

  const { key } = await trpc.apiKeys.exchange.mutate({
    email: "admin@example.com",
    password: "test1234",
    keyName: "test-key",
  });
  provide("adminApiKey", key);
  return () => ({});
}

declare module "vitest" {
  export interface ProvidedContext {
    adminApiKey: string;
  }
}