-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathImageOverview.test.tsx
More file actions
278 lines (229 loc) · 8.12 KB
/
ImageOverview.test.tsx
File metadata and controls
278 lines (229 loc) · 8.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
import React from 'react';
import { screen } from '@testing-library/react';
import { RHEL_10, X86_64 } from '@/constants';
import { renderWithRedux } from '@/test/testUtils';
import { adminUser } from '../../AdvancedSettings/tests/mocks';
import ImageOverview from '../index';
describe('ImageOverview', () => {
test('renders the card with image overview title', () => {
renderWithRedux(<ImageOverview />);
expect(screen.getByText('Image overview')).toBeInTheDocument();
});
test('displays the blueprint name', () => {
renderWithRedux(<ImageOverview />, {
details: {
blueprintName: 'my-test-blueprint',
blueprintDescription: '',
isCustomName: true,
},
});
expect(screen.getByText('Name')).toBeInTheDocument();
expect(screen.getByText('my-test-blueprint')).toBeInTheDocument();
});
test('displays the blueprint description', () => {
renderWithRedux(<ImageOverview />, {
details: {
blueprintName: 'test-blueprint',
blueprintDescription: 'This is a test description',
isCustomName: true,
},
});
expect(screen.getByText('Details')).toBeInTheDocument();
expect(screen.getByText('This is a test description')).toBeInTheDocument();
});
test('displays the base release for package mode', () => {
renderWithRedux(<ImageOverview />, {
distribution: RHEL_10,
blueprintMode: 'package',
});
expect(screen.getByText('Base release')).toBeInTheDocument();
expect(
screen.getByText('Red Hat Enterprise Linux (RHEL) 10'),
).toBeInTheDocument();
});
test('displays the architecture', () => {
renderWithRedux(<ImageOverview />, {
architecture: X86_64,
});
expect(screen.getByText('Architecture')).toBeInTheDocument();
expect(screen.getByText(X86_64)).toBeInTheDocument();
});
test('displays target environments heading', () => {
renderWithRedux(<ImageOverview />);
expect(screen.getByText('Target environments')).toBeInTheDocument();
});
describe('Private clouds', () => {
test('displays vsphere when selected', () => {
renderWithRedux(<ImageOverview />, {
imageTypes: ['vsphere'],
});
expect(screen.getByText('Private cloud')).toBeInTheDocument();
expect(screen.getByText('VMware vSphere (.vmdk)')).toBeInTheDocument();
});
test('displays vsphere-ova when selected', () => {
renderWithRedux(<ImageOverview />, {
imageTypes: ['vsphere-ova'],
});
expect(screen.getByText('Private cloud')).toBeInTheDocument();
expect(screen.getByText('VMware vSphere (.ova)')).toBeInTheDocument();
});
test('displays multiple private clouds when selected', () => {
renderWithRedux(<ImageOverview />, {
imageTypes: ['vsphere', 'vsphere-ova'],
});
expect(screen.getByText('VMware vSphere (.vmdk)')).toBeInTheDocument();
expect(screen.getByText('VMware vSphere (.ova)')).toBeInTheDocument();
});
test('does not display private cloud section when none selected', () => {
renderWithRedux(<ImageOverview />, {
imageTypes: ['aws'],
});
expect(screen.queryByText('Private cloud')).not.toBeInTheDocument();
});
});
describe('Public clouds', () => {
test('displays AWS details when selected', () => {
renderWithRedux(<ImageOverview />, {
imageTypes: ['aws'],
aws: {
accountId: '123456789012',
shareMethod: 'manual',
source: undefined,
region: 'us-west-2',
},
});
expect(screen.getByText('Public cloud')).toBeInTheDocument();
expect(screen.getByText('Amazon Web Services')).toBeInTheDocument();
expect(
screen.getByText(/Shared with account: 123456789012/),
).toBeInTheDocument();
expect(screen.getByText(/Region: us-west-2/)).toBeInTheDocument();
});
test('displays GCP details when selected', () => {
renderWithRedux(<ImageOverview />, {
imageTypes: ['gcp'],
gcp: {
accountType: 'user',
email: 'test@example.com',
},
});
expect(screen.getByText('Google Cloud')).toBeInTheDocument();
expect(
screen.getByText(/Account type: Google account/),
).toBeInTheDocument();
expect(
screen.getByText(/Principal: test@example.com/),
).toBeInTheDocument();
});
test('displays Azure details when selected', () => {
renderWithRedux(<ImageOverview />, {
imageTypes: ['azure'],
azure: {
tenantId: 'tenant-123',
subscriptionId: 'sub-456',
resourceGroup: 'my-resource-group',
hyperVGeneration: 'V2',
},
});
expect(screen.getByText('Microsoft Azure')).toBeInTheDocument();
expect(screen.getByText(/Tenant ID: tenant-123/)).toBeInTheDocument();
expect(screen.getByText(/Subscription ID: sub-456/)).toBeInTheDocument();
expect(
screen.getByText(/Resource group: my-resource-group/),
).toBeInTheDocument();
});
test('displays OCI when selected', () => {
renderWithRedux(<ImageOverview />, {
imageTypes: ['oci'],
});
expect(
screen.getByText('Oracle Cloud Infrastructure'),
).toBeInTheDocument();
});
test('does not display public cloud section when none selected', () => {
renderWithRedux(<ImageOverview />, {
imageTypes: ['vsphere'],
});
expect(screen.queryByText('Public cloud')).not.toBeInTheDocument();
});
});
describe('Miscellaneous formats', () => {
test('displays guest-image when selected', () => {
renderWithRedux(<ImageOverview />, {
imageTypes: ['guest-image'],
});
expect(screen.getByText('Miscellaneous formats')).toBeInTheDocument();
expect(screen.getByText('Virtualization (.qcow2)')).toBeInTheDocument();
});
test('displays image-installer when selected', () => {
renderWithRedux(<ImageOverview />, {
imageTypes: ['image-installer'],
});
expect(screen.getByText('Baremetal (.iso)')).toBeInTheDocument();
});
test('displays wsl when selected', () => {
renderWithRedux(<ImageOverview />, {
imageTypes: ['wsl'],
});
expect(
screen.getByText('Windows Subsystem for Linux (.tar.gz)'),
).toBeInTheDocument();
});
test('displays multiple misc formats when selected', () => {
renderWithRedux(<ImageOverview />, {
imageTypes: ['guest-image', 'image-installer', 'wsl'],
});
expect(screen.getByText('Virtualization (.qcow2)')).toBeInTheDocument();
expect(screen.getByText('Baremetal (.iso)')).toBeInTheDocument();
expect(
screen.getByText('Windows Subsystem for Linux (.tar.gz)'),
).toBeInTheDocument();
});
test('does not display misc formats section when none selected', () => {
renderWithRedux(<ImageOverview />, {
imageTypes: ['aws'],
});
expect(
screen.queryByText('Miscellaneous formats'),
).not.toBeInTheDocument();
});
});
describe('Users', () => {
test('displays users section in on-prem image mode', () => {
renderWithRedux(
<ImageOverview />,
{
imageTypes: ['guest-image'],
blueprintMode: 'image',
users: [adminUser],
},
{
preloadedState: { env: { isOnPremise: true } },
},
);
expect(screen.getByText('Users')).toBeInTheDocument();
expect(screen.getByText('admin')).toBeInTheDocument();
});
test('does not display users section in hosted mode', () => {
renderWithRedux(<ImageOverview />, {
imageTypes: ['guest-image'],
users: [adminUser],
});
expect(screen.queryByText('Users')).not.toBeInTheDocument();
});
test('does not display users section in on-prem package mode', () => {
renderWithRedux(
<ImageOverview />,
{
imageTypes: ['guest-image'],
blueprintMode: 'package',
users: [adminUser],
},
{
preloadedState: { env: { isOnPremise: true } },
},
);
expect(screen.queryByText('Users')).not.toBeInTheDocument();
});
});
});