Skip to content

Commit 1482270

Browse files
committed
wrap the create cloud component inside sidebar when rendering
1 parent 5f16606 commit 1482270

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

redisinsight/ui/src/components/navigation-menu/components/create-cloud/CreateCloud.spec.tsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { appFeatureFlagsFeaturesSelector } from 'uiSrc/slices/app/features'
99
import { sendEventTelemetry } from 'uiSrc/telemetry'
1010
import { HELP_LINKS } from 'uiSrc/pages/home/constants'
1111
import * as appFeaturesSlice from 'uiSrc/slices/app/features'
12+
import { SideBar } from 'uiSrc/components/base/layout/sidebar'
1213
import CreateCloud from './CreateCloud'
1314

1415
jest.mock('uiSrc/telemetry', () => ({
@@ -37,15 +38,17 @@ beforeEach(() => {
3738
store.clearActions()
3839
})
3940

41+
const sideBarWithCreateCloud = <SideBar isExpanded={false}><CreateCloud /></SideBar>
42+
4043
describe('CreateCloud', () => {
4144
it('should render', () => {
42-
expect(render(<CreateCloud />)).toBeTruthy()
45+
expect(render(sideBarWithCreateCloud)).toBeTruthy()
4346
})
4447

4548
it('should call proper actions on click cloud button', () => {
46-
const { container } = render(<CreateCloud />)
49+
const { container } = render(sideBarWithCreateCloud)
4750
const createCloudLink = container.querySelector(
48-
'[data-test-subj="create-cloud-nav-link"]',
51+
'[data-testid="create-cloud-sidebar-item"]',
4952
)
5053

5154
fireEvent.click(createCloudLink as Element)
@@ -69,9 +72,9 @@ describe('CreateCloud', () => {
6972
flag: true,
7073
},
7174
})
72-
const { container } = render(<CreateCloud />)
75+
const { container } = render(sideBarWithCreateCloud)
7376
const createCloudLink = container.querySelector(
74-
'[data-test-subj="create-cloud-nav-link"]',
77+
'[data-testid="create-cloud-sidebar-item"]',
7578
)
7679

7780
fireEvent.click(createCloudLink as Element)
@@ -86,7 +89,10 @@ describe('CreateCloud', () => {
8689

8790
it('should not render if cloud ads feature flag is disabled', () => {
8891
mockFeatureFlags(false)
89-
const { container } = render(<CreateCloud />)
90-
expect(container).toBeEmptyDOMElement()
92+
const { container } = render(sideBarWithCreateCloud)
93+
const createCloudLink = container.querySelector(
94+
'[data-testid="create-cloud-db-link"]',
95+
)
96+
expect(createCloudLink).not.toBeInTheDocument()
9197
})
9298
})

redisinsight/ui/src/components/navigation-menu/components/create-cloud/CreateCloud.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const CreateCloud = () => {
3434
campaign: 'navigation_menu',
3535
})}
3636
style={{ marginInline: 'auto', backgroundColor: 'transparent' }}
37+
data-testid="create-cloud-db-link"
3738
>
3839
<SideBarItem
3940
tooltipProps={{
@@ -47,8 +48,8 @@ const CreateCloud = () => {
4748
action: OAuthSocialAction.Create,
4849
})
4950
}}
50-
data-test-subj="create-cloud-nav-link"
5151
style={{ marginInline: 'auto' }}
52+
data-testid="create-cloud-sidebar-item"
5253
>
5354
<SideBarItemIcon
5455
width="20px"

0 commit comments

Comments
 (0)