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

fix: project environments order (#1599)

This commit is contained in:
Tymoteusz Czech 2022-05-23 10:52:50 +02:00 committed by GitHub
parent f306622580
commit 0f272680ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 46 additions and 2 deletions

View File

@ -311,7 +311,6 @@ class FeatureStrategiesStore implements IFeatureStrategiesStore {
);
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
private static getEnvironment(r: any): IEnvironmentOverview {
return {
name: r.environment,

View File

@ -238,7 +238,14 @@ class ProjectStore implements IProjectStore {
.where({
project_id: id,
})
.pluck('environment_name');
.innerJoin(
'environments',
'project_environments.environment_name',
'environments.name',
)
.orderBy('environments.sort_order', 'asc')
.orderBy('project_environments.environment_name', 'asc')
.pluck('project_environments.environment_name');
}
async getMembers(projectId: string): Promise<number> {

View File

@ -518,6 +518,44 @@ test('A newly created project only gets connected to enabled environments', asyn
expect(connectedEnvs.some((e) => e === disabledEnv)).toBeFalsy();
});
test('should have environments sorted in order', async () => {
const project = {
id: 'environment-order-test',
name: 'Environment testing project',
description: '',
};
const first = 'test';
const second = 'abc';
const third = 'example';
const fourth = 'mock';
await db.stores.environmentStore.create({
name: first,
type: 'test',
sortOrder: 1,
});
await db.stores.environmentStore.create({
name: fourth,
type: 'test',
sortOrder: 4,
});
await db.stores.environmentStore.create({
name: third,
type: 'test',
sortOrder: 3,
});
await db.stores.environmentStore.create({
name: second,
type: 'test',
sortOrder: 2,
});
await projectService.createProject(project, user);
const connectedEnvs =
await db.stores.projectStore.getEnvironmentsForProject(project.id);
expect(connectedEnvs).toEqual(['default', first, second, third, fourth]);
});
test('should add a user to the project with a custom role', async () => {
const project = {
id: 'add-users-custom-role',