mirror of
https://github.com/Unleash/unleash.git
synced 2025-03-18 00:19:49 +01:00
fix: backport lifecycle and playground fixes (#7396)
This commit is contained in:
parent
29e0167001
commit
406f906d7f
@ -6,5 +6,5 @@ export const comparisonModerator = (
|
||||
): DeepOmit<IFeatureToggle, keyof IFeatureToggle> => {
|
||||
const tempData = { ...data };
|
||||
|
||||
return deepOmit(tempData, 'lastSeenAt', 'yes', 'no');
|
||||
return deepOmit(tempData, 'lastSeenAt', 'yes', 'no', 'lifecycle');
|
||||
};
|
||||
|
@ -8,6 +8,7 @@ import {
|
||||
DELETE_FEATURE,
|
||||
UPDATE_FEATURE,
|
||||
} from 'component/providers/AccessProvider/permissions';
|
||||
import { Route, Routes } from 'react-router-dom';
|
||||
|
||||
const currentTime = '2024-04-25T08:05:00.000Z';
|
||||
const twoMinutesAgo = '2024-04-25T08:03:00.000Z';
|
||||
@ -22,16 +23,24 @@ const renderOpenTooltip = (
|
||||
loading = false,
|
||||
) => {
|
||||
render(
|
||||
<FeatureLifecycleTooltip
|
||||
stage={stage}
|
||||
onArchive={onArchive}
|
||||
onComplete={onComplete}
|
||||
onUncomplete={onUncomplete}
|
||||
loading={loading}
|
||||
>
|
||||
<span>child</span>
|
||||
</FeatureLifecycleTooltip>,
|
||||
<Routes>
|
||||
<Route
|
||||
path={'/projects/:projectId'}
|
||||
element={
|
||||
<FeatureLifecycleTooltip
|
||||
stage={stage}
|
||||
onArchive={onArchive}
|
||||
onComplete={onComplete}
|
||||
onUncomplete={onUncomplete}
|
||||
loading={loading}
|
||||
>
|
||||
<span>child</span>
|
||||
</FeatureLifecycleTooltip>
|
||||
}
|
||||
/>
|
||||
</Routes>,
|
||||
{
|
||||
route: '/projects/default',
|
||||
permissions: [
|
||||
{ permission: DELETE_FEATURE },
|
||||
{ permission: UPDATE_FEATURE },
|
||||
|
@ -25,6 +25,7 @@ import { isSafeToArchive } from './isSafeToArchive';
|
||||
import { useLocationSettings } from 'hooks/useLocationSettings';
|
||||
import { formatDateYMDHMS } from 'utils/formatDate';
|
||||
import { formatDistanceToNow, parseISO } from 'date-fns';
|
||||
import { useRequiredPathParam } from 'hooks/useRequiredPathParam';
|
||||
|
||||
const TimeLabel = styled('span')(({ theme }) => ({
|
||||
color: theme.palette.text.secondary,
|
||||
@ -264,6 +265,8 @@ const LiveStageDescription: FC<{
|
||||
onComplete: () => void;
|
||||
loading: boolean;
|
||||
}> = ({ children, onComplete, loading }) => {
|
||||
const projectId = useRequiredPathParam('projectId');
|
||||
|
||||
return (
|
||||
<>
|
||||
<BoldTitle>Is this feature complete?</BoldTitle>
|
||||
@ -282,6 +285,7 @@ const LiveStageDescription: FC<{
|
||||
size='small'
|
||||
onClick={onComplete}
|
||||
disabled={loading}
|
||||
projectId={projectId}
|
||||
>
|
||||
Mark completed
|
||||
</PermissionButton>
|
||||
@ -300,6 +304,8 @@ const SafeToArchive: FC<{
|
||||
onUncomplete: () => void;
|
||||
loading: boolean;
|
||||
}> = ({ onArchive, onUncomplete, loading }) => {
|
||||
const projectId = useRequiredPathParam('projectId');
|
||||
|
||||
return (
|
||||
<>
|
||||
<BoldTitle>Safe to archive</BoldTitle>
|
||||
@ -316,6 +322,7 @@ const SafeToArchive: FC<{
|
||||
sx={{
|
||||
display: 'flex',
|
||||
flexDirection: 'row',
|
||||
flexWrap: 'wrap',
|
||||
gap: 2,
|
||||
}}
|
||||
>
|
||||
@ -326,6 +333,7 @@ const SafeToArchive: FC<{
|
||||
size='small'
|
||||
onClick={onUncomplete}
|
||||
disabled={loading}
|
||||
projectId={projectId}
|
||||
>
|
||||
Revert to live
|
||||
</PermissionButton>
|
||||
@ -336,6 +344,7 @@ const SafeToArchive: FC<{
|
||||
size='small'
|
||||
sx={{ mb: 2 }}
|
||||
onClick={onArchive}
|
||||
projectId={projectId}
|
||||
>
|
||||
Archive feature
|
||||
</PermissionButton>
|
||||
|
24
package.json
24
package.json
@ -82,9 +82,7 @@
|
||||
"testTimeout": 10000,
|
||||
"globalSetup": "./scripts/jest-setup.js",
|
||||
"transform": {
|
||||
"^.+\\.tsx?$": [
|
||||
"@swc/jest"
|
||||
]
|
||||
"^.+\\.tsx?$": ["@swc/jest"]
|
||||
},
|
||||
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
|
||||
"testPathIgnorePatterns": [
|
||||
@ -93,13 +91,7 @@
|
||||
"/frontend/",
|
||||
"/website/"
|
||||
],
|
||||
"moduleFileExtensions": [
|
||||
"ts",
|
||||
"tsx",
|
||||
"js",
|
||||
"jsx",
|
||||
"json"
|
||||
],
|
||||
"moduleFileExtensions": ["ts", "tsx", "js", "jsx", "json"],
|
||||
"coveragePathIgnorePatterns": [
|
||||
"/node_modules/",
|
||||
"/dist/",
|
||||
@ -240,14 +232,8 @@
|
||||
"tough-cookie": "4.1.4"
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.{js,ts}": [
|
||||
"biome check --write --no-errors-on-unmatched"
|
||||
],
|
||||
"*.{jsx,tsx}": [
|
||||
"biome check --write --no-errors-on-unmatched"
|
||||
],
|
||||
"*.json": [
|
||||
"biome format --write --no-errors-on-unmatched"
|
||||
]
|
||||
"*.{js,ts}": ["biome check --write --no-errors-on-unmatched"],
|
||||
"*.{jsx,tsx}": ["biome check --write --no-errors-on-unmatched"],
|
||||
"*.json": ["biome format --write --no-errors-on-unmatched"]
|
||||
}
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ test('advanced playground evaluation with no toggles', async () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('advanced playground evaluation with parent dependency', async () => {
|
||||
test('advanced playground evaluation with unsatisfied parent dependency', async () => {
|
||||
await createFeatureToggle('test-parent');
|
||||
await createFeatureToggle('test-child');
|
||||
await enableToggle('test-child');
|
||||
@ -126,6 +126,35 @@ test('advanced playground evaluation with parent dependency', async () => {
|
||||
expect(parent.isEnabled).toBe(false);
|
||||
});
|
||||
|
||||
test('advanced playground evaluation with satisfied disabled parent dependency', async () => {
|
||||
await createFeatureToggle('test-parent');
|
||||
await createFeatureToggle('test-child');
|
||||
await enableToggle('test-child');
|
||||
await app.addDependency('test-child', {
|
||||
feature: 'test-parent',
|
||||
enabled: false,
|
||||
variants: [],
|
||||
});
|
||||
|
||||
const { body: result } = await app.request
|
||||
.post('/api/admin/playground/advanced')
|
||||
.send({
|
||||
environments: ['default'],
|
||||
projects: ['default'],
|
||||
context: { appName: 'test' },
|
||||
})
|
||||
.set('Content-Type', 'application/json')
|
||||
.expect(200);
|
||||
|
||||
const child = result.features[0].environments.default[0];
|
||||
const parent = result.features[1].environments.default[0];
|
||||
|
||||
expect(child.hasUnsatisfiedDependency).toBe(false);
|
||||
expect(child.isEnabled).toBe(true);
|
||||
expect(parent.hasUnsatisfiedDependency).toBe(false);
|
||||
expect(parent.isEnabled).toBe(false);
|
||||
});
|
||||
|
||||
test('advanced playground evaluation happy path', async () => {
|
||||
await createFeatureToggleWithStrategy('test-playground-feature');
|
||||
await enableToggle('test-playground-feature');
|
||||
|
@ -77,9 +77,6 @@ export default class UnleashClient {
|
||||
}
|
||||
|
||||
if (parent.enabled !== false) {
|
||||
if (!parentToggle.enabled) {
|
||||
return false;
|
||||
}
|
||||
if (parent.variants?.length) {
|
||||
return parent.variants.includes(
|
||||
this.getVariant(parent.feature, context).name,
|
||||
@ -91,12 +88,9 @@ export default class UnleashClient {
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
!parentToggle.enabled &&
|
||||
!(
|
||||
this.isEnabled(parent.feature, context, () => false)
|
||||
.result === true
|
||||
)
|
||||
return !(
|
||||
this.isEnabled(parent.feature, context, () => false).result ===
|
||||
true
|
||||
);
|
||||
});
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ import type { Db } from '../../../lib/db/db';
|
||||
import type { IContextFieldDto } from '../../../lib/types/stores/context-field-store';
|
||||
import { DEFAULT_ENV } from '../../../lib/util';
|
||||
import type {
|
||||
CreateDependentFeatureSchema,
|
||||
CreateFeatureSchema,
|
||||
CreateFeatureStrategySchema,
|
||||
ImportTogglesSchema,
|
||||
@ -102,7 +103,10 @@ export interface IUnleashHttpAPI {
|
||||
expectedResponseCode?: number,
|
||||
): supertest.Test;
|
||||
|
||||
addDependency(child: string, parent: string): supertest.Test;
|
||||
addDependency(
|
||||
child: string,
|
||||
parent: string | CreateDependentFeatureSchema,
|
||||
): supertest.Test;
|
||||
|
||||
addTag(
|
||||
feature: string,
|
||||
@ -224,7 +228,7 @@ function httpApis(
|
||||
|
||||
addDependency(
|
||||
child: string,
|
||||
parent: string,
|
||||
parent: string | CreateDependentFeatureSchema,
|
||||
project = DEFAULT_PROJECT,
|
||||
expectedResponseCode: number = 200,
|
||||
): supertest.Test {
|
||||
@ -232,7 +236,7 @@ function httpApis(
|
||||
.post(
|
||||
`/api/admin/projects/${project}/features/${child}/dependencies`,
|
||||
)
|
||||
.send({ feature: parent })
|
||||
.send(typeof parent === 'string' ? { feature: parent } : parent)
|
||||
.set('Content-Type', 'application/json')
|
||||
.expect(expectedResponseCode);
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user