@@ -3,14 +3,10 @@ import {browserHistory} from 'react-router';
33
44import { mountWithTheme } from 'sentry-test/enzyme' ;
55import { initializeOrg } from 'sentry-test/initializeOrg' ;
6+ import { mountGlobalModal } from 'sentry-test/modal' ;
67
7- import { openAddDashboardWidgetModal } from 'app/actionCreators/modal' ;
88import DashboardDetail from 'app/views/dashboardsV2/detail' ;
99
10- jest . mock ( 'app/actionCreators/modal' , ( ) => ( {
11- openAddDashboardWidgetModal : jest . fn ( ) ,
12- } ) ) ;
13-
1410describe ( 'Dashboards > Detail' , function ( ) {
1511 const organization = TestStubs . Organization ( {
1612 features : [ 'global-views' , 'dashboards-v2' , 'discover-query' ] ,
@@ -70,8 +66,17 @@ describe('Dashboards > Detail', function () {
7066 // Enter edit mode.
7167 wrapper . find ( 'Controls Button[data-test-id="dashboard-edit"]' ) . simulate ( 'click' ) ;
7268
73- // Click delete, request should be made.
69+ const modal = await mountGlobalModal ( ) ;
70+
71+ // Click delete, confirm will show
7472 wrapper . find ( 'Controls Button[data-test-id="dashboard-delete"]' ) . simulate ( 'click' ) ;
73+ await tick ( ) ;
74+
75+ await modal . update ( ) ;
76+
77+ // Click confirm
78+ modal . find ( 'button[aria-label="Confirm"]' ) . simulate ( 'click' ) ;
79+
7580 expect ( deleteMock ) . toHaveBeenCalled ( ) ;
7681 } ) ;
7782
@@ -128,14 +133,20 @@ describe('Dashboards > Detail', function () {
128133 beforeEach ( function ( ) {
129134 initialData = initializeOrg ( { organization} ) ;
130135 widgets = [
131- TestStubs . Widget ( [ { conditions : 'event.type:error' , fields : [ 'count()' ] } ] , {
132- title : 'Errors' ,
133- interval : '1d' ,
134- } ) ,
135- TestStubs . Widget ( [ { conditions : 'event.type:transaction' , fields : [ 'count()' ] } ] , {
136- title : 'Transactions' ,
137- interval : '1d' ,
138- } ) ,
136+ TestStubs . Widget (
137+ [ { name : '' , conditions : 'event.type:error' , fields : [ 'count()' ] } ] ,
138+ {
139+ title : 'Errors' ,
140+ interval : '1d' ,
141+ }
142+ ) ,
143+ TestStubs . Widget (
144+ [ { name : '' , conditions : 'event.type:transaction' , fields : [ 'count()' ] } ] ,
145+ {
146+ title : 'Transactions' ,
147+ interval : '1d' ,
148+ }
149+ ) ,
139150 ] ;
140151
141152 MockApiClient . addMockResponse ( {
@@ -241,14 +252,10 @@ describe('Dashboards > Detail', function () {
241252 . simulate ( 'click' ) ;
242253
243254 await tick ( ) ;
244- wrapper . update ( ) ;
255+ await wrapper . update ( ) ;
256+ const modal = await mountGlobalModal ( ) ;
245257
246- expect ( openAddDashboardWidgetModal ) . toHaveBeenCalled ( ) ;
247- expect ( openAddDashboardWidgetModal ) . toHaveBeenCalledWith (
248- expect . objectContaining ( {
249- widget : widgets [ 0 ] ,
250- } )
251- ) ;
258+ expect ( modal . find ( 'AddDashboardWidgetModal' ) . props ( ) . widget ) . toEqual ( widgets [ 0 ] ) ;
252259 } ) ;
253260 } ) ;
254261} ) ;
0 commit comments