mirror of
https://github.com/Unleash/unleash.git
synced 2024-11-01 19:07:38 +01:00
4dec126199
* Feat: add initial event schema * Feat: add events-schema plus tests * Feat(broken): add openapi validation to getEvents endpoint * Add schema to basic events endpoint * Feat: Add openapi for feature events * Fix: fix recursive schema inclusion * Feat: add test for recursive function * Fix: make nullable fields nullable * Fix: remove `ADMIN` permission for toggle events. * fix: add new schemas to the snapshot * Fix: remove recursive schema inclusion * Feat: test feature events schema * Fix: add correct permissions for feature events endpoint. * Refactor: rename "name" to "featureName" for clearer docs * Fix: Add missing "version" field to feature events * Feat: add descriptions and extra responses to events endpoints. * Fix: update openapi snapshot * Simplify standard responses function * Refactor: move endpoint descriptions into own file. * Refactor: simplify type signature. * Feat: specify type of data and preData properties to object * Fix: update snapshot * Refactor: move standard-responses into /util/ directory.
77 lines
2.4 KiB
TypeScript
77 lines
2.4 KiB
TypeScript
import { validateSchema } from '../validate';
|
|
import {
|
|
FeatureEventsSchema,
|
|
featureEventsSchema,
|
|
} from './feature-events-schema';
|
|
|
|
test('featureEventsSchema', () => {
|
|
const data: FeatureEventsSchema = {
|
|
toggleName: 'my-feature',
|
|
events: [
|
|
{
|
|
id: 899,
|
|
type: 'feature-created',
|
|
createdBy: 'user@company.com',
|
|
createdAt: '2022-05-31T13:32:20.560Z',
|
|
data: {
|
|
name: 'new-feature',
|
|
description: 'Toggle description',
|
|
type: 'release',
|
|
project: 'my-project',
|
|
stale: false,
|
|
variants: [],
|
|
createdAt: '2022-05-31T13:32:20.547Z',
|
|
lastSeenAt: null,
|
|
impressionData: true,
|
|
},
|
|
preData: null,
|
|
tags: [],
|
|
featureName: 'new-feature',
|
|
project: 'my-project',
|
|
environment: null,
|
|
},
|
|
],
|
|
};
|
|
|
|
expect(validateSchema(featureEventsSchema.$id, data)).toBeUndefined();
|
|
});
|
|
|
|
test('featureEventsSchema types', () => {
|
|
const data: FeatureEventsSchema = {
|
|
toggleName: 'my-feature',
|
|
events: [
|
|
{
|
|
// @ts-expect-error
|
|
id: '1',
|
|
type: 'feature-created',
|
|
createdBy: 'user@company.com',
|
|
createdAt: '2022-05-31T13:32:20.560Z',
|
|
data: {
|
|
name: 'new-feature',
|
|
description: 'Toggle description',
|
|
type: 'release',
|
|
project: 'my-project',
|
|
stale: false,
|
|
variants: [],
|
|
createdAt: '2022-05-31T13:32:20.547Z',
|
|
lastSeenAt: null,
|
|
impressionData: true,
|
|
},
|
|
preData: null,
|
|
tags: [
|
|
{
|
|
type: '',
|
|
// @ts-expect-error
|
|
value: 1,
|
|
},
|
|
],
|
|
featureName: 'new-feature',
|
|
project: 'my-project',
|
|
environment: null,
|
|
},
|
|
],
|
|
};
|
|
|
|
expect(validateSchema(featureEventsSchema.$id, data)).not.toBeUndefined();
|
|
});
|