Skip to content

Commit 802f3af

Browse files
authored
fix failing cloudAds unit tests (#4464)
1 parent 38d20f0 commit 802f3af

File tree

6 files changed

+26
-10
lines changed

6 files changed

+26
-10
lines changed

jest.config.cjs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ module.exports = {
6969
},
7070
},
7171
globals: {
72-
riConfig: {}
72+
riConfig: {
73+
cloudAds: {
74+
defaultFlag: true
75+
}
76+
}
7377
}
7478
}

redisinsight/ui/src/components/messages/module-not-loaded-minimalized/ModuleNotLoadedMinimalized.spec.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ describe('ModuleNotLoadedMinimalized', () => {
5959
})
6060

6161
it('should render expected text when cloudAds feature flag is enabled', () => {
62+
mockFeatureFlags({
63+
cloudAds: {
64+
flag: true,
65+
}
66+
})
67+
6268
render(<ModuleNotLoadedMinimalized moduleName={moduleName} source={source} />)
6369

6470
expect(screen.getByText(/Create a free trial Redis Stack database with search and query/)).toBeInTheDocument()

redisinsight/ui/src/components/messages/module-not-loaded/ModuleNotLoaded.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ const ModuleNotLoaded = ({ moduleName, id, type = 'workbench', onClose }: IProps
8585
if (!cloudAdsFeature?.flag) {
8686
return (
8787
<EuiText className={cx(styles.text, styles.marginBottom)}>
88-
Open a database with {moduleName?.toLowerCase()}.
88+
Open a database with {moduleName}.
8989
</EuiText>
9090
)
9191
}

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,12 @@ describe('CreateCloud', () => {
5555
it('should call proper telemetry when sso is disabled', () => {
5656
const sendEventTelemetryMock = jest.fn();
5757
(sendEventTelemetry as jest.Mock).mockImplementation(() => sendEventTelemetryMock);
58-
(appFeatureFlagsFeaturesSelector as jest.Mock).mockReturnValueOnce({
58+
(appFeatureFlagsFeaturesSelector as jest.Mock).mockReturnValue({
5959
cloudSso: {
6060
flag: false
61+
},
62+
cloudAds: {
63+
flag: true
6164
}
6265
})
6366
const { container } = render(<CreateCloud />)

redisinsight/ui/src/pages/home/components/add-database-screen/components/connectivity-options/ConnectivityOptions.spec.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ jest.mock('uiSrc/slices/app/features', () => ({
1717
appFeatureFlagsFeaturesSelector: jest.fn().mockReturnValue({
1818
cloudSso: {
1919
flag: false,
20+
},
21+
cloudAds: {
22+
flag: true,
2023
}
2124
}),
2225
}))
@@ -59,9 +62,12 @@ describe('ConnectivityOptions', () => {
5962
})
6063

6164
it('should call proper actions after click on create cloud btn', () => {
62-
(appFeatureFlagsFeaturesSelector as jest.Mock).mockReturnValueOnce({
65+
(appFeatureFlagsFeaturesSelector as jest.Mock).mockReturnValue({
6366
cloudSso: {
6467
flag: true
68+
},
69+
cloudAds: {
70+
flag: true,
6571
}
6672
})
6773

redisinsight/ui/src/pages/home/components/database-list-header/DatabaseListHeader.spec.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ jest.mock('uiSrc/slices/app/features', () => ({
1515
databaseManagement: {
1616
flag: true,
1717
},
18+
cloudAds: {
19+
flag: true,
20+
}
1821
}),
1922
}))
2023

@@ -59,12 +62,6 @@ describe('DatabaseListHeader', () => {
5962
})
6063

6164
it('should show promo cloud button with enabled feature flag', () => {
62-
(appFeatureFlagsFeaturesSelector as jest.Mock).mockReturnValueOnce({
63-
enhancedCloudUI: {
64-
flag: false
65-
}
66-
})
67-
6865
render(<DatabaseListHeader {...instance(mockedProps)} />)
6966

7067
expect(screen.getByTestId('promo-btn')).toBeInTheDocument()

0 commit comments

Comments
 (0)