mirror of
https://github.com/Unleash/unleash.git
synced 2025-09-24 17:51:14 +02:00
feat: order links by insertion order (#9928)
This commit is contained in:
parent
dea785fb96
commit
c8ebaa49fc
@ -58,7 +58,7 @@ const addLink = async (
|
|||||||
.expect(expectedCode);
|
.expect(expectedCode);
|
||||||
};
|
};
|
||||||
|
|
||||||
const updatedLink = async (
|
const updateLink = async (
|
||||||
featureName: string,
|
featureName: string,
|
||||||
linkId: string,
|
linkId: string,
|
||||||
link: FeatureLinkSchema,
|
link: FeatureLinkSchema,
|
||||||
@ -88,6 +88,10 @@ test('should manage feature links', async () => {
|
|||||||
await app.createFeature('my_feature');
|
await app.createFeature('my_feature');
|
||||||
|
|
||||||
await addLink('my_feature', { url: 'example.com', title: 'feature link' });
|
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();
|
const links = await featureLinkStore.getAll();
|
||||||
expect(links).toMatchObject([
|
expect(links).toMatchObject([
|
||||||
@ -96,30 +100,44 @@ test('should manage feature links', async () => {
|
|||||||
title: 'feature link',
|
title: 'feature link',
|
||||||
featureName: 'my_feature',
|
featureName: 'my_feature',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
url: 'https://example_another.com',
|
||||||
|
title: 'another feature link',
|
||||||
|
featureName: 'my_feature',
|
||||||
|
},
|
||||||
]);
|
]);
|
||||||
const { body } = await app.getProjectFeatures('default', 'my_feature');
|
const { body } = await app.getProjectFeatures('default', 'my_feature');
|
||||||
expect(body.links).toMatchObject([
|
expect(body.links).toMatchObject([
|
||||||
{ id: links[0].id, title: 'feature link', url: 'https://example.com' },
|
{ 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',
|
url: 'example_updated.com',
|
||||||
title: 'feature link updated',
|
title: 'feature link updated',
|
||||||
});
|
});
|
||||||
|
|
||||||
const updatedLinks = await featureLinkStore.getAll();
|
const updatedLink = await featureLinkStore.get(links[0].id);
|
||||||
expect(updatedLinks).toMatchObject([
|
expect(updatedLink).toMatchObject({
|
||||||
{
|
|
||||||
url: 'https://example_updated.com',
|
url: 'https://example_updated.com',
|
||||||
title: 'feature link updated',
|
title: 'feature link updated',
|
||||||
featureName: 'my_feature',
|
featureName: 'my_feature',
|
||||||
},
|
});
|
||||||
]);
|
|
||||||
|
|
||||||
await deleteLink('my_feature', links[0].id);
|
await deleteLink('my_feature', links[0].id);
|
||||||
|
|
||||||
const deletedLinks = await featureLinkStore.getAll();
|
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();
|
const [event1, event2, event3] = await eventStore.getEvents();
|
||||||
expect([event1, event2, event3]).toMatchObject([
|
expect([event1, event2, event3]).toMatchObject([
|
||||||
@ -145,7 +163,10 @@ test('should manage feature links', async () => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'feature-link-added',
|
type: 'feature-link-added',
|
||||||
data: { url: 'https://example.com', title: 'feature link' },
|
data: {
|
||||||
|
url: 'https://example_another.com',
|
||||||
|
title: 'another feature link',
|
||||||
|
},
|
||||||
preData: null,
|
preData: null,
|
||||||
featureName: 'my_feature',
|
featureName: 'my_feature',
|
||||||
project: 'default',
|
project: 'default',
|
||||||
|
@ -14,7 +14,8 @@ export class FeatureLinksReadModel implements IFeatureLinksReadModel {
|
|||||||
async getLinks(feature: string): Promise<IFeatureLink[]> {
|
async getLinks(feature: string): Promise<IFeatureLink[]> {
|
||||||
const links = await this.db
|
const links = await this.db
|
||||||
.from('feature_link')
|
.from('feature_link')
|
||||||
.where('feature_name', feature);
|
.where('feature_name', feature)
|
||||||
|
.orderBy('id', 'asc');
|
||||||
|
|
||||||
return links.map((link) => ({
|
return links.map((link) => ({
|
||||||
id: link.id,
|
id: link.id,
|
||||||
|
Loading…
Reference in New Issue
Block a user