mirror of
https://github.com/Unleash/unleash.git
synced 2025-06-18 01:18:23 +02:00
During adding privateProjectsChecker, I saw that events composition root is not used almost at all. Refactored code so we do not call new EventService anymore.
52 lines
1.3 KiB
TypeScript
52 lines
1.3 KiB
TypeScript
import { setupAppWithAuth } from '../../helpers/test-helper';
|
|
import dbInit, { type ITestDb } from '../../helpers/database-init';
|
|
import getLogger from '../../../fixtures/no-logger';
|
|
|
|
let db: ITestDb;
|
|
|
|
beforeAll(async () => {
|
|
db = await dbInit('feature_api_auth', getLogger);
|
|
});
|
|
|
|
afterAll(async () => {
|
|
await db.destroy();
|
|
});
|
|
|
|
test('creates new feature flag with createdBy', async () => {
|
|
expect.assertions(1);
|
|
|
|
const { request, destroy } = await setupAppWithAuth(
|
|
db.stores,
|
|
{},
|
|
db.rawDatabase,
|
|
);
|
|
|
|
// Login
|
|
await request.post('/auth/demo/login').send({
|
|
email: 'user@mail.com',
|
|
});
|
|
|
|
// create flag
|
|
await request
|
|
.post('/api/admin/projects/default/features')
|
|
.send({
|
|
name: 'com.test.Username',
|
|
enabled: false,
|
|
strategies: [{ name: 'default' }],
|
|
})
|
|
.expect(201);
|
|
|
|
await request.get('/api/admin/events/com.test.Username').expect((res) => {
|
|
expect(res.body.events[0].createdBy).toBe('user@mail.com');
|
|
});
|
|
|
|
await destroy();
|
|
});
|
|
|
|
test('should require authenticated user', async () => {
|
|
expect.assertions(0);
|
|
const { request, destroy } = await setupAppWithAuth(db.stores);
|
|
await request.get('/api/admin/projects/default/features').expect(401);
|
|
await destroy();
|
|
});
|