diff --git a/frontend/src/component/playground/Playground/PlaygroundForm/PlaygroundConnectionFieldset/PlaygroundConnectionFieldset.test.tsx b/frontend/src/component/playground/Playground/PlaygroundForm/PlaygroundConnectionFieldset/PlaygroundConnectionFieldset.test.tsx index cc89480bf9..196ad3f26c 100644 --- a/frontend/src/component/playground/Playground/PlaygroundForm/PlaygroundConnectionFieldset/PlaygroundConnectionFieldset.test.tsx +++ b/frontend/src/component/playground/Playground/PlaygroundForm/PlaygroundConnectionFieldset/PlaygroundConnectionFieldset.test.tsx @@ -7,26 +7,43 @@ import { useState } from 'react'; const server = testServerSetup(); beforeEach(() => { - testServerRoute(server, '/API/admin/ui-config', { + testServerRoute(server, '/api/admin/ui-config', { versionInfo: { current: { oss: 'version', enterprise: 'version' }, }, - flags: { - playgroundImprovements: true, - }, }); testServerRoute( server, - '/API/admin/projects', + '/api/admin/projects', + { + version: 1, projects: [ { - id: 'default', name: 'Default', + id: 'default', + description: 'Default project', + health: 100, + favorite: false, + featureCount: 0, + memberCount: 0, + updatedAt: '2023-11-21T15:50:57.035Z', + createdAt: '2023-11-10T09:52:14.898Z', + mode: 'open', + defaultStickiness: 'default', }, { - id: 'MyProject', name: 'MyProject', + id: 'MyProject', + description: '', + health: 100, + favorite: false, + featureCount: 1, + memberCount: 1, + updatedAt: '2023-11-21T15:50:57.037Z', + createdAt: '2023-11-10T09:52:52.169Z', + mode: 'open', + defaultStickiness: 'sessionId', }, ], }, @@ -35,7 +52,7 @@ beforeEach(() => { ); testServerRoute( server, - '/API/admin/API-tokens', + '/api/admin/api-tokens', { tokens: [ { @@ -69,45 +86,57 @@ const Component = () => { ); }; -test('should parse project and environment from token input', async () => { - render(); +const timeoutInMilliseconds = 10000; - const tokenInput = await screen.findByLabelText('API token'); - fireEvent.change(tokenInput, { - target: { - value: 'default:development.964a287e1b728cb5f4f3e0120df92cb5', - }, - }); +test( + 'should parse project and environment from token input', + async () => { + const { container } = render(); + const projectAutocomplete = await screen.findByTestId( + 'PLAYGROUND_PROJECT_SELECT', + ); + const button = await within(projectAutocomplete).findByRole('button'); + fireEvent.click(button); + await within(container).findByText('Default'); + const tokenInput = await screen.findByLabelText('API token'); + fireEvent.change(tokenInput, { + target: { + value: 'default:development.964a287e1b728cb5f4f3e0120df92cb5', + }, + }); + + const projectInput = within(projectAutocomplete).getByRole('combobox'); + + const environmentAutocomplete = await screen.findByTestId( + 'PLAYGROUND_ENVIRONMENT_SELECT', + ); + const environmentInput = within(environmentAutocomplete).getByRole( + 'combobox', + ); + + expect(projectInput).toBeDisabled(); + expect(environmentInput).toBeDisabled(); + await within(projectAutocomplete).findByText('Default'); + await within(environmentAutocomplete).findByText('development'); + }, + timeoutInMilliseconds, +); + +test('should load projects from token definition if project is []', async () => { + const { container } = render(); const projectAutocomplete = await screen.findByTestId( 'PLAYGROUND_PROJECT_SELECT', ); - const projectInput = within(projectAutocomplete).getByRole('combobox'); - - const environmentAutocomplete = await screen.findByTestId( - 'PLAYGROUND_ENVIRONMENT_SELECT', - ); - const environmentInput = within(environmentAutocomplete).getByRole( - 'combobox', - ); - - expect(projectInput).toBeDisabled(); - expect(environmentInput).toBeDisabled(); - await within(projectAutocomplete).findByText('Default'); - await within(environmentAutocomplete).findByText('development'); -}); - -test('should load projects from token definition if project is []', async () => { - render(); + const button = await within(projectAutocomplete).findByRole('button'); + fireEvent.click(button); + await within(container).findByText('Default'); const tokenInput = await screen.findByLabelText('API token'); fireEvent.change(tokenInput, { target: { value: '[]:development.964a287e1b728cb5f4f3e0120df92cb5' }, }); - const projectAutocomplete = await screen.findByTestId( - 'PLAYGROUND_PROJECT_SELECT', - ); const projectInput = within(projectAutocomplete).getByRole('combobox'); const environmentAutocomplete = await screen.findByTestId( @@ -125,16 +154,19 @@ test('should load projects from token definition if project is []', async () => }); test('should show an error when admin token', async () => { - render(); + const { container } = render(); + const projectAutocomplete = await screen.findByTestId( + 'PLAYGROUND_PROJECT_SELECT', + ); + const button = await within(projectAutocomplete).findByRole('button'); + fireEvent.click(button); + await within(container).findByText('Default'); const tokenInput = await screen.findByLabelText('API token'); fireEvent.change(tokenInput, { target: { value: '*:*.964a287e1b728cb5f4f3e0120df92cb5' }, }); - const projectAutocomplete = await screen.findByTestId( - 'PLAYGROUND_PROJECT_SELECT', - ); const projectInput = within(projectAutocomplete).getByRole('combobox'); const environmentAutocomplete = await screen.findByTestId( @@ -150,7 +182,13 @@ test('should show an error when admin token', async () => { }); test('should have a working clear button when token is filled', async () => { - render(); + const { container } = render(); + const projectAutocomplete = await screen.findByTestId( + 'PLAYGROUND_PROJECT_SELECT', + ); + const button = await within(projectAutocomplete).findByRole('button'); + fireEvent.click(button); + await within(container).findByText('Default'); const tokenInput = await screen.findByLabelText('API token'); fireEvent.change(tokenInput, { @@ -160,8 +198,8 @@ test('should have a working clear button when token is filled', async () => { }); const clear = await screen.findByTestId('TOKEN_INPUT_CLEAR_BTN'); - const button = within(clear).getByRole('button'); - fireEvent.click(button); + const clearButton = within(clear).getByRole('button'); + fireEvent.click(clearButton); expect(tokenInput).toHaveValue(''); }); diff --git a/frontend/src/component/playground/Playground/PlaygroundForm/PlaygroundConnectionFieldset/PlaygroundConnectionFieldset.tsx b/frontend/src/component/playground/Playground/PlaygroundForm/PlaygroundConnectionFieldset/PlaygroundConnectionFieldset.tsx index dae8b15683..0fb4affe0a 100644 --- a/frontend/src/component/playground/Playground/PlaygroundForm/PlaygroundConnectionFieldset/PlaygroundConnectionFieldset.tsx +++ b/frontend/src/component/playground/Playground/PlaygroundForm/PlaygroundConnectionFieldset/PlaygroundConnectionFieldset.tsx @@ -58,11 +58,11 @@ export const PlaygroundConnectionFieldset: VFC< availableEnvironments, }) => { const theme = useTheme(); - const playgroundImprovements = useUiFlag('playgroundImprovements'); const { tokens } = useApiTokens(); const [tokenError, setTokenError] = useState(); - const { projects: availableProjects = [] } = useProjects(); + const { projects: availableProjects } = useProjects(); + const projectsOptions = [ allOption, ...availableProjects.map(({ name: label, id }) => ({ @@ -155,7 +155,6 @@ export const PlaygroundConnectionFieldset: VFC< const [tokenProject, tokenEnvironment] = extractProjectEnvironmentFromToken(tempToken); setEnvironments([tokenEnvironment]); - switch (tokenProject) { case '[]': handleTokenWithSomeProjects(tempToken); @@ -301,24 +300,19 @@ export const PlaygroundConnectionFieldset: VFC< /> - - } + ); diff --git a/frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/FeatureStrategyList/PlaygroundResultFeatureStrategyList.tsx b/frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/FeatureStrategyList/PlaygroundResultFeatureStrategyList.tsx index 2adbcdb49d..d8d7f71759 100644 --- a/frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/FeatureStrategyList/PlaygroundResultFeatureStrategyList.tsx +++ b/frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/FeatureStrategyList/PlaygroundResultFeatureStrategyList.tsx @@ -16,7 +16,6 @@ export const PlaygroundResultFeatureStrategyList = ({ feature, input, }: PlaygroundResultFeatureStrategyListProps) => { - const playgroundImprovements = useUiFlag('playgroundImprovements'); const enabledStrategies = feature.strategies?.data?.filter( (strategy) => !strategy.disabled, ); @@ -24,8 +23,7 @@ export const PlaygroundResultFeatureStrategyList = ({ (strategy) => strategy.disabled, ); - const showDisabledStrategies = - playgroundImprovements && disabledStrategies?.length > 0; + const showDisabledStrategies = disabledStrategies?.length > 0; return ( <> diff --git a/frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/FeatureStrategyList/StrategyList/playgroundResultStrategyLists.tsx b/frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/FeatureStrategyList/StrategyList/playgroundResultStrategyLists.tsx index aa08a59f93..a22eeed56e 100644 --- a/frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/FeatureStrategyList/StrategyList/playgroundResultStrategyLists.tsx +++ b/frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/FeatureStrategyList/StrategyList/playgroundResultStrategyLists.tsx @@ -110,7 +110,6 @@ export const WrappedPlaygroundResultStrategyList = ({ feature, input, }: IWrappedPlaygroundResultStrategyListProps) => { - const playgroundImprovements = useUiFlag('playgroundImprovements'); const enabledStrategies = feature.strategies?.data?.filter( (strategy) => !strategy.disabled, ); @@ -118,8 +117,7 @@ export const WrappedPlaygroundResultStrategyList = ({ (strategy) => strategy.disabled, ); - const showDisabledStrategies = - playgroundImprovements && disabledStrategies?.length > 0; + const showDisabledStrategies = disabledStrategies?.length > 0; return ( diff --git a/frontend/src/interfaces/uiConfig.ts b/frontend/src/interfaces/uiConfig.ts index 24e07a82a3..f27115dddc 100644 --- a/frontend/src/interfaces/uiConfig.ts +++ b/frontend/src/interfaces/uiConfig.ts @@ -65,7 +65,6 @@ export type UiFlags = { privateProjects?: boolean; dependentFeatures?: boolean; banners?: boolean; - playgroundImprovements?: boolean; scheduledConfigurationChanges?: boolean; featureSearchAPI?: boolean; featureSearchFrontend?: boolean; diff --git a/frontend/src/utils/testRenderer.tsx b/frontend/src/utils/testRenderer.tsx index c9bb09a98e..f4722f68dd 100644 --- a/frontend/src/utils/testRenderer.tsx +++ b/frontend/src/utils/testRenderer.tsx @@ -23,7 +23,9 @@ export const render = ( const Wrapper: FC = ({ children }) => ( - new Map() }}> + new Map(), dedupingInterval: 0 }} + > diff --git a/src/lib/__snapshots__/create-config.test.ts.snap b/src/lib/__snapshots__/create-config.test.ts.snap index 7a0d59fd80..f969200e89 100644 --- a/src/lib/__snapshots__/create-config.test.ts.snap +++ b/src/lib/__snapshots__/create-config.test.ts.snap @@ -98,7 +98,6 @@ exports[`should create default config 1`] = ` }, "migrationLock": true, "personalAccessTokensKillSwitch": false, - "playgroundImprovements": false, "privateProjects": false, "proPlanAutoCharge": false, "responseTimeWithAppNameKillSwitch": false, diff --git a/src/lib/features/feature-toggle/converters/feature-toggle-row-converter.ts b/src/lib/features/feature-toggle/converters/feature-toggle-row-converter.ts index 830bc2511e..4cc23c0867 100644 --- a/src/lib/features/feature-toggle/converters/feature-toggle-row-converter.ts +++ b/src/lib/features/feature-toggle/converters/feature-toggle-row-converter.ts @@ -99,29 +99,16 @@ export class FeatureToggleRowConverter { }; rowToStrategy = (row: Record): IStrategyConfig => { - let strategy: IStrategyConfig; - if (this.flagResolver.isEnabled('playgroundImprovements')) { - strategy = { - id: row.strategy_id, - name: row.strategy_name, - title: row.strategy_title, - constraints: row.constraints || [], - parameters: mapValues(row.parameters || {}, ensureStringValue), - sortOrder: row.sort_order, - disabled: row.strategy_disabled, - }; - } else { - strategy = { - id: row.strategy_id, - name: row.strategy_name, - constraints: row.constraints || [], - parameters: mapValues(row.parameters || {}, ensureStringValue), - sortOrder: row.sort_order, - }; - } - - strategy.variants = row.strategy_variants || []; - return strategy; + return { + id: row.strategy_id, + name: row.strategy_name, + title: row.strategy_title, + constraints: row.constraints || [], + parameters: mapValues(row.parameters || {}, ensureStringValue), + sortOrder: row.sort_order, + disabled: row.strategy_disabled, + variants: row.strategy_variants || [], + }; }; addTag = (feature: Record, row: Record): void => { @@ -160,7 +147,6 @@ export class FeatureToggleRowConverter { row: any, feature: PartialDeep, featureQuery?: IFeatureToggleQuery, - includeDisabledStrategies?: boolean, ) => { feature.impressionData = row.impression_data; feature.enabled = !!row.enabled; @@ -173,10 +159,7 @@ export class FeatureToggleRowConverter { feature.variants = row.variants || []; feature.project = row.project; - if ( - this.isUnseenStrategyRow(feature, row) && - (includeDisabledStrategies ? true : !row.strategy_disabled) - ) { + if (this.isUnseenStrategyRow(feature, row)) { feature.strategies?.push(this.rowToStrategy(row)); } if (this.isNewTag(feature, row)) { @@ -201,12 +184,7 @@ export class FeatureToggleRowConverter { strategies: [], }; - feature = this.createBaseFeature( - r, - feature, - featureQuery, - includeDisabledStrategies, - ); + feature = this.createBaseFeature(r, feature, featureQuery); feature.createdAt = r.created_at; feature.favorite = r.favorite; @@ -225,7 +203,6 @@ export class FeatureToggleRowConverter { buildPlaygroundFeaturesFromRows = ( rows: any[], dependentFeaturesEnabled: boolean, - includeDisabledStrategies: boolean, featureQuery?: IFeatureToggleQuery, ): FeatureConfigurationClient[] => { const result = rows.reduce((acc, r) => { @@ -233,12 +210,7 @@ export class FeatureToggleRowConverter { strategies: [], }; - feature = this.createBaseFeature( - r, - feature, - featureQuery, - includeDisabledStrategies, - ); + feature = this.createBaseFeature(r, feature, featureQuery); if (r.parent && dependentFeaturesEnabled) { feature.dependencies = feature.dependencies || []; diff --git a/src/lib/features/feature-toggle/feature-toggle-store.ts b/src/lib/features/feature-toggle/feature-toggle-store.ts index bc0b6a060a..213adab0b6 100644 --- a/src/lib/features/feature-toggle/feature-toggle-store.ts +++ b/src/lib/features/feature-toggle/feature-toggle-store.ts @@ -211,9 +211,6 @@ export default class FeatureToggleStore implements IFeatureToggleStore { const dependentFeaturesEnabled = this.flagResolver.isEnabled('dependentFeatures'); - const includeDisabledStrategies = this.flagResolver.isEnabled( - 'playgroundImprovements', - ); if (dependentFeaturesEnabled) { builder.withDependentFeatureToggles(); @@ -234,7 +231,6 @@ export default class FeatureToggleStore implements IFeatureToggleStore { return this.featureToggleRowConverter.buildPlaygroundFeaturesFromRows( rows, dependentFeaturesEnabled, - includeDisabledStrategies, featureQuery, ); } diff --git a/src/lib/features/feature-toggle/tests/feature-toggle-service.e2e.test.ts b/src/lib/features/feature-toggle/tests/feature-toggle-service.e2e.test.ts index c27e36f686..351470fbd1 100644 --- a/src/lib/features/feature-toggle/tests/feature-toggle-service.e2e.test.ts +++ b/src/lib/features/feature-toggle/tests/feature-toggle-service.e2e.test.ts @@ -37,11 +37,7 @@ const mockConstraints = (): IConstraint[] => { const irrelevantDate = new Date(); beforeAll(async () => { - const config = createTestConfig({ - experimental: { - flags: { playgroundImprovements: true }, - }, - }); + const config = createTestConfig(); db = await dbInit( 'feature_toggle_service_v2_service_serial', config.getLogger, diff --git a/src/lib/features/playground/advanced-playground.test.ts b/src/lib/features/playground/advanced-playground.test.ts index 6ecab21c1d..7faccdb53c 100644 --- a/src/lib/features/playground/advanced-playground.test.ts +++ b/src/lib/features/playground/advanced-playground.test.ts @@ -12,7 +12,7 @@ let db: ITestDb; beforeAll(async () => { db = await dbInit('advanced_playground', getLogger, { experimental: { - flags: { dependentFeatures: true, playgroundImprovements: true }, + flags: { dependentFeatures: true }, }, }); app = await setupAppWithCustomConfig( @@ -25,7 +25,6 @@ beforeAll(async () => { strategyVariant: true, privateProjects: true, dependentFeatures: true, - playgroundImprovements: true, useLastSeenRefactor: true, }, }, diff --git a/src/lib/types/experimental.ts b/src/lib/types/experimental.ts index e179dcae18..27ca62c44d 100644 --- a/src/lib/types/experimental.ts +++ b/src/lib/types/experimental.ts @@ -28,7 +28,6 @@ export type IFlagKey = | 'disableMetrics' | 'useLastSeenRefactor' | 'banners' - | 'playgroundImprovements' | 'featureSearchAPI' | 'featureSearchFrontend' | 'scheduledConfigurationChanges' @@ -128,10 +127,6 @@ const flags: IFlags = { process.env.UNLEASH_EXPERIMENTAL_USE_LAST_SEEN_REFACTOR, false, ), - playgroundImprovements: parseEnvVarBoolean( - process.env.UNLEASH_EXPERIMENTAL_PLAYGROUND_IMPROVEMENTS, - false, - ), featureSearchAPI: parseEnvVarBoolean( process.env.UNLEASH_EXPERIMENTAL_FEATURE_SEARCH_API, false,