Skip to content

Open-source status page, incident response and uptime monitoring

871 B
Raw Blame
import { z } from "@hono/zod-openapi";
import { expect, test } from "vitest";

import { app } from "@/index";

import { SummarySchema } from "./schema";

test.skip("return the summary of the monitor", async () => {
  const res = await app.request("/v1/monitor/1/summary", {
    headers: {
      "x-openstatus-key": "1",
    },
  });

  const result = z
    .object({ data: SummarySchema.array() })
    .safeParse(await res.json());

  expect(res.status).toBe(200);
  expect(result.success).toBe(true);
});

test("no auth key should return 401", async () => {
  const res = await app.request("/v1/monitor/1/summary");

  expect(res.status).toBe(401);
});

test("invalid monitor id should return 404", async () => {
  const res = await app.request("/v1/monitor/404/summary", {
    headers: {
      "x-openstatus-key": "2",
    },
  });

  expect(res.status).toBe(404);
});