Skip to content

Commit c2991dd

Browse files
committed
wrap PSUBSCRIBE_COMMAND output with FeatureFlagComponent
1 parent a9e672e commit c2991dd

File tree

2 files changed

+44
-7
lines changed

2 files changed

+44
-7
lines changed

redisinsight/ui/src/components/messages/cli-output/cliOutput.spec.tsx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,37 @@ describe('cliTexts', () => {
7272
expect(screen.queryByTestId('user-pub-sub-link-disabled')).not.toBeInTheDocument()
7373
})
7474
})
75+
76+
describe('PSUBSCRIBE_COMMAND_CLI', () => {
77+
it('should render proper content with flag disabled', async () => {
78+
const initialStoreState = set(
79+
cloneDeep(initialStateDefault),
80+
`app.features.featureFlags.features.${FeatureFlags.envDependent}`,
81+
{ flag: false }
82+
)
83+
84+
render(cliTexts.PSUBSCRIBE_COMMAND(), {
85+
store: mockStore(initialStoreState)
86+
})
87+
88+
expect(screen.getByTestId('user-pub-sub-link-disabled')).toBeInTheDocument()
89+
expect(screen.queryByTestId('user-pub-sub-link')).not.toBeInTheDocument()
90+
})
91+
92+
it('should render proper content with flag enabled', () => {
93+
const initialStoreState = set(
94+
cloneDeep(initialStateDefault),
95+
`app.features.featureFlags.features.${FeatureFlags.envDependent}`,
96+
{ flag: true }
97+
)
98+
99+
render(cliTexts.PSUBSCRIBE_COMMAND(), {
100+
store: mockStore(initialStoreState)
101+
})
102+
103+
expect(screen.getByTestId('user-pub-sub-link')).toBeInTheDocument()
104+
expect(screen.queryByTestId('user-pub-sub-link-disabled')).not.toBeInTheDocument()
105+
})
106+
})
75107
})
76108
})

redisinsight/ui/src/components/messages/cli-output/cliOutput.tsx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,25 @@ export const cliTexts = {
5555
REPEAT_COUNT_INVALID: 'Invalid repeat command option value',
5656
CONNECTION_CLOSED: 'Client connection previously closed. Run the command after the connection is re-created.',
5757
UNABLE_TO_DECRYPT: 'Unable to decrypt. Check the system keychain or re-run the command.',
58-
PSUBSCRIBE_COMMAND: (path: string = '') => (
59-
<EuiTextColor color="danger" key={Date.now()}>
58+
PUB_SUB_NOT_SUPPORTED_ENV: (
59+
<div className="cli-output-response-fail" data-testid="user-pub-sub-link-disabled">
60+
PubSub not supported in this environment.
61+
</div>
62+
),
63+
USE_PSUBSCRIBE_COMMAND: (path: string = '') => (
64+
<EuiTextColor color="danger" key={Date.now()} data-testid="user-pub-sub-link">
6065
{'Use '}
6166
<EuiLink {...getRouterLinkProps(path)} color="text" data-test-subj="pubsub-page-btn">
6267
Pub/Sub
6368
</EuiLink>
6469
{' to see the messages published to all channels in your database.'}
6570
</EuiTextColor>
6671
),
72+
PSUBSCRIBE_COMMAND: (path: string = '') => (
73+
<FeatureFlagComponent name={FeatureFlags.envDependent} otherwise={cliTexts.PUB_SUB_NOT_SUPPORTED_ENV}>
74+
{cliTexts.USE_PSUBSCRIBE_COMMAND(path)}
75+
</FeatureFlagComponent>
76+
),
6777
PSUBSCRIBE_COMMAND_CLI: (path: string = '') => (
6878
[
6979
cliTexts.PSUBSCRIBE_COMMAND(path),
@@ -92,11 +102,6 @@ export const cliTexts = {
92102
{cliTexts.USE_PROFILER_TOOL(onClick)}
93103
</FeatureFlagComponent>
94104
),
95-
PUB_SUB_NOT_SUPPORTED_ENV: (
96-
<div className="cli-output-response-fail" data-testid="user-pub-sub-link-disabled">
97-
PubSub not supported in this environment.
98-
</div>
99-
),
100105
USE_PUB_SUB_TOOL: (path: string = '') => (
101106
<EuiTextColor color="danger" key={Date.now()} data-testid="user-pub-sub-link">
102107
{'Use '}

0 commit comments

Comments
 (0)