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

feat: sort parent options alphabetically (#5238)

This commit is contained in:
Mateusz Kwasniewski 2023-11-01 21:18:19 +01:00 committed by GitHub
parent bc66fb649f
commit cbc89f6a92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View File

@ -77,7 +77,8 @@ export class DependentFeaturesReadModel implements IDependentFeaturesReadModel {
.andWhere('features.name', '!=', child)
.andWhere('dependent_features.child', null)
.andWhere('features.archived_at', null)
.select('features.name');
.select('features.name')
.orderBy('features.name');
return rows.map((item) => item.name);
}

View File

@ -55,6 +55,7 @@ afterAll(async () => {
beforeEach(async () => {
await db.stores.dependentFeaturesStore.deleteAll();
await db.stores.featureToggleStore.deleteAll();
});
const addFeatureDependency = async (
@ -136,6 +137,20 @@ test('should add and delete feature dependencies', async () => {
]);
});
test('should sort parent options alphabetically', async () => {
const parent1 = `a${uuidv4()}`;
const parent2 = `c${uuidv4()}`;
const parent3 = `b${uuidv4()}`;
const child = uuidv4();
await app.createFeature(parent1);
await app.createFeature(parent2);
await app.createFeature(parent3);
await app.createFeature(child);
const { body: parentOptions } = await getParentOptions(child);
expect(parentOptions).toStrictEqual([parent1, parent3, parent2]);
});
test('should not allow to add grandparent', async () => {
const grandparent = uuidv4();
const parent = uuidv4();