mirror of
https://github.com/Unleash/unleash.git
synced 2025-04-10 01:16:39 +02:00
fix: playground parent disabled with strategy (#7744)
This commit is contained in:
parent
0284daf2ba
commit
afa34867c1
@ -59,6 +59,13 @@ const enableToggle = (featureName: string) =>
|
|||||||
)
|
)
|
||||||
.send({})
|
.send({})
|
||||||
.expect(200);
|
.expect(200);
|
||||||
|
const disableToggle = (featureName: string) =>
|
||||||
|
app.request
|
||||||
|
.post(
|
||||||
|
`/api/admin/projects/default/features/${featureName}/environments/default/off`,
|
||||||
|
)
|
||||||
|
.send({})
|
||||||
|
.expect(200);
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
await app.destroy();
|
await app.destroy();
|
||||||
@ -99,6 +106,8 @@ test('advanced playground evaluation with unsatisfied parent dependency', async
|
|||||||
await createFeatureToggle('test-parent');
|
await createFeatureToggle('test-parent');
|
||||||
await createFeatureToggle('test-child');
|
await createFeatureToggle('test-child');
|
||||||
await enableToggle('test-child');
|
await enableToggle('test-child');
|
||||||
|
await enableToggle('test-parent');
|
||||||
|
await disableToggle('test-parent');
|
||||||
await app.addDependency('test-child', 'test-parent');
|
await app.addDependency('test-child', 'test-parent');
|
||||||
|
|
||||||
const { body: result } = await app.request
|
const { body: result } = await app.request
|
||||||
@ -116,6 +125,7 @@ test('advanced playground evaluation with unsatisfied parent dependency', async
|
|||||||
// child is disabled because of the parent
|
// child is disabled because of the parent
|
||||||
expect(child.hasUnsatisfiedDependency).toBe(true);
|
expect(child.hasUnsatisfiedDependency).toBe(true);
|
||||||
expect(child.isEnabled).toBe(false);
|
expect(child.isEnabled).toBe(false);
|
||||||
|
expect(child.strategies.data.length).toBe(1);
|
||||||
expect(child.isEnabledInCurrentEnvironment).toBe(true);
|
expect(child.isEnabledInCurrentEnvironment).toBe(true);
|
||||||
expect(child.variant).toEqual({
|
expect(child.variant).toEqual({
|
||||||
name: 'disabled',
|
name: 'disabled',
|
||||||
@ -124,6 +134,7 @@ test('advanced playground evaluation with unsatisfied parent dependency', async
|
|||||||
});
|
});
|
||||||
expect(parent.hasUnsatisfiedDependency).toBe(false);
|
expect(parent.hasUnsatisfiedDependency).toBe(false);
|
||||||
expect(parent.isEnabled).toBe(false);
|
expect(parent.isEnabled).toBe(false);
|
||||||
|
expect(parent.strategies.data.length).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('advanced playground evaluation with satisfied disabled parent dependency', async () => {
|
test('advanced playground evaluation with satisfied disabled parent dependency', async () => {
|
||||||
|
@ -75,6 +75,9 @@ export default class UnleashClient {
|
|||||||
if (parentToggle.dependencies?.length) {
|
if (parentToggle.dependencies?.length) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (Boolean(parent.enabled) !== Boolean(parentToggle.enabled)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (parent.enabled !== false) {
|
if (parent.enabled !== false) {
|
||||||
if (parent.variants?.length) {
|
if (parent.variants?.length) {
|
||||||
|
Loading…
Reference in New Issue
Block a user