-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCOGViewerDrawer.test.tsx
385 lines (345 loc) · 11.8 KB
/
COGViewerDrawer.test.tsx
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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
import { expect, test } from '@/__tests__/playwright/setup-msw';
import { HttpResponse } from 'msw';
test.describe('COG Viewer Drawer', () => {
test('COG Viewer loads with renders object presets', async ({
page,
}, testInfo) => {
await test.step('navigate to create ingest page', async () => {
await page.goto('/create-ingest');
});
await test.step('enter URL of Sample File and valid json in renders object', async () => {
await page.getByLabel('Sample Files-1').fill('s3://test.com');
await page.getByLabel('dashboard').fill(
JSON.stringify(
{
resampling: 'nearest',
bidx: [1],
colormap_name: 'rdbu',
assets: ['cog_default'],
rescale: [[-1, 1]],
color_formula: 'test123',
nodata: 255,
title: 'VEDA Dashboard Render Parameters',
},
null,
2
)
);
});
const initialRendersScreenshot = await page.screenshot({ fullPage: true });
testInfo.attach('Initial Renders Object', {
body: initialRendersScreenshot,
contentType: 'image/png',
});
await test.step('click button to open COG Viewer Drawer', async () => {
await page
.getByRole('button', {
name: /Generate Renders Object from Sample File/i,
})
.click();
});
await expect(
page.getByText('Band: Band 1 (Index: 1)'),
'multi-band COGs should not have Band Name Header'
).toBeHidden();
await test.step('validate that RGB Band Dropdowns are visible and populated with first 3 bands', async () => {
await expect(page.getByLabel('Band (R)')).toBeVisible();
await expect(page.locator('[data-testid="band-R"]')).toContainText(
'b1 - Band 1'
);
await expect(page.getByLabel('Band (G)')).toBeVisible();
await expect(page.locator('[data-testid="band-G"]')).toContainText(
'b2 - Band 2'
);
await expect(page.getByLabel('Band (B)')).toBeVisible();
await expect(page.locator('[data-testid="band-B"]')).toContainText(
'b3 - Band 3'
);
});
await test.step('validate that form controls pre-populate with values from renders object', async () => {
await expect(page.locator('[data-testid="colormap"]')).toContainText(
'rdbu'
);
await expect(page.locator('[data-testid="resampling"]')).toContainText(
/nearest/i
);
await expect(page.locator('[data-testid="colorFormula"]')).toHaveValue(
/test123/i
);
await expect(page.locator('[data-testid="nodata"]')).toHaveValue(/255/i);
});
const prepopulatedControlsScreenshot = await page.screenshot();
testInfo.attach('Pre-populated COG Viewer Form Controls', {
body: prepopulatedControlsScreenshot,
contentType: 'image/png',
});
await test.step('validate that Rendering Options Modal displays values in form in pretty json format', async () => {
await page
.getByRole('button', { name: 'View Rendering Options' })
.click();
await expect(
page.getByRole('dialog', { name: /COG Rendering Options/i })
).toBeVisible();
await expect(page.locator('.ant-modal-body')).toHaveText(
JSON.stringify(
{
bidx: [1],
rescale: [[-1, 1]],
colormap_name: 'rdbu',
color_formula: 'test123',
resampling: 'nearest',
nodata: 255,
assets: ['cog_default'],
},
null,
2
)
);
});
const renderingOptionsModalScreenshot = await page.screenshot();
testInfo.attach('Rendering Options Modal', {
body: renderingOptionsModalScreenshot,
contentType: 'image/png',
});
});
test('COG Viewer loads without entry in renders object', async ({
page,
}, testInfo) => {
await test.step('navigate to create ingest page', async () => {
await page.goto('/create-ingest');
});
await test.step('enter URL of Sample File but no renders object', async () => {
await page.getByLabel('Sample Files-1').fill('s3://test.com');
});
await test.step('click button to open COG Viewer Drawer', async () => {
await page
.getByRole('button', {
name: /Generate Renders Object from Sample File/i,
})
.click();
});
await test.step('validate that form controls pre-populate with default values', async () => {
await expect(page.locator('[data-testid="colormap"]')).toContainText(
'Internal'
);
await expect(page.locator('[data-testid="resampling"]')).toContainText(
''
);
await expect(page.locator('[data-testid="colorFormula"]')).toHaveValue(
''
);
await expect(page.locator('[data-testid="nodata"]')).toHaveValue('');
});
const defaultControlsScreenshot = await page.screenshot();
testInfo.attach('Default state of COG Viewer Form Controls', {
body: defaultControlsScreenshot,
contentType: 'image/png',
});
await test.step('validate that Rendering Options Modal displays default values in form in pretty json format', async () => {
await page
.getByRole('button', { name: 'View Rendering Options' })
.click();
await expect(
page.getByRole('dialog', { name: /COG Rendering Options/i })
).toBeVisible();
await expect(page.locator('.ant-modal-body')).toHaveText(
JSON.stringify(
{
bidx: [1],
rescale: [],
assets: ['cog_default'],
},
null,
2
)
);
});
});
test('COG Viewer loads with error in renders object presets', async ({
page,
}) => {
await test.step('navigate to create ingest page', async () => {
await page.goto('/create-ingest');
});
await test.step('enter URL of Sample File and invalid json in renders object', async () => {
await page.getByLabel('Sample Files-1').fill('s3://test.com');
await page.getByLabel('dashboard').fill('"test": true');
});
await test.step('click button to open COG Viewer Drawer', async () => {
await page
.getByRole('button', {
name: /Generate Renders Object from Sample File/i,
})
.click();
});
await test.step('validate that form controls pre-populate with default values', async () => {
await expect(page.locator('[data-testid="colormap"]')).toContainText(
'Internal'
);
await expect(page.locator('[data-testid="resampling"]')).toContainText(
''
);
await expect(page.locator('[data-testid="colorFormula"]')).toHaveValue(
''
);
await expect(page.locator('[data-testid="nodata"]')).toHaveValue('');
});
await test.step('validate that Rendering Options Modal displays default values in form in pretty json format', async () => {
await page
.getByRole('button', { name: 'View Rendering Options' })
.click();
await expect(
page.getByRole('dialog', { name: /COG Rendering Options/i })
).toBeVisible();
await expect(page.locator('.ant-modal-body')).toHaveText(
JSON.stringify(
{
bidx: [1],
rescale: [],
assets: ['cog_default'],
},
null,
2
)
);
});
});
test('COG Viewer overwrites existing renders object with selections', async ({
page,
}) => {
await test.step('navigate to create ingest page', async () => {
await page.goto('/create-ingest');
});
await test.step('enter URL of Sample File and valid json in renders object', async () => {
await page.getByLabel('Sample Files-1').fill('s3://test.com');
await page.getByLabel('dashboard').fill(
JSON.stringify(
{
resampling: 'nearest',
bidx: [1],
colormap_name: 'rdbu',
assets: ['cog_default'],
rescale: [[-1, 1]],
color_formula: 'test123',
nodata: 255,
title: 'VEDA Dashboard Render Parameters',
},
null,
2
)
);
});
await test.step('click button to open COG Viewer Drawer', async () => {
await page
.getByRole('button', {
name: /Generate Renders Object from Sample File/i,
})
.click();
});
await test.step('change renders values in COG Viewer Control Form', async () => {
await expect(page.locator('[data-testid="colormap"]')).toContainText(
'rdbu'
);
await expect(page.locator('[data-testid="nodata"]')).toHaveValue('255');
await page.locator('[data-testid="nodata"]').fill('');
await expect(page.locator('[data-testid="colorFormula"]')).toHaveValue(
/test123/i
);
await page.locator('[data-testid="colorFormula"]').fill('test456');
});
await test.step('validate that Rendering Options Modal displays new values in form in pretty json format', async () => {
await page
.getByRole('button', { name: 'View Rendering Options' })
.click();
await expect(
page.getByRole('dialog', { name: /COG Rendering Options/i })
).toBeVisible();
await expect(page.locator('.ant-modal-body')).toHaveText(
JSON.stringify(
{
bidx: [1],
rescale: [[-1, 1]],
colormap_name: 'rdbu',
color_formula: 'test456',
resampling: 'nearest',
assets: ['cog_default'],
},
null,
2
)
);
});
await test.step('close COG Rendering Options Modal', async () => {
await page
.getByLabel('COG Rendering Options')
.getByRole('button', { name: 'Cancel' })
.click();
});
await test.step('click to accept selected COG Rendering Options', async () => {
await page
.getByRole('button', { name: /accept render options/i })
.click();
});
await test.step('validate that renders object has updated with new values', async () => {
await expect(page.getByLabel('Dashboard')).toHaveText(
JSON.stringify(
{
bidx: [1],
rescale: [[-1, 1]],
colormap_name: 'rdbu',
color_formula: 'test456',
resampling: 'nearest',
assets: ['cog_default'],
},
null,
2
)
);
});
});
test('COG Viewer does not open if sample files input is empty', async ({
page,
}, testInfo) => {
await test.step('navigate to create ingest page', async () => {
await page.goto('/create-ingest');
});
await test.step('do not enter URL of Sample File but enter valid json in renders object', async () => {
await page.getByLabel('dashboard').fill(
JSON.stringify(
{
resampling: 'nearest',
bidx: [1],
colormap_name: 'rdbu',
assets: ['cog_default'],
rescale: [[-1, 1]],
color_formula: 'test123',
nodata: 255,
title: 'VEDA Dashboard Render Parameters',
},
null,
2
)
);
});
await test.step('click button to open COG Viewer Drawer', async () => {
await page
.getByRole('button', {
name: /Generate Renders Object from Sample File/i,
})
.click();
});
await expect(
page.getByText(/Sample File URL is required/i),
'verify error message appears'
).toBeVisible();
await expect(
page.locator('.ant-drawer').filter({ hasText: /COG Rendering Options/i }),
'COG Viewer Drawer remains hidden'
).toBeHidden();
const errorScreenshot = await page.screenshot();
testInfo.attach('error message if no sample file url present', {
body: errorScreenshot,
contentType: 'image/png',
});
});
});