1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-07-26 13:48:33 +02:00

feat: order links by insertion order (#9928)

This commit is contained in:
Mateusz Kwasniewski 2025-05-08 10:46:26 +02:00 committed by GitHub
parent dea785fb96
commit c8ebaa49fc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 35 additions and 13 deletions

View File

@ -58,7 +58,7 @@ const addLink = async (
.expect(expectedCode);
};
const updatedLink = async (
const updateLink = async (
featureName: string,
linkId: string,
link: FeatureLinkSchema,
@ -88,6 +88,10 @@ test('should manage feature links', async () => {
await app.createFeature('my_feature');
await addLink('my_feature', { url: 'example.com', title: 'feature link' });
await addLink('my_feature', {
url: 'example_another.com',
title: 'another feature link',
});
const links = await featureLinkStore.getAll();
expect(links).toMatchObject([
@ -96,30 +100,44 @@ test('should manage feature links', async () => {
title: 'feature link',
featureName: 'my_feature',
},
{
url: 'https://example_another.com',
title: 'another feature link',
featureName: 'my_feature',
},
]);
const { body } = await app.getProjectFeatures('default', 'my_feature');
expect(body.links).toMatchObject([
{ id: links[0].id, title: 'feature link', url: 'https://example.com' },
{
id: links[1].id,
title: 'another feature link',
url: 'https://example_another.com',
},
]);
await updatedLink('my_feature', links[0].id, {
await updateLink('my_feature', links[0].id, {
url: 'example_updated.com',
title: 'feature link updated',
});
const updatedLinks = await featureLinkStore.getAll();
expect(updatedLinks).toMatchObject([
{
url: 'https://example_updated.com',
title: 'feature link updated',
featureName: 'my_feature',
},
]);
const updatedLink = await featureLinkStore.get(links[0].id);
expect(updatedLink).toMatchObject({
url: 'https://example_updated.com',
title: 'feature link updated',
featureName: 'my_feature',
});
await deleteLink('my_feature', links[0].id);
const deletedLinks = await featureLinkStore.getAll();
expect(deletedLinks).toMatchObject([]);
expect(deletedLinks).toMatchObject([
{
id: links[1].id,
title: 'another feature link',
url: 'https://example_another.com',
},
]);
const [event1, event2, event3] = await eventStore.getEvents();
expect([event1, event2, event3]).toMatchObject([
@ -145,7 +163,10 @@ test('should manage feature links', async () => {
},
{
type: 'feature-link-added',
data: { url: 'https://example.com', title: 'feature link' },
data: {
url: 'https://example_another.com',
title: 'another feature link',
},
preData: null,
featureName: 'my_feature',
project: 'default',

View File

@ -14,7 +14,8 @@ export class FeatureLinksReadModel implements IFeatureLinksReadModel {
async getLinks(feature: string): Promise<IFeatureLink[]> {
const links = await this.db
.from('feature_link')
.where('feature_name', feature);
.where('feature_name', feature)
.orderBy('id', 'asc');
return links.map((link) => ({
id: link.id,