Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

test: health check (#1743)

Himself6568144fb2dc52
diff --git a/packages/workspace/src/affine/__tests__/api.spec.ts b/packages/workspace/src/affine/__tests__/api.spec.ts
index 55ffc1a2bb..9b8d38f559 100644
--- a/packages/workspace/src/affine/__tests__/api.spec.ts
+++ b/packages/workspace/src/affine/__tests__/api.spec.ts
@@ -6,6 +6,7 @@ import 'fake-indexeddb/auto';
import { readFile } from 'node:fs/promises';
import { MessageCode } from '@affine/env/constant';
+import { createStatusApis } from '@affine/workspace/affine/api/status';
import { assertExists } from '@blocksuite/global/utils';
import { Workspace } from '@blocksuite/store';
import { faker } from '@faker-js/faker';
@@ -25,6 +26,7 @@ import {
let workspaceApis: ReturnType<typeof createWorkspaceApis>;
let affineAuth: ReturnType<typeof createAffineAuth>;
+let statusApis: ReturnType<typeof createStatusApis>;
const mockUser = {
name: faker.name.fullName(),
@@ -42,6 +44,11 @@ beforeEach(() => {
beforeEach(() => {
affineAuth = createAffineAuth('http://localhost:3000/');
workspaceApis = createWorkspaceApis('http://localhost:3000/');
+ statusApis = createStatusApis('http://localhost:3000/');
+});
+
+beforeEach(async () => {
+ expect(await statusApis.healthz(), 'health check').toBe(true);
});
beforeEach(async () => {
diff --git a/packages/workspace/src/affine/api/status.ts b/packages/workspace/src/affine/api/status.ts
new file mode 100644
index 0000000000..fc0cbbe765
--- /dev/null
+++ b/packages/workspace/src/affine/api/status.ts
@@ -0,0 +1,7 @@
+export function createStatusApis(prefixUrl = '/') {
+ return {
+ healthz: async (): Promise<boolean> => {
+ return fetch(`${prefixUrl}api/healthz`).then(r => r.status === 204);
+ },
+ } as const;
+}