-
-
Notifications
You must be signed in to change notification settings - Fork 4k
/
test_organization_dashboards.py
744 lines (637 loc) · 29.3 KB
/
test_organization_dashboards.py
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
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
import pytest
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait
from fixtures.page_objects.dashboard_detail import (
EDIT_WIDGET_BUTTON,
WIDGET_DRAG_HANDLE,
WIDGET_RESIZE_HANDLE,
WIDGET_TITLE_FIELD,
DashboardDetailPage,
)
from sentry.models.dashboard import Dashboard
from sentry.models.dashboard_widget import (
DashboardWidget,
DashboardWidgetDisplayTypes,
DashboardWidgetQuery,
DashboardWidgetTypes,
)
from sentry.testutils.cases import AcceptanceTestCase
from sentry.testutils.helpers.datetime import before_now, iso_format
from sentry.testutils.silo import no_silo_test
FEATURE_NAMES = [
"organizations:discover-basic",
"organizations:discover-query",
"organizations:dashboards-basic",
"organizations:global-views",
]
EDIT_FEATURE = ["organizations:dashboards-edit"]
pytestmark = pytest.mark.sentry_metrics
@no_silo_test
class OrganizationDashboardsAcceptanceTest(AcceptanceTestCase):
def setUp(self):
super().setUp()
min_ago = iso_format(before_now(minutes=1))
self.store_event(
data={"event_id": "a" * 32, "message": "oh no", "timestamp": min_ago},
project_id=self.project.id,
)
self.dashboard = Dashboard.objects.create(
title="Dashboard 1", created_by_id=self.user.id, organization=self.organization
)
self.page = DashboardDetailPage(
self.browser, self.client, organization=self.organization, dashboard=self.dashboard
)
self.login_as(self.user)
def capture_screenshots(self, screenshot_name):
"""
Captures screenshots in both a pre and post refresh state.
Necessary for verifying that the layout persists after saving.
"""
self.page.wait_until_loaded()
self.browser.refresh()
self.page.wait_until_loaded()
def test_default_overview_dashboard_layout(self):
with self.feature(FEATURE_NAMES):
self.page.visit_default_overview()
def test_add_and_move_new_widget_on_existing_dashboard(self):
with self.feature(FEATURE_NAMES + EDIT_FEATURE):
self.page.visit_dashboard_detail()
self.page.enter_edit_state()
self.page.add_widget_through_dashboard("New Widget")
# Drag to the right
dragHandle = self.browser.element(WIDGET_DRAG_HANDLE)
action = ActionChains(self.browser.driver)
action.drag_and_drop_by_offset(dragHandle, 1000, 0).perform()
self.page.save_dashboard()
self.capture_screenshots("dashboards - save new widget layout in custom dashboard")
def test_create_new_dashboard_with_modified_widget_layout(self):
with self.feature(FEATURE_NAMES + EDIT_FEATURE):
# Create a new dashboard
self.page.visit_create_dashboard()
self.page.add_widget_through_dashboard("New Widget")
# Drag to the right
dragHandle = self.browser.element(WIDGET_DRAG_HANDLE)
action = ActionChains(self.browser.driver)
action.drag_and_drop_by_offset(dragHandle, 1000, 0).perform()
self.page.save_dashboard()
# Wait for page redirect, or else loading check passes too early
wait = WebDriverWait(self.browser.driver, 10)
wait.until(
lambda driver: (
f"/organizations/{self.organization.slug}/dashboards/new/"
not in driver.current_url
)
)
self.capture_screenshots("dashboards - save widget layout in new custom dashboard")
def test_move_existing_widget_on_existing_dashboard(self):
existing_widget = DashboardWidget.objects.create(
dashboard=self.dashboard,
order=0,
title="Existing Widget",
display_type=DashboardWidgetDisplayTypes.LINE_CHART,
widget_type=DashboardWidgetTypes.DISCOVER,
interval="1d",
)
DashboardWidgetQuery.objects.create(
widget=existing_widget, fields=["count()"], columns=[], aggregates=["count()"], order=0
)
with self.feature(FEATURE_NAMES + EDIT_FEATURE):
self.page.visit_dashboard_detail()
self.page.enter_edit_state()
# Drag to the right
dragHandle = self.browser.element(WIDGET_DRAG_HANDLE)
action = ActionChains(self.browser.driver)
action.drag_and_drop_by_offset(dragHandle, 1000, 0).perform()
self.page.save_dashboard()
self.capture_screenshots("dashboards - move existing widget on existing dashboard")
@pytest.mark.skip(reason="flaky: DD-1216")
def test_widget_edit_keeps_same_layout_after_modification(self):
existing_widget = DashboardWidget.objects.create(
dashboard=self.dashboard,
order=0,
title="Existing Widget",
display_type=DashboardWidgetDisplayTypes.LINE_CHART,
widget_type=DashboardWidgetTypes.DISCOVER,
interval="1d",
)
DashboardWidgetQuery.objects.create(
widget=existing_widget, fields=["count()"], columns=[], aggregates=["count()"], order=0
)
with self.feature(FEATURE_NAMES + EDIT_FEATURE):
self.page.visit_dashboard_detail()
self.page.enter_edit_state()
# Drag existing widget to the right
dragHandle = self.browser.element(WIDGET_DRAG_HANDLE)
action = ActionChains(self.browser.driver)
action.drag_and_drop_by_offset(dragHandle, 1000, 0).perform()
# Edit the existing widget
button = self.browser.element(EDIT_WIDGET_BUTTON)
button.click()
title_input = self.browser.element(WIDGET_TITLE_FIELD)
title_input.clear()
title_input.send_keys(Keys.END, "Existing WidgetUPDATED!!")
button = self.browser.element('[aria-label="Update Widget"]')
button.click()
# Add and drag new widget to the right
self.page.add_widget_through_dashboard("New Widget")
dragHandle = self.browser.element(
f".react-grid-item:nth-of-type(2) {WIDGET_DRAG_HANDLE}"
)
action = ActionChains(self.browser.driver)
action.drag_and_drop_by_offset(dragHandle, 1000, 0)
action.perform()
# Edit the new widget
button = self.browser.element(f".react-grid-item:nth-of-type(2) {EDIT_WIDGET_BUTTON}")
button.click()
title_input = self.browser.element(WIDGET_TITLE_FIELD)
title_input.clear()
title_input.send_keys(Keys.END, "New WidgetUPDATED!!")
button = self.browser.element('[aria-label="Update Widget"]')
button.click()
self.page.save_dashboard()
self.capture_screenshots(
"dashboards - edit widgets after layout change does not reset layout"
)
def test_add_issue_widgets_do_not_overlap(self):
def add_issue_widget(widget_title):
self.browser.wait_until_clickable('[data-test-id="widget-add"]')
self.page.click_dashboard_add_widget_button()
title_input = self.browser.element(WIDGET_TITLE_FIELD)
title_input.clear()
title_input.send_keys(widget_title)
self.browser.element('[aria-label="Issues (States, Assignment, Time, etc.)"]').click()
button = self.browser.element('[aria-label="Add Widget"]')
button.click()
with self.feature(FEATURE_NAMES + EDIT_FEATURE):
self.page.visit_dashboard_detail()
self.page.enter_edit_state()
add_issue_widget("Issue Widget 1")
add_issue_widget("Issue Widget 2")
self.page.save_dashboard()
self.capture_screenshots("dashboards - issue widgets do not overlap")
def test_resize_new_and_existing_widgets(self):
existing_widget = DashboardWidget.objects.create(
dashboard=self.dashboard,
order=0,
title="Existing Widget",
display_type=DashboardWidgetDisplayTypes.LINE_CHART,
widget_type=DashboardWidgetTypes.DISCOVER,
interval="1d",
)
DashboardWidgetQuery.objects.create(
widget=existing_widget, fields=["count()"], columns=[], aggregates=["count()"], order=0
)
with self.feature(FEATURE_NAMES + EDIT_FEATURE):
self.page.visit_dashboard_detail()
self.page.enter_edit_state()
# Resize existing widget
resizeHandle = self.browser.element(WIDGET_RESIZE_HANDLE)
action = ActionChains(self.browser.driver)
action.drag_and_drop_by_offset(resizeHandle, 500, 0).perform()
self.page.add_widget_through_dashboard("New Widget")
# Drag it to the left for consistency
dragHandle = self.browser.element(
f".react-grid-item:nth-of-type(2) {WIDGET_DRAG_HANDLE}"
)
action = ActionChains(self.browser.driver)
action.drag_and_drop_by_offset(dragHandle, -1000, 0).perform()
# Resize new widget, get the 2nd element instead of the "last" because the "last" is
# the add widget button
resizeHandle = self.browser.element(
f".react-grid-item:nth-of-type(2) {WIDGET_RESIZE_HANDLE}"
)
action = ActionChains(self.browser.driver)
action.drag_and_drop_by_offset(resizeHandle, 500, 0).perform()
self.page.save_dashboard()
self.capture_screenshots("dashboards - resize new and existing widgets")
def test_delete_existing_widget_does_not_trigger_new_widget_layout_reset(self):
existing_widget = DashboardWidget.objects.create(
dashboard=self.dashboard,
order=0,
title="Existing Widget",
display_type=DashboardWidgetDisplayTypes.LINE_CHART,
widget_type=DashboardWidgetTypes.DISCOVER,
interval="1d",
)
DashboardWidgetQuery.objects.create(
widget=existing_widget, fields=["count()"], columns=[], aggregates=["count()"], order=0
)
with self.feature(FEATURE_NAMES + EDIT_FEATURE):
self.page.visit_dashboard_detail()
self.page.enter_edit_state()
self.page.add_widget_through_dashboard("New Widget")
# Drag it to the bottom left
dragHandle = self.browser.element(
f".react-grid-item:nth-of-type(2) {WIDGET_DRAG_HANDLE}"
)
action = ActionChains(self.browser.driver)
action.drag_and_drop_by_offset(dragHandle, -500, 500).perform()
# Resize new widget, get the 2nd element instead of the "last" because the "last" is
# the add widget button
resizeHandle = self.browser.element(
f".react-grid-item:nth-of-type(2) {WIDGET_RESIZE_HANDLE}"
)
action = ActionChains(self.browser.driver)
action.drag_and_drop_by_offset(resizeHandle, 500, 0).perform()
# Delete first existing widget
delete_widget_button = self.browser.element(
'.react-grid-item:first-of-type [data-test-id="widget-delete"]'
)
delete_widget_button.click()
self.page.save_dashboard()
self.capture_screenshots(
"dashboards - delete existing widget does not reset new widget layout"
)
def test_resize_big_number_widget(self):
existing_widget = DashboardWidget.objects.create(
dashboard=self.dashboard,
order=0,
title="Big Number Widget",
display_type=DashboardWidgetDisplayTypes.BIG_NUMBER,
widget_type=DashboardWidgetTypes.DISCOVER,
interval="1d",
)
DashboardWidgetQuery.objects.create(
widget=existing_widget,
fields=["count_unique(issue)"],
columns=[],
aggregates=["count_unique(issue)"],
order=0,
)
with self.feature(FEATURE_NAMES + EDIT_FEATURE):
self.page.visit_dashboard_detail()
self.page.enter_edit_state()
# Resize existing widget
resizeHandle = self.browser.element(WIDGET_RESIZE_HANDLE)
action = ActionChains(self.browser.driver)
action.drag_and_drop_by_offset(resizeHandle, 200, 200).perform()
self.page.save_dashboard()
self.capture_screenshots("dashboards - resize big number widget")
def test_default_layout_when_widgets_do_not_have_layout_set(self):
existing_widgets = DashboardWidget.objects.bulk_create(
[
DashboardWidget(
dashboard=self.dashboard,
order=i,
title=f"Existing Widget {i}",
display_type=DashboardWidgetDisplayTypes.LINE_CHART,
widget_type=DashboardWidgetTypes.DISCOVER,
interval="1d",
)
for i in range(4)
]
)
DashboardWidgetQuery.objects.bulk_create(
[
DashboardWidgetQuery(
widget=existing_widget,
fields=["count()"],
columns=[],
aggregates=["count()"],
order=0,
)
for existing_widget in existing_widgets
]
)
with self.feature(FEATURE_NAMES + EDIT_FEATURE):
self.page.visit_dashboard_detail()
self.page.wait_until_loaded()
def test_duplicate_widget_in_view_mode(self):
existing_widget = DashboardWidget.objects.create(
dashboard=self.dashboard,
order=0,
title="Big Number Widget",
display_type=DashboardWidgetDisplayTypes.BIG_NUMBER,
widget_type=DashboardWidgetTypes.DISCOVER,
interval="1d",
)
DashboardWidgetQuery.objects.create(
widget=existing_widget,
fields=["count_unique(issue)"],
columns=[],
aggregates=["count_unique(issue)"],
order=0,
)
with self.feature(FEATURE_NAMES + EDIT_FEATURE):
self.page.visit_dashboard_detail()
self.browser.element('[aria-label="Widget actions"]').click()
self.browser.element('[data-test-id="duplicate-widget"]').click()
self.page.wait_until_loaded()
self.browser.element('[aria-label="Widget actions"]').click()
self.browser.element('[data-test-id="duplicate-widget"]').click()
self.page.wait_until_loaded()
# Should not trigger alert
self.page.enter_edit_state()
self.page.click_cancel_button()
wait = WebDriverWait(self.browser.driver, 5)
wait.until_not(EC.alert_is_present())
def test_delete_widget_in_view_mode(self):
existing_widget = DashboardWidget.objects.create(
dashboard=self.dashboard,
order=0,
title="Big Number Widget",
display_type=DashboardWidgetDisplayTypes.BIG_NUMBER,
widget_type=DashboardWidgetTypes.DISCOVER,
interval="1d",
)
DashboardWidgetQuery.objects.create(
widget=existing_widget,
fields=["count_unique(issue)"],
columns=[],
aggregates=["count_unique(issue)"],
order=0,
)
with self.feature(FEATURE_NAMES + EDIT_FEATURE):
self.page.visit_dashboard_detail()
self.browser.element('[aria-label="Widget actions"]').click()
self.browser.element('[data-test-id="delete-widget"]').click()
self.browser.element('[data-test-id="confirm-button"]').click()
self.page.wait_until_loaded()
def test_cancel_without_changes_does_not_trigger_confirm_with_custom_widget_through_header(
self,
):
with self.feature(FEATURE_NAMES + EDIT_FEATURE):
self.page.visit_dashboard_detail()
self.page.click_dashboard_header_add_widget_button()
title_input = self.browser.element(WIDGET_TITLE_FIELD)
title_input.send_keys("New custom widget")
button = self.browser.element('[aria-label="Add Widget"]')
button.click()
self.page.wait_until_loaded()
# Should not trigger confirm dialog
self.page.enter_edit_state()
self.page.click_cancel_button()
wait = WebDriverWait(self.browser.driver, 5)
wait.until_not(EC.alert_is_present())
def test_position_when_adding_multiple_widgets_through_add_widget_tile_in_edit(
self,
):
with self.feature(FEATURE_NAMES + EDIT_FEATURE):
self.page.visit_dashboard_detail()
self.page.enter_edit_state()
# Widgets should take up the whole first row and the first spot in second row
self.page.add_widget_through_dashboard("A")
self.page.add_widget_through_dashboard("B")
self.page.add_widget_through_dashboard("C")
self.page.add_widget_through_dashboard("D")
self.page.wait_until_loaded()
self.page.save_dashboard()
self.capture_screenshots(
"dashboards - position when adding multiple widgets through Add Widget tile in edit"
)
@pytest.mark.skip(reason="flaky: DD-1217")
def test_position_when_adding_multiple_widgets_through_add_widget_tile_in_create(
self,
):
with self.feature(FEATURE_NAMES + EDIT_FEATURE):
self.page.visit_create_dashboard()
# Widgets should take up the whole first row and the first spot in second row
self.page.add_widget_through_dashboard("A")
self.page.add_widget_through_dashboard("B")
self.page.add_widget_through_dashboard("C")
self.page.add_widget_through_dashboard("D")
self.page.wait_until_loaded()
self.page.save_dashboard()
# Wait for page redirect, or else loading check passes too early
wait = WebDriverWait(self.browser.driver, 10)
wait.until(
lambda driver: (
f"/organizations/{self.organization.slug}/dashboards/new/"
not in driver.current_url
)
)
self.capture_screenshots(
"dashboards - position when adding multiple widgets through Add Widget tile in create"
)
def test_deleting_stacked_widgets_by_context_menu_does_not_trigger_confirm_on_edit_cancel(
self,
):
layouts = [
{"x": 0, "y": 0, "w": 2, "h": 2, "minH": 2},
{"x": 0, "y": 2, "w": 2, "h": 2, "minH": 2},
]
existing_widgets = DashboardWidget.objects.bulk_create(
[
DashboardWidget(
dashboard=self.dashboard,
order=i,
title=f"Existing Widget {i}",
display_type=DashboardWidgetDisplayTypes.LINE_CHART,
widget_type=DashboardWidgetTypes.DISCOVER,
interval="1d",
detail={"layout": layout},
)
for i, layout in enumerate(layouts)
]
)
DashboardWidgetQuery.objects.bulk_create(
DashboardWidgetQuery(
widget=widget, fields=["count()"], columns=[], aggregates=["count()"], order=0
)
for widget in existing_widgets
)
with self.feature(FEATURE_NAMES + EDIT_FEATURE):
self.page.visit_dashboard_detail()
dropdown_trigger = self.browser.element('[aria-label="Widget actions"]')
dropdown_trigger.click()
delete_widget_menu_item = self.browser.element('[data-test-id="delete-widget"]')
delete_widget_menu_item.click()
confirm_button = self.browser.element('[data-test-id="confirm-button"]')
confirm_button.click()
wait = WebDriverWait(self.browser.driver, 5)
wait.until(
EC.presence_of_element_located(
(By.XPATH, "//*[contains(text(),'Dashboard updated')]")
)
)
# Should not trigger confirm dialog
self.page.enter_edit_state()
self.page.click_cancel_button()
wait.until_not(EC.alert_is_present())
def test_changing_number_widget_to_area_updates_widget_height(
self,
):
layouts = [
(DashboardWidgetDisplayTypes.BIG_NUMBER, {"x": 0, "y": 0, "w": 2, "h": 1, "minH": 1}),
(DashboardWidgetDisplayTypes.LINE_CHART, {"x": 0, "y": 1, "w": 2, "h": 2, "minH": 2}),
]
existing_widgets = DashboardWidget.objects.bulk_create(
[
DashboardWidget(
dashboard=self.dashboard,
order=i,
title=f"Widget {i}",
display_type=display_type,
widget_type=DashboardWidgetTypes.DISCOVER,
interval="1d",
detail={"layout": layout},
)
for i, (display_type, layout) in enumerate(layouts)
]
)
DashboardWidgetQuery.objects.bulk_create(
DashboardWidgetQuery(
widget=widget, fields=["count()"], columns=[], aggregates=["count()"], order=0
)
for widget in existing_widgets
)
with self.feature(FEATURE_NAMES + EDIT_FEATURE):
self.page.visit_dashboard_detail()
# Open edit modal for first widget
dropdown_trigger = self.browser.element('[aria-label="Widget actions"]')
dropdown_trigger.click()
edit_widget_menu_item = self.browser.element('[data-test-id="edit-widget"]')
edit_widget_menu_item.click()
# Change the chart type to the first visualization option - Area chart
chart_type_input = self.browser.element("#react-select-2-input")
chart_type_input.send_keys("Area", Keys.ENTER)
button = self.browser.element('[aria-label="Update Widget"]')
button.click()
# No confirm dialog because of shifting lower element
self.page.enter_edit_state()
self.page.click_cancel_button()
wait = WebDriverWait(self.browser.driver, 5)
wait.until_not(EC.alert_is_present())
# Try to decrease height to 1 row, should stay at 2 rows
self.page.enter_edit_state()
resizeHandle = self.browser.element(WIDGET_RESIZE_HANDLE)
action = ActionChains(self.browser.driver)
action.drag_and_drop_by_offset(resizeHandle, 0, -100).perform()
self.page.save_dashboard()
@pytest.mark.skip(reason="flaky behaviour due to loading spinner")
def test_changing_number_widget_larger_than_min_height_for_area_chart_keeps_height(
self,
):
existing_widget = DashboardWidget.objects.create(
dashboard=self.dashboard,
order=0,
title="Originally Big Number - 3 rows",
display_type=DashboardWidgetDisplayTypes.BIG_NUMBER,
widget_type=DashboardWidgetTypes.DISCOVER,
interval="1d",
detail={"layout": {"x": 0, "y": 0, "w": 2, "h": 3, "minH": 1}},
)
DashboardWidgetQuery.objects.create(
widget=existing_widget, fields=["count()"], columns=[], aggregates=["count()"], order=0
)
with self.feature(FEATURE_NAMES + EDIT_FEATURE):
self.page.visit_dashboard_detail()
# Open edit modal for first widget
dropdown_trigger = self.browser.element('[aria-label="Widget actions"]')
dropdown_trigger.click()
edit_widget_menu_item = self.browser.element('[data-test-id="edit-widget"]')
edit_widget_menu_item.click()
# Change the chart type to the first visualization option - Area chart
chart_type_input = self.browser.element("#react-select-2-input")
chart_type_input.send_keys("Area", Keys.ENTER)
button = self.browser.element('[aria-label="Update Widget"]')
button.click()
self.page.wait_until_loaded()
# Try to decrease height by >1 row, should be at 2 rows
self.page.enter_edit_state()
resizeHandle = self.browser.element(WIDGET_RESIZE_HANDLE)
action = ActionChains(self.browser.driver)
action.drag_and_drop_by_offset(resizeHandle, 0, -400).perform()
self.page.save_dashboard()
@pytest.mark.skip(reason="flaky: DD-1211")
def test_changing_area_widget_larger_than_min_height_for_number_chart_keeps_height(
self,
):
existing_widget = DashboardWidget.objects.create(
dashboard=self.dashboard,
order=0,
title="Originally Area Chart - 3 rows",
display_type=DashboardWidgetDisplayTypes.AREA_CHART,
widget_type=DashboardWidgetTypes.DISCOVER,
interval="1d",
detail={"layout": {"x": 0, "y": 0, "w": 2, "h": 3, "minH": 2}},
)
DashboardWidgetQuery.objects.create(
widget=existing_widget, fields=["count()"], columns=[], aggregates=["count()"], order=0
)
with self.feature(FEATURE_NAMES + EDIT_FEATURE):
self.page.visit_dashboard_detail()
# Open edit modal for first widget
dropdown_trigger = self.browser.element('[aria-label="Widget actions"]')
dropdown_trigger.click()
edit_widget_menu_item = self.browser.element('[data-test-id="edit-widget"]')
edit_widget_menu_item.click()
# Change the chart type to big number
chart_type_input = self.browser.element("#react-select-2-input")
chart_type_input.send_keys("Big Number", Keys.ENTER)
button = self.browser.element('[aria-label="Update Widget"]')
button.click()
self.page.wait_until_loaded()
# Decrease height by >1 row, should stop at 1 row
self.page.enter_edit_state()
resizeHandle = self.browser.element(WIDGET_RESIZE_HANDLE)
action = ActionChains(self.browser.driver)
action.drag_and_drop_by_offset(resizeHandle, 0, -400).perform()
self.page.save_dashboard()
@no_silo_test
class OrganizationDashboardsManageAcceptanceTest(AcceptanceTestCase):
def setUp(self):
super().setUp()
self.team = self.create_team(organization=self.organization, name="Mariachi Band")
self.project = self.create_project(
organization=self.organization, teams=[self.team], name="Bengal"
)
self.dashboard = Dashboard.objects.create(
title="Dashboard 1", created_by_id=self.user.id, organization=self.organization
)
self.widget_1 = DashboardWidget.objects.create(
dashboard=self.dashboard,
order=0,
title="Widget 1",
display_type=DashboardWidgetDisplayTypes.LINE_CHART,
widget_type=DashboardWidgetTypes.DISCOVER,
interval="1d",
)
self.widget_2 = DashboardWidget.objects.create(
dashboard=self.dashboard,
order=1,
title="Widget 2",
display_type=DashboardWidgetDisplayTypes.TABLE,
widget_type=DashboardWidgetTypes.DISCOVER,
interval="1d",
)
self.login_as(self.user)
self.default_path = f"/organizations/{self.organization.slug}/dashboards/"
def wait_until_loaded(self):
self.browser.wait_until_not('[data-test-id="loading-indicator"]')
self.browser.wait_until_not('[data-test-id="loading-placeholder"]')
def test_dashboard_manager(self):
with self.feature(FEATURE_NAMES + EDIT_FEATURE):
self.browser.get(self.default_path)
self.wait_until_loaded()
def test_dashboard_manager_with_unset_layouts_and_defined_layouts(self):
dashboard_with_layouts = Dashboard.objects.create(
title="Dashboard with some defined layouts",
created_by_id=self.user.id,
organization=self.organization,
)
DashboardWidget.objects.create(
dashboard=dashboard_with_layouts,
order=0,
title="Widget 1",
display_type=DashboardWidgetDisplayTypes.BAR_CHART,
widget_type=DashboardWidgetTypes.DISCOVER,
interval="1d",
detail={"layout": {"x": 1, "y": 0, "w": 3, "h": 3, "minH": 2}},
)
# This widget has no layout, but should position itself at
# x: 4, y: 0, w: 2, h: 2
DashboardWidget.objects.create(
dashboard=dashboard_with_layouts,
order=1,
title="Widget 2",
display_type=DashboardWidgetDisplayTypes.TABLE,
widget_type=DashboardWidgetTypes.DISCOVER,
interval="1d",
)
with self.feature(FEATURE_NAMES + EDIT_FEATURE):
self.browser.get(self.default_path)
self.wait_until_loaded()