@@ -25,12 +25,14 @@ import {
2525 untilResolved ,
2626 muteFetch ,
2727 provideUserAuthentication ,
28+ provideSiteInfo ,
2829} from '../../../../../tests/js/utils' ;
2930import {
3031 surveyEventEndpoint ,
3132 surveyTimeoutsEndpoint ,
3233 surveyTriggerEndpoint ,
3334} from '../../../../../tests/js/mock-survey-endpoints' ;
35+ import { CORE_SITE } from '../site/constants' ;
3436
3537describe ( 'core/user surveys' , ( ) => {
3638 let registry ;
@@ -69,6 +71,7 @@ describe( 'core/user surveys', () => {
6971
7072 it ( 'should not throw when called with only a triggerID' , async ( ) => {
7173 provideUserAuthentication ( registry ) ;
74+ provideSiteInfo ( registry ) ;
7275
7376 muteFetch ( surveyTriggerEndpoint ) ;
7477
@@ -85,6 +88,22 @@ describe( 'core/user surveys', () => {
8588
8689 it ( 'should not fetch if user is not authenticated' , async ( ) => {
8790 provideUserAuthentication ( registry , { authenticated : false } ) ;
91+ provideSiteInfo ( registry ) ;
92+
93+ await registry
94+ . dispatch ( CORE_USER )
95+ . triggerSurvey ( 'userInput_answered_other__goals' ) ;
96+
97+ expect ( fetchMock ) . not . toHaveFetched ( surveyTriggerEndpoint , {
98+ body : {
99+ data : { triggerID : 'userInput_answered_other__goals' } ,
100+ } ,
101+ } ) ;
102+ } ) ;
103+
104+ it ( 'should not fetch if site is not using proxy' , async ( ) => {
105+ provideUserAuthentication ( registry ) ;
106+ provideSiteInfo ( registry , { usingProxy : false } ) ;
88107
89108 await registry
90109 . dispatch ( CORE_USER )
@@ -98,6 +117,7 @@ describe( 'core/user surveys', () => {
98117 } ) ;
99118
100119 it ( 'should wait for authentication to be resolved before making a network request' , async ( ) => {
120+ provideSiteInfo ( registry ) ;
101121 muteFetch ( surveyTriggerEndpoint ) ;
102122
103123 registry . dispatch ( CORE_USER ) . receiveGetSurveyTimeouts ( [ ] ) ;
@@ -133,6 +153,7 @@ describe( 'core/user surveys', () => {
133153
134154 it ( 'should make network requests to survey endpoint' , async ( ) => {
135155 provideUserAuthentication ( registry ) ;
156+ provideSiteInfo ( registry ) ;
136157
137158 muteFetch ( surveyTriggerEndpoint ) ;
138159
@@ -158,6 +179,7 @@ describe( 'core/user surveys', () => {
158179 const triggerID = 'userInput_answered_other__goals' ;
159180
160181 provideUserAuthentication ( registry ) ;
182+ provideSiteInfo ( registry ) ;
161183
162184 registry
163185 . dispatch ( CORE_USER )
@@ -177,6 +199,7 @@ describe( 'core/user surveys', () => {
177199 fetchMock . post ( surveyTriggerEndpoint , { } ) ;
178200
179201 provideUserAuthentication ( registry ) ;
202+ provideSiteInfo ( registry ) ;
180203 registry . dispatch ( CORE_USER ) . receiveGetSurveyTimeouts ( [ ] ) ;
181204
182205 await Promise . all ( [
@@ -194,6 +217,7 @@ describe( 'core/user surveys', () => {
194217 const triggerID = 'userInput_answered_other__goals' ;
195218
196219 provideUserAuthentication ( registry ) ;
220+ provideSiteInfo ( registry ) ;
197221
198222 await registry . resolveSelect ( CORE_USER ) . getAuthentication ( ) ;
199223
@@ -202,6 +226,7 @@ describe( 'core/user surveys', () => {
202226 registry . dispatch ( CORE_USER ) . receiveGetSurveyTimeouts ( [ ] ) ;
203227
204228 await registry . resolveSelect ( CORE_USER ) . getSurveyTimeouts ( ) ;
229+ await registry . resolveSelect ( CORE_SITE ) . getSiteInfo ( ) ;
205230
206231 jest . useFakeTimers ( ) ;
207232
0 commit comments