@@ -12,7 +12,6 @@ const DEFAULT_LINKS_HEADER =
12
12
'<http://127.0.0.1:8000/api/0/organizations/org-slug/issues/?cursor=1443575731:0:0>; rel="next"; results="true"; cursor="1443575731:0:0' ;
13
13
14
14
describe ( 'OrganizationStream' , function ( ) {
15
- let sandbox ;
16
15
let wrapper ;
17
16
let props ;
18
17
@@ -25,8 +24,6 @@ describe('OrganizationStream', function() {
25
24
let fetchMembersRequest ;
26
25
27
26
beforeEach ( function ( ) {
28
- sandbox = sinon . sandbox . create ( ) ;
29
-
30
27
project = TestStubs . ProjectDetails ( {
31
28
id : '3559' ,
32
29
name : 'Foo Project' ,
@@ -81,7 +78,6 @@ describe('OrganizationStream', function() {
81
78
body : [ TestStubs . Member ( { projects : [ project . slug ] } ) ] ,
82
79
} ) ;
83
80
84
- sandbox . stub ( browserHistory , 'push' ) ;
85
81
TagStore . init ( ) ;
86
82
87
83
props = {
@@ -97,10 +93,89 @@ describe('OrganizationStream', function() {
97
93
} ) ;
98
94
99
95
afterEach ( function ( ) {
100
- sandbox . restore ( ) ;
101
96
MockApiClient . clearMockResponses ( ) ;
102
97
} ) ;
103
98
99
+ describe ( 'transitionTo' , function ( ) {
100
+ let instance ;
101
+ beforeEach ( function ( ) {
102
+ wrapper = shallow ( < OrganizationStream { ...props } /> ) ;
103
+ instance = wrapper . instance ( ) ;
104
+ } ) ;
105
+
106
+ it ( 'transitions to query updates' , function ( ) {
107
+ instance . transitionTo ( { query : 'is:ignored' } ) ;
108
+
109
+ expect ( browserHistory . push ) . toHaveBeenCalledWith ( {
110
+ pathname : '/organizations/org-slug/issues/' ,
111
+ query : {
112
+ environment : [ ] ,
113
+ project : [ parseInt ( project . id , 10 ) ] ,
114
+ query : 'is:ignored' ,
115
+ statsPeriod : '14d' ,
116
+ } ,
117
+ } ) ;
118
+ } ) ;
119
+
120
+ it ( 'transitions to saved search that has a projectId' , function ( ) {
121
+ savedSearch = {
122
+ id : 123 ,
123
+ projectId : 99 ,
124
+ query : 'foo:bar' ,
125
+ } ;
126
+ instance . setState ( { savedSearch} ) ;
127
+ instance . transitionTo ( ) ;
128
+
129
+ expect ( browserHistory . push ) . toHaveBeenCalledWith ( {
130
+ pathname : '/organizations/org-slug/issues/searches/123/' ,
131
+ query : {
132
+ environment : [ ] ,
133
+ project : [ savedSearch . projectId ] ,
134
+ statsPeriod : '14d' ,
135
+ } ,
136
+ } ) ;
137
+ } ) ;
138
+
139
+ it ( 'goes to all projects when using a basic saved searches and global-views feature' , function ( ) {
140
+ organization . features = [ 'global-views' ] ;
141
+ savedSearch = {
142
+ id : 1 ,
143
+ project : null ,
144
+ query : 'is:unresolved' ,
145
+ } ;
146
+ instance . setState ( { savedSearch} ) ;
147
+ instance . transitionTo ( ) ;
148
+
149
+ expect ( browserHistory . push ) . toHaveBeenCalledWith ( {
150
+ pathname : '/organizations/org-slug/issues/searches/1/' ,
151
+ query : {
152
+ environment : [ ] ,
153
+ statsPeriod : '14d' ,
154
+ } ,
155
+ } ) ;
156
+ } ) ;
157
+
158
+ it ( 'retains project selection when using a basic saved search and no global-views feature' , function ( ) {
159
+ organization . features = [ ] ;
160
+ savedSearch = {
161
+ id : 1 ,
162
+ projectId : null ,
163
+ query : 'is:unresolved' ,
164
+ } ;
165
+ instance . setState ( { savedSearch} ) ;
166
+ instance . transitionTo ( ) ;
167
+
168
+ expect ( browserHistory . push ) . toHaveBeenCalledWith ( {
169
+ pathname : '/organizations/org-slug/issues/searches/1/' ,
170
+ query : {
171
+ environment : [ ] ,
172
+ project : props . selection . projects ,
173
+ statsPeriod : '14d' ,
174
+ } ,
175
+ } ) ;
176
+ } ) ;
177
+ } ) ;
178
+
104
179
describe ( 'getEndpointParams' , function ( ) {
105
180
beforeEach ( function ( ) {
106
181
wrapper = shallow ( < OrganizationStream { ...props } /> ) ;
0 commit comments