Skip to content

Commit a37f575

Browse files
committed
#RI-4814 - fix pr comments
1 parent b40c788 commit a37f575

File tree

3 files changed

+87
-84
lines changed

3 files changed

+87
-84
lines changed

redisinsight/ui/src/components/oauth/oauth-select-plan/OAuthSelectPlan.spec.tsx

Lines changed: 3 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { cleanup, fireEvent, mockedStore, render, within } from 'uiSrc/utils/tes
44
import { TelemetryEvent, sendEventTelemetry } from 'uiSrc/telemetry'
55
import { addFreeDb, oauthCloudPlanSelector, oauthCloudSelector, initialState } from 'uiSrc/slices/oauth/cloud'
66
import { OAuthSocialSource } from 'uiSrc/slices/interfaces'
7+
import { MOCK_NO_TF_REGION, MOCK_REGIONS } from 'uiSrc/constants/mocks/mock-sso'
78
import OAuthSelectPlan from './OAuthSelectPlan'
89

910
jest.mock('uiSrc/telemetry', () => ({
@@ -48,87 +49,6 @@ jest.mock('uiSrc/slices/app/features', () => ({
4849
}),
4950
}))
5051

51-
const mockNoTFRegion = {
52-
id: 12148,
53-
type: 'fixed',
54-
name: 'Cache 30MB',
55-
provider: 'AWS',
56-
price: 0,
57-
region: 'eu-west-1',
58-
regionId: 4,
59-
details: {
60-
id: 4,
61-
name: 'eu-west-1',
62-
cloud: 'AWS',
63-
displayOrder: 4,
64-
countryName: 'Europe',
65-
cityName: 'Ireland',
66-
regionId: 4,
67-
flag: 'ie'
68-
}
69-
}
70-
71-
const mockRegions = [
72-
mockNoTFRegion,
73-
{
74-
id: 12150,
75-
type: 'fixed',
76-
name: 'Cache 30MB',
77-
provider: 'AWS',
78-
price: 0,
79-
region: 'ap-southeast-1',
80-
regionId: 5,
81-
details: {
82-
id: 5,
83-
name: 'ap-southeast-1',
84-
cloud: 'AWS',
85-
displayOrder: 7,
86-
countryName: 'Asia Pacific',
87-
cityName: 'Singapore',
88-
regionId: 5,
89-
flag: 'sg'
90-
}
91-
},
92-
{
93-
id: 12152,
94-
type: 'fixed',
95-
name: 'Cache 30MB',
96-
provider: 'Azure',
97-
price: 0,
98-
region: 'east-us',
99-
regionId: 16,
100-
details: {
101-
id: 16,
102-
name: 'east-us',
103-
cloud: 'Azure',
104-
displayOrder: 10,
105-
countryName: 'East US',
106-
cityName: 'Virginia',
107-
regionId: 16,
108-
flag: 'us'
109-
}
110-
},
111-
{
112-
id: 12153,
113-
type: 'fixed',
114-
name: 'Cache 30MB',
115-
provider: 'GCP',
116-
price: 0,
117-
region: 'us-central1',
118-
regionId: 27,
119-
details: {
120-
id: 27,
121-
name: 'us-central1',
122-
cloud: 'GCP',
123-
displayOrder: 17,
124-
countryName: 'North America',
125-
cityName: 'Iowa',
126-
regionId: 27,
127-
flag: 'us'
128-
}
129-
}
130-
]
131-
13252
let store: typeof mockedStore
13353
beforeEach(() => {
13454
cleanup()
@@ -140,7 +60,7 @@ describe('OAuthSelectPlan', () => {
14060
beforeEach(() => {
14161
(oauthCloudPlanSelector as jest.Mock).mockReturnValue({
14262
isOpenDialog: true,
143-
data: mockRegions,
63+
data: MOCK_REGIONS,
14464
})
14565
})
14666

@@ -204,7 +124,7 @@ describe('OAuthSelectPlan', () => {
204124
it('should display text if no Trigger and Function regions available on this vendor', async () => {
205125
(oauthCloudPlanSelector as jest.Mock).mockReturnValue({
206126
isOpenDialog: true,
207-
data: [mockNoTFRegion],
127+
data: [MOCK_NO_TF_REGION],
208128
})
209129

210130
const { queryByTestId } = render(<OAuthSelectPlan />)

redisinsight/ui/src/components/oauth/oauth-select-plan/OAuthSelectPlan.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ const OAuthSelectPlan = () => {
123123
}
124124
)
125125

126+
const isVendorWithTFRegions = !!regionOptions.length
127+
&& !plans.some(({ region = '' }) => tfProviderRegions?.includes(region))
128+
126129
const onChangeRegion = (region: string) => {
127130
setPlanIdSelected(region)
128131
}
@@ -172,7 +175,7 @@ const OAuthSelectPlan = () => {
172175
onChange={onChangeRegion}
173176
data-testid="select-oauth-region"
174177
/>
175-
{!!regionOptions.length && !plans.some(({ region = '' }) => tfProviderRegions?.includes(region)) && (
178+
{isVendorWithTFRegions && (
176179
<EuiText className={styles.selectDescription} data-testid="select-region-select-description">
177180
This vendor does not support triggers and functions capability.
178181
</EuiText>
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
export const MOCK_NO_TF_REGION = {
2+
id: 12148,
3+
type: 'fixed',
4+
name: 'Cache 30MB',
5+
provider: 'AWS',
6+
price: 0,
7+
region: 'eu-west-1',
8+
regionId: 4,
9+
details: {
10+
id: 4,
11+
name: 'eu-west-1',
12+
cloud: 'AWS',
13+
displayOrder: 4,
14+
countryName: 'Europe',
15+
cityName: 'Ireland',
16+
regionId: 4,
17+
flag: 'ie'
18+
}
19+
}
20+
21+
export const MOCK_REGIONS = [
22+
MOCK_NO_TF_REGION,
23+
{
24+
id: 12150,
25+
type: 'fixed',
26+
name: 'Cache 30MB',
27+
provider: 'AWS',
28+
price: 0,
29+
region: 'ap-southeast-1',
30+
regionId: 5,
31+
details: {
32+
id: 5,
33+
name: 'ap-southeast-1',
34+
cloud: 'AWS',
35+
displayOrder: 7,
36+
countryName: 'Asia Pacific',
37+
cityName: 'Singapore',
38+
regionId: 5,
39+
flag: 'sg'
40+
}
41+
},
42+
{
43+
id: 12152,
44+
type: 'fixed',
45+
name: 'Cache 30MB',
46+
provider: 'Azure',
47+
price: 0,
48+
region: 'east-us',
49+
regionId: 16,
50+
details: {
51+
id: 16,
52+
name: 'east-us',
53+
cloud: 'Azure',
54+
displayOrder: 10,
55+
countryName: 'East US',
56+
cityName: 'Virginia',
57+
regionId: 16,
58+
flag: 'us'
59+
}
60+
},
61+
{
62+
id: 12153,
63+
type: 'fixed',
64+
name: 'Cache 30MB',
65+
provider: 'GCP',
66+
price: 0,
67+
region: 'us-central1',
68+
regionId: 27,
69+
details: {
70+
id: 27,
71+
name: 'us-central1',
72+
cloud: 'GCP',
73+
displayOrder: 17,
74+
countryName: 'North America',
75+
cityName: 'Iowa',
76+
regionId: 27,
77+
flag: 'us'
78+
}
79+
}
80+
]

0 commit comments

Comments
 (0)