mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-06 00:07:44 +01:00
1fdf68eeec
### What We've had this marked as deprecated through our v4, this PR removes it. ### Worth noting This updates the deprecation notices with removal notices in the documentation as well. ### Considerations The tags API is still located under /api/admin/features/{featureName}/tags. It should be moved to /api/admin/projects/{project}/features/{featureName}/tags. I vote we do that in a separate PR, we'd probably also need to deprecate the existing tags endpoints for v5 and remove in v6. We could use 308s to signify that they are moved. --------- Co-authored-by: Thomas Heartman <thomas@getunleash.ai>
93 lines
2.6 KiB
TypeScript
93 lines
2.6 KiB
TypeScript
import dbInit, { ITestDb } from '../../helpers/database-init';
|
|
import { setupApp, setupAppWithCustomConfig } from '../../helpers/test-helper';
|
|
import getLogger from '../../../fixtures/no-logger';
|
|
|
|
let db: ITestDb;
|
|
|
|
beforeAll(async () => {
|
|
db = await dbInit('maintenance_api_serial', getLogger);
|
|
});
|
|
|
|
afterEach(async () => {
|
|
await db.stores.featureToggleStore.deleteAll();
|
|
});
|
|
|
|
afterAll(async () => {
|
|
await db.destroy();
|
|
});
|
|
|
|
test('should not allow to create feature toggles in maintenance mode', async () => {
|
|
const appWithMaintenanceMode = await setupAppWithCustomConfig(db.stores, {
|
|
experimental: {
|
|
flags: {
|
|
maintenanceMode: true,
|
|
},
|
|
},
|
|
});
|
|
|
|
return appWithMaintenanceMode.request
|
|
.post('/api/admin/projects/default/features')
|
|
.send({
|
|
name: 'maintenance-feature',
|
|
})
|
|
.set('Content-Type', 'application/json')
|
|
.expect(503);
|
|
});
|
|
|
|
test('maintenance mode is off by default', async () => {
|
|
const appWithMaintenanceMode = await setupApp(db.stores);
|
|
|
|
return appWithMaintenanceMode.request
|
|
.post('/api/admin/projects/default/features')
|
|
.send({
|
|
name: 'maintenance-feature1',
|
|
})
|
|
.set('Content-Type', 'application/json')
|
|
.expect(201);
|
|
});
|
|
|
|
test('should go into maintenance mode, when user has set it', async () => {
|
|
const appWithMaintenanceMode = await setupApp(db.stores);
|
|
|
|
await appWithMaintenanceMode.request
|
|
.post('/api/admin/maintenance')
|
|
.send({
|
|
enabled: true,
|
|
})
|
|
.set('Content-Type', 'application/json')
|
|
.expect(204);
|
|
|
|
return appWithMaintenanceMode.request
|
|
.post('/api/admin/projects/default/features')
|
|
.send({
|
|
name: 'maintenance-feature1',
|
|
})
|
|
.set('Content-Type', 'application/json')
|
|
.expect(503);
|
|
});
|
|
test('maintenance mode flag should take precedence over maintenance mode setting', async () => {
|
|
const appWithMaintenanceMode = await setupAppWithCustomConfig(db.stores, {
|
|
experimental: {
|
|
flags: {
|
|
maintenanceMode: true,
|
|
},
|
|
},
|
|
});
|
|
|
|
await appWithMaintenanceMode.request
|
|
.post('/api/admin/maintenance')
|
|
.send({
|
|
enabled: false,
|
|
})
|
|
.set('Content-Type', 'application/json')
|
|
.expect(204);
|
|
|
|
return appWithMaintenanceMode.request
|
|
.post('/api/admin/projects/default/features')
|
|
.send({
|
|
name: 'maintenance-feature1',
|
|
})
|
|
.set('Content-Type', 'application/json')
|
|
.expect(503);
|
|
});
|