mirror of
https://github.com/Unleash/unleash.git
synced 2025-09-28 17:55:15 +02:00
fix: fix bulk removal of tags (#3651)
This commit is contained in:
parent
10fee99467
commit
2a6cfc434f
@ -187,6 +187,7 @@ class FeatureTagStore implements IFeatureTagStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async tagFeatures(featureTags: IFeatureTag[]): Promise<IFeatureAndTag[]> {
|
async tagFeatures(featureTags: IFeatureTag[]): Promise<IFeatureAndTag[]> {
|
||||||
|
if (featureTags.length !== 0) {
|
||||||
const rows = await this.db(TABLE)
|
const rows = await this.db(TABLE)
|
||||||
.insert(featureTags.map(this.featureTagToRow))
|
.insert(featureTags.map(this.featureTagToRow))
|
||||||
.returning(COLUMNS)
|
.returning(COLUMNS)
|
||||||
@ -195,6 +196,7 @@ class FeatureTagStore implements IFeatureTagStore {
|
|||||||
if (rows) {
|
if (rows) {
|
||||||
return rows.map(this.rowToFeatureAndTag);
|
return rows.map(this.rowToFeatureAndTag);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,3 +161,48 @@ test('Can tag features', async () => {
|
|||||||
expect(res.body).toMatchObject({ tags: [addedTag] });
|
expect(res.body).toMatchObject({ tags: [addedTag] });
|
||||||
expect(res2.body).toMatchObject({ tags: [addedTag] });
|
expect(res2.body).toMatchObject({ tags: [addedTag] });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Can bulk remove tags', async () => {
|
||||||
|
const featureName = 'test.feature3';
|
||||||
|
const featureName2 = 'test.feature4';
|
||||||
|
const addedTag = {
|
||||||
|
value: 'TeamRed',
|
||||||
|
type: 'simple',
|
||||||
|
};
|
||||||
|
|
||||||
|
await app.request.post('/api/admin/projects/default/features').send({
|
||||||
|
name: featureName,
|
||||||
|
type: 'killswitch',
|
||||||
|
enabled: true,
|
||||||
|
strategies: [{ name: 'default' }],
|
||||||
|
});
|
||||||
|
|
||||||
|
await app.request.post('/api/admin/projects/default/features').send({
|
||||||
|
name: featureName2,
|
||||||
|
type: 'killswitch',
|
||||||
|
enabled: true,
|
||||||
|
strategies: [{ name: 'default' }],
|
||||||
|
});
|
||||||
|
|
||||||
|
await app.request
|
||||||
|
.put('/api/admin/tags/features')
|
||||||
|
.send({
|
||||||
|
features: [featureName, featureName2],
|
||||||
|
tags: {
|
||||||
|
addedTags: [addedTag],
|
||||||
|
removedTags: [],
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.expect(200);
|
||||||
|
|
||||||
|
await app.request
|
||||||
|
.put('/api/admin/tags/features')
|
||||||
|
.send({
|
||||||
|
features: [featureName, featureName2],
|
||||||
|
tags: {
|
||||||
|
addedTags: [],
|
||||||
|
removedTags: [addedTag],
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.expect(200);
|
||||||
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user