1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-07-12 13:48:35 +02:00
unleash.unleash/src/lib/features/project/projects.e2e.test.ts
Gastón Fournier bdb763c9d5
chore!: remove deprecated default env from new installs (#10080)
**BREAKING CHANGE**: DEFAULT_ENV changed from `default` (should not be
used anymore) to `development`

## About the changes
- Only delete default env if the install is fresh new.
- Consider development the new default. The main consequence of this
change is that the default is no longer considered `type=production`
environment but also for frontend tokens due to this assumption:
724c4b78a2/src/lib/schema/api-token-schema.test.ts (L54-L59)
(I believe this is mostly due to the [support for admin
tokens](https://github.com/Unleash/unleash/pull/10080#discussion_r2126871567))
- `feature_toggle_update_total` metric reports `n/a` in environment and
environment type as it's not environment specific
2025-06-06 12:02:21 +02:00

94 lines
2.3 KiB
TypeScript

import dbInit, {
type ITestDb,
} from '../../../test/e2e/helpers/database-init.js';
import {
type IUnleashTest,
setupAppWithCustomConfig,
} from '../../../test/e2e/helpers/test-helper.js';
import getLogger from '../../../test/fixtures/no-logger.js';
import type { IProjectStore } from '../../types/index.js';
let app: IUnleashTest;
let db: ITestDb;
let projectStore: IProjectStore;
const testDate = '2023-10-01T12:34:56.000Z';
beforeAll(async () => {
db = await dbInit('projects_api_serial', getLogger);
app = await setupAppWithCustomConfig(
db.stores,
{
experimental: {
flags: {
strictSchemaValidation: true,
},
},
},
db.rawDatabase,
);
projectStore = db.stores.projectStore;
});
afterEach(async () => {
await db.stores.featureToggleStore.deleteAll();
});
afterAll(async () => {
await app.destroy();
await db.destroy();
});
test('Should ONLY return default project', async () => {
projectStore.create({
id: 'test2',
name: 'test',
description: '',
mode: 'open',
});
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 project overview should include feature type counts', async () => {
await app.createFeature({
name: 'my-new-release-toggle',
type: 'release',
});
await app.createFeature({
name: 'my-new-development-toggle',
type: 'experiment',
});
const { body } = await app.request
.get('/api/admin/projects/default/overview')
.expect('Content-Type', /json/)
.expect(200);
expect(body).toMatchObject({
featureTypeCounts: [
{
type: 'experiment',
count: 1,
},
{
type: 'release',
count: 1,
},
],
});
});