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.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
test(server): all instance variants (#7882)
forehaloe53dde79445c
diff --git a/packages/backend/server/src/app.controller.ts b/packages/backend/server/src/app.controller.tsindex f98b3a6a9a..a0964b4fae 100644--- a/packages/backend/server/src/app.controller.ts+++ b/packages/backend/server/src/app.controller.ts@@ -15,7 +15,7 @@ export class AppController {compatibility: this.config.version,message: `AFFiNE ${this.config.version} Server`,type: this.config.type,- flavor: this.config.flavor,+ flavor: this.config.flavor.type,};}}diff --git a/packages/backend/server/tests/app.e2e.ts b/packages/backend/server/tests/app/graphql.e2e.tssimilarity index 59%rename from packages/backend/server/tests/app.e2e.tsrename to packages/backend/server/tests/app/graphql.e2e.tsindex 1973e11d6a..e4f4bcbab8 100644--- a/packages/backend/server/tests/app.e2e.ts+++ b/packages/backend/server/tests/app/graphql.e2e.ts@@ -3,8 +3,8 @@ import type { TestFn } from 'ava';import ava from 'ava';import request from 'supertest';-import { AppModule } from '../src/app.module';-import { createTestingApp } from './utils';+import { buildAppModule } from '../../src/app.module';+import { createTestingApp } from '../utils';const gql = '/graphql';@@ -12,15 +12,17 @@ const test = ava as TestFn<{app: INestApplication;}>;-test.beforeEach(async t => {+test.before('start app', async t => {+ // @ts-expect-error override+ AFFiNE.flavor = { type: 'graphql', graphql: true, sync: false };const { app } = await createTestingApp({- imports: [AppModule],+ imports: [buildAppModule()],});t.context.app = app;});-test.afterEach.always(async t => {+test.after.always(async t => {await t.context.app.close();});@@ -55,3 +57,17 @@ test('should init app', async t => {t.is(config.type, 'Affine');t.true(Array.isArray(config.features));});++test('should return 404 for unknown path', async t => {+ await request(t.context.app.getHttpServer()).get('/unknown').expect(404);++ t.pass();+});++test('should be able to call apis', async t => {+ const res = await request(t.context.app.getHttpServer())+ .get('/info')+ .expect(200);++ t.is(res.body.flavor, 'graphql');+});diff --git a/packages/backend/server/tests/selfhost/app.e2e.ts b/packages/backend/server/tests/app/selfhost.e2e.tssimilarity index 97%rename from packages/backend/server/tests/selfhost/app.e2e.tsrename to packages/backend/server/tests/app/selfhost.e2e.tsindex ad47be64b6..935066d8d1 100644--- a/packages/backend/server/tests/selfhost/app.e2e.ts+++ b/packages/backend/server/tests/app/selfhost.e2e.ts@@ -101,9 +101,11 @@ test('should always return static asset files', async t => {});test('should be able to call apis', async t => {- await request(t.context.app.getHttpServer()).get('/info').expect(200);+ const res = await request(t.context.app.getHttpServer())+ .get('/info')+ .expect(200);- t.pass();+ t.is(res.body.flavor, 'allinone');});const blockedPages = [diff --git a/packages/backend/server/tests/app/sync.e2e.ts b/packages/backend/server/tests/app/sync.e2e.tsnew file mode 100644index 0000000000..1391a6761e--- /dev/null+++ b/packages/backend/server/tests/app/sync.e2e.ts@@ -0,0 +1,33 @@+import type { INestApplication } from '@nestjs/common';+import type { TestFn } from 'ava';+import ava from 'ava';+import request from 'supertest';++import { buildAppModule } from '../../src/app.module';+import { createTestingApp } from '../utils';++const test = ava as TestFn<{+ app: INestApplication;+}>;++test.before('start app', async t => {+ // @ts-expect-error override+ AFFiNE.flavor = { type: 'sync', graphql: false, sync: true };+ const { app } = await createTestingApp({+ imports: [buildAppModule()],+ });++ t.context.app = app;+});++test.after.always(async t => {+ await t.context.app.close();+});++test('should init app', async t => {+ const res = await request(t.context.app.getHttpServer())+ .get('/info')+ .expect(200);++ t.is(res.body.flavor, 'sync');+});diff --git a/packages/backend/server/tests/sync.spec.ts b/packages/backend/server/tests/sync.spec.tsdeleted file mode 100644index d384199c88..0000000000--- a/packages/backend/server/tests/sync.spec.ts+++ /dev/null@@ -1,16 +0,0 @@-import { Test } from '@nestjs/testing';-import test from 'ava';--test('should be able to bootstrap sync server', async t => {- // set env before import- process.env.SERVER_FLAVOR = 'sync';- const { AppModule } = await import('../src/app.module');- await t.notThrowsAsync(async () => {- const module = await Test.createTestingModule({- imports: [AppModule],- }).compile();- const app = module.createNestApplication();- await app.close();- });- process.env.SERVER_FLAVOR = '';-});