2021-10-01 10:59:43 +02:00
|
|
|
import dbInit from '../../../helpers/database-init';
|
2023-02-10 15:05:57 +01:00
|
|
|
import { setupAppWithCustomConfig } from '../../../helpers/test-helper';
|
2021-10-01 10:59:43 +02:00
|
|
|
import getLogger from '../../../../fixtures/no-logger';
|
|
|
|
import ProjectStore from '../../../../../lib/db/project-store';
|
|
|
|
|
|
|
|
let app;
|
|
|
|
let db;
|
|
|
|
|
|
|
|
let projectStore: ProjectStore;
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
|
|
|
db = await dbInit('projects_api_serial', getLogger);
|
2023-02-10 15:05:57 +01:00
|
|
|
app = await setupAppWithCustomConfig(db.stores, {
|
|
|
|
experimental: {
|
|
|
|
flags: {
|
|
|
|
strictSchemaValidation: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
2021-10-01 10:59:43 +02:00
|
|
|
projectStore = db.stores.projectStore;
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
await app.destroy();
|
|
|
|
await db.destroy();
|
|
|
|
});
|
|
|
|
|
|
|
|
test('Should ONLY return default project', async () => {
|
2023-03-16 15:29:52 +01:00
|
|
|
projectStore.create({
|
|
|
|
id: 'test2',
|
|
|
|
name: 'test',
|
|
|
|
description: '',
|
|
|
|
mode: 'open',
|
|
|
|
});
|
2021-10-01 10:59:43 +02:00
|
|
|
|
|
|
|
const { body } = await app.request
|
|
|
|
.get('/api/admin/projects')
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
|
|
|
|
|
|
|
expect(body.projects).toHaveLength(1);
|
|
|
|
expect(body.projects[0].id).toBe('default');
|
|
|
|
});
|
2023-03-13 13:22:47 +01:00
|
|
|
|
|
|
|
test('Should store and retrieve default project stickiness', async () => {
|
|
|
|
const appWithDefaultStickiness = await setupAppWithCustomConfig(db.stores, {
|
|
|
|
experimental: {
|
|
|
|
flags: {
|
|
|
|
projectScopedStickiness: true,
|
|
|
|
strictSchemaValidation: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
2023-03-15 15:06:25 +01:00
|
|
|
const reqBody = { defaultStickiness: 'userId' };
|
2023-03-13 13:22:47 +01:00
|
|
|
|
|
|
|
await appWithDefaultStickiness.request
|
2023-03-15 15:06:25 +01:00
|
|
|
.post('/api/admin/projects/default/settings')
|
2023-03-13 13:22:47 +01:00
|
|
|
.send(reqBody)
|
|
|
|
.expect(200);
|
|
|
|
|
|
|
|
const { body } = await appWithDefaultStickiness.request
|
2023-03-15 15:06:25 +01:00
|
|
|
.get('/api/admin/projects/default/settings')
|
2023-03-13 13:22:47 +01:00
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
|
|
|
|
|
|
|
expect(body).toStrictEqual(reqBody);
|
|
|
|
});
|