1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-05-12 01:17:04 +02:00

fix: enabling more tests with strict schema validation (#3081)

This commit is contained in:
Mateusz Kwasniewski 2023-02-14 11:25:13 +01:00 committed by GitHub
parent c78b2d8325
commit c14621a09a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 101 additions and 14 deletions

View File

@ -16,6 +16,10 @@ export const featureEventsSchema = {
type: 'array',
items: { $ref: eventSchema.$id },
},
totalEvents: {
type: 'integer',
minimum: 0,
},
},
components: {
schemas: {

View File

@ -97,6 +97,13 @@ export const featureSchema = {
},
description: 'The list of feature variants',
},
strategies: {
type: 'array',
items: {
type: 'object',
},
description: 'This is a legacy field that will be deprecated',
},
tags: {
type: 'array',
items: {

View File

@ -23,6 +23,7 @@ export const healthOverviewSchema = {
},
description: {
type: 'string',
nullable: true,
},
members: {
type: 'number',
@ -50,6 +51,10 @@ export const healthOverviewSchema = {
favorite: {
type: 'boolean',
},
stats: {
$ref: '#/components/schemas/projectStatsSchema',
description: 'Project statistics',
},
},
components: {
schemas: {

View File

@ -1,6 +1,6 @@
import dbInit from '../../helpers/database-init';
import getLogger from '../../../fixtures/no-logger';
import { setupApp } from '../../helpers/test-helper';
import { setupAppWithCustomConfig } from '../../helpers/test-helper';
let app;
let db;
@ -9,7 +9,13 @@ const PATH = '/api/admin/constraints/validate';
beforeAll(async () => {
db = await dbInit('constraints', getLogger);
app = await setupApp(db.stores);
app = await setupAppWithCustomConfig(db.stores, {
experimental: {
flags: {
strictSchemaValidation: true,
},
},
});
});
afterAll(async () => {

View File

@ -1,6 +1,9 @@
import dbInit, { ITestDb } from '../../helpers/database-init';
import getLogger from '../../../fixtures/no-logger';
import { IUnleashTest, setupApp } from '../../helpers/test-helper';
import {
IUnleashTest,
setupAppWithCustomConfig,
} from '../../helpers/test-helper';
import { DEFAULT_ENV } from '../../../../lib/util/constants';
let app: IUnleashTest;
@ -8,7 +11,13 @@ let db: ITestDb;
beforeAll(async () => {
db = await dbInit('environment_api_serial', getLogger);
app = await setupApp(db.stores);
app = await setupAppWithCustomConfig(db.stores, {
experimental: {
flags: {
strictSchemaValidation: true,
},
},
});
});
afterAll(async () => {

View File

@ -1,4 +1,7 @@
import { IUnleashTest, setupApp } from '../../helpers/test-helper';
import {
IUnleashTest,
setupAppWithCustomConfig,
} from '../../helpers/test-helper';
import dbInit, { ITestDb } from '../../helpers/database-init';
import getLogger from '../../../fixtures/no-logger';
import { FEATURE_CREATED, IBaseEvent } from '../../../../lib/types/events';
@ -11,7 +14,13 @@ let eventStore: IEventStore;
beforeAll(async () => {
db = await dbInit('event_api_serial', getLogger);
app = await setupApp(db.stores);
app = await setupAppWithCustomConfig(db.stores, {
experimental: {
flags: {
strictSchemaValidation: true,
},
},
});
eventStore = db.stores.eventStore;
});

View File

@ -1,7 +1,6 @@
import dbInit, { ITestDb } from '../../helpers/database-init';
import {
IUnleashTest,
setupApp,
setupAppWithCustomConfig,
} from '../../helpers/test-helper';
import getLogger from '../../../fixtures/no-logger';
@ -24,7 +23,13 @@ const defaultStrategy = {
beforeAll(async () => {
db = await dbInit('feature_api_serial', getLogger);
app = await setupApp(db.stores);
app = await setupAppWithCustomConfig(db.stores, {
experimental: {
flags: {
strictSchemaValidation: true,
},
},
});
const createToggle = async (
toggle: FeatureToggleDTO,

View File

@ -1,5 +1,5 @@
import dbInit from '../../../helpers/database-init';
import { setupApp } from '../../../helpers/test-helper';
import { setupAppWithCustomConfig } from '../../../helpers/test-helper';
import getLogger from '../../../../fixtures/no-logger';
let app;
@ -8,7 +8,13 @@ let user;
beforeAll(async () => {
db = await dbInit('project_health_api_serial', getLogger);
app = await setupApp(db.stores);
app = await setupAppWithCustomConfig(db.stores, {
experimental: {
flags: {
strictSchemaValidation: true,
},
},
});
user = await db.stores.userStore.insert({
name: 'Some Name',
email: 'test@getunleash.io',

View File

@ -1,4 +1,7 @@
import { IUnleashTest, setupApp } from '../../../helpers/test-helper';
import {
IUnleashTest,
setupAppWithCustomConfig,
} from '../../../helpers/test-helper';
import dbInit, { ITestDb } from '../../../helpers/database-init';
import getLogger from '../../../../fixtures/no-logger';
import * as jsonpatch from 'fast-json-patch';
@ -9,7 +12,13 @@ let db: ITestDb;
beforeAll(async () => {
db = await dbInit('project_feature_variants_api_serial', getLogger);
app = await setupApp(db.stores);
app = await setupAppWithCustomConfig(db.stores, {
experimental: {
flags: {
strictSchemaValidation: true,
},
},
});
await db.stores.environmentStore.create({
name: 'development',
type: 'development',

View File

@ -1,5 +1,5 @@
import dbInit from '../../helpers/database-init';
import { setupApp } from '../../helpers/test-helper';
import { setupAppWithCustomConfig } from '../../helpers/test-helper';
import getLogger from '../../../fixtures/no-logger';
let app;
@ -7,7 +7,13 @@ let db;
beforeAll(async () => {
db = await dbInit('tag_api_serial', getLogger);
app = await setupApp(db.stores);
app = await setupAppWithCustomConfig(db.stores, {
experimental: {
flags: {
strictSchemaValidation: true,
},
},
});
});
afterAll(async () => {

View File

@ -1223,6 +1223,10 @@ exports[`should serve the OpenAPI spec 1`] = `
"toggleName": {
"type": "string",
},
"totalEvents": {
"minimum": 0,
"type": "integer",
},
"version": {
"type": "number",
},
@ -1323,6 +1327,13 @@ exports[`should serve the OpenAPI spec 1`] = `
"example": false,
"type": "boolean",
},
"strategies": {
"description": "This is a legacy field that will be deprecated",
"items": {
"type": "object",
},
"type": "array",
},
"tags": {
"description": "The list of feature tags",
"items": {
@ -1660,6 +1671,7 @@ exports[`should serve the OpenAPI spec 1`] = `
"additionalProperties": false,
"properties": {
"description": {
"nullable": true,
"type": "string",
},
"environments": {
@ -1686,6 +1698,10 @@ exports[`should serve the OpenAPI spec 1`] = `
"name": {
"type": "string",
},
"stats": {
"$ref": "#/components/schemas/projectStatsSchema",
"description": "Project statistics",
},
"updatedAt": {
"format": "date-time",
"nullable": true,
@ -1708,6 +1724,7 @@ exports[`should serve the OpenAPI spec 1`] = `
"type": "number",
},
"description": {
"nullable": true,
"type": "string",
},
"environments": {
@ -1740,6 +1757,10 @@ exports[`should serve the OpenAPI spec 1`] = `
"staleCount": {
"type": "number",
},
"stats": {
"$ref": "#/components/schemas/projectStatsSchema",
"description": "Project statistics",
},
"updatedAt": {
"format": "date-time",
"nullable": true,