diff --git a/src/lib/features/feature-links/feature-link.e2e.test.ts b/src/lib/features/feature-links/feature-link.e2e.test.ts index 70f6a001e1..5098c12494 100644 --- a/src/lib/features/feature-links/feature-link.e2e.test.ts +++ b/src/lib/features/feature-links/feature-link.e2e.test.ts @@ -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', diff --git a/src/lib/features/feature-links/feature-links-read-model.ts b/src/lib/features/feature-links/feature-links-read-model.ts index 477bdee42a..36bec14b18 100644 --- a/src/lib/features/feature-links/feature-links-read-model.ts +++ b/src/lib/features/feature-links/feature-links-read-model.ts @@ -14,7 +14,8 @@ export class FeatureLinksReadModel implements IFeatureLinksReadModel { async getLinks(feature: string): Promise { 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,