1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-06 00:07:44 +01:00
unleash.unleash/src/test/e2e/api/admin/project/projects.e2e.test.ts
Ivar Conradi Østhus 1bc130b7f0
fix: add createdAt in projects API response (#3929)
This PR adds the "createdAt" field to the /api/projects response, so
that we are compliant with the schema.
2023-06-09 14:18:38 +00:00

61 lines
1.6 KiB
TypeScript

import dbInit from '../../../helpers/database-init';
import { setupAppWithCustomConfig } from '../../../helpers/test-helper';
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);
app = await setupAppWithCustomConfig(db.stores, {
experimental: {
flags: {
strictSchemaValidation: true,
},
},
});
projectStore = db.stores.projectStore;
});
afterAll(async () => {
await app.destroy();
await db.destroy();
});
test('Should ONLY return default project', async () => {
projectStore.create({
id: 'test2',
name: 'test',
description: '',
mode: 'open',
defaultStickiness: 'default',
});
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');
});
test('response should include created_at', async () => {
const { body } = await app.request
.get('/api/admin/projects')
.expect('Content-Type', /json/)
.expect(200);
expect(body.projects[0].createdAt).toBeDefined();
});
test('response for default project should include created_at', async () => {
const { body } = await app.request
.get('/api/admin/projects/default')
.expect('Content-Type', /json/)
.expect(200);
expect(body.createdAt).toBeDefined();
});