Skip to content

Commit

Permalink
circular dep, test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewazores committed Dec 16, 2022
1 parent cf5e30a commit 18859f6
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/app/AppLayout/AppLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ import cryostatLogo from '@app/assets/cryostat_logo_hori_rgb_reverse.svg';
import { SessionState } from '@app/Shared/Services/Login.service';
import { NotificationCategory } from '@app/Shared/Services/NotificationChannel.service';
import { useSubscriptions } from '@app/utils/useSubscriptions';
import { FeatureFlag, FeatureLevel } from '@app/Shared/FeatureFlag/FeatureFlag';
import { FeatureLevel } from '@app/Shared/Services/Settings.service';
import { FeatureFlag } from '@app/Shared/FeatureFlag/FeatureFlag';

interface IAppLayout {
children: React.ReactNode;
Expand Down
2 changes: 1 addition & 1 deletion src/app/Settings/FeatureLevels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import * as React from 'react';
import { ServiceContext } from '@app/Shared/Services/Services';
import { useSubscriptions } from '@app/utils/useSubscriptions';
import { UserSetting } from './Settings';
import { FeatureLevel } from '@app/Shared/FeatureFlag/FeatureFlag';
import { FeatureLevel } from '@app/Shared/Services/Settings.service';
import { Select, SelectOption } from '@patternfly/react-core';

const Component = () => {
Expand Down
7 changes: 1 addition & 6 deletions src/app/Shared/FeatureFlag/FeatureFlag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,9 @@
*/
import * as React from 'react';
import { ServiceContext } from '@app/Shared/Services/Services';
import { FeatureLevel } from '@app/Shared/Services/Settings.service';
import { useSubscriptions } from '@app/utils/useSubscriptions';

export enum FeatureLevel {
DEVELOPMENT = 0,
BETA = 1,
PRODUCTION = 2,
}

export interface FeatureFlagProps {
level: FeatureLevel;
children?: React.ReactNode | undefined;
Expand Down
7 changes: 6 additions & 1 deletion src/app/Shared/Services/Settings.service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import { DeleteWarningType } from '@app/Modal/DeleteWarningUtils';
import { getFromLocalStorage, saveToLocalStorage } from '@app/utils/LocalStorage';
import { BehaviorSubject, Observable } from 'rxjs';
import { FeatureLevel } from '@app/Shared/FeatureFlag/FeatureFlag';
import {
AutomatedAnalysisRecordingConfig,
automatedAnalysisRecordingName,
Expand All @@ -48,6 +47,12 @@ import {
} from './Api.service';
import { NotificationCategory } from './NotificationChannel.service';

export enum FeatureLevel {
DEVELOPMENT = 0,
BETA = 1,
PRODUCTION = 2,
}

export function enumKeys<O extends Object, K extends keyof O = keyof O>(obj: O): K[] {
return Object.keys(obj).filter((k) => Number.isNaN(+k)) as K[];
}
Expand Down
8 changes: 8 additions & 0 deletions src/test/Settings/Settings.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,14 @@ jest.mock('@app/Settings/AutoRefresh', () => ({
},
}));

jest.mock('@app/Settings/FeatureLevels', () => ({
FeatureLevels: {
title: 'Feature Levels Title',
description: 'Feature Levels Description',
content: () => <Text>Feature Levels Component</Text>,
},
}));

describe('<Settings/>', () => {
afterEach(cleanup);

Expand Down
47 changes: 47 additions & 0 deletions src/test/Settings/__snapshots__/Settings.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,53 @@ exports[`<Settings/> renders correctly 1`] = `
</div>
</article>
</div>
<div
className="pf-l-stack__item"
>
<article
className="pf-c-card"
data-ouia-component-id="OUIA-Generated-Card-7"
data-ouia-component-type="PF4/Card"
data-ouia-safe={true}
id=""
>
<div
className="pf-c-card__title"
>
<p
className=""
data-ouia-component-id="OUIA-Generated-Text-19"
data-ouia-component-type="PF4/Text"
data-ouia-safe={true}
data-pf-content={true}
>
Feature Levels Title
</p>
<small
className=""
data-ouia-component-id="OUIA-Generated-Text-20"
data-ouia-component-type="PF4/Text"
data-ouia-safe={true}
data-pf-content={true}
>
Feature Levels Description
</small>
</div>
<div
className="pf-c-card__body"
>
<p
className=""
data-ouia-component-id="OUIA-Generated-Text-21"
data-ouia-component-type="PF4/Text"
data-ouia-safe={true}
data-pf-content={true}
>
Feature Levels Component
</p>
</div>
</article>
</div>
</div>
</section>
`;

0 comments on commit 18859f6

Please sign in to comment.