@@ -19,20 +19,23 @@ describe('atlasOptInReducer', function () {
1919
2020 beforeEach ( async function ( ) {
2121 mockPreferences = await createSandboxFromDefaultPreferences ( ) ;
22+ await mockPreferences . savePreferences ( {
23+ optInDataExplorerGenAIFeatures : false ,
24+ } ) ;
2225 } ) ;
2326
2427 afterEach ( function ( ) {
2528 sandbox . reset ( ) ;
2629 } ) ;
2730
2831 describe ( 'optIn' , function ( ) {
29- it ( 'should check authenticated state and set state to success if already authenticated ' , async function ( ) {
30- const mockAtlasService = {
31- optIn : sandbox . stub ( ) . resolves ( { sub : '1234' } ) ,
32+ it ( 'should check state and set state to success if already opted in ' , async function ( ) {
33+ const mockAtlasAiService = {
34+ optIntoGenAIFeaturesAtlas : sandbox . stub ( ) . resolves ( { sub : '1234' } ) ,
3235 } ;
3336 const store = configureStore ( {
34- atlasAuthService : mockAtlasService as any ,
35- atlasAiService : mockAtlasService as any ,
37+ atlasAuthService : { } as any ,
38+ atlasAiService : mockAtlasAiService as any ,
3639 preferences : mockPreferences ,
3740 } ) ;
3841
@@ -41,22 +44,22 @@ describe('atlasOptInReducer', function () {
4144 'initial'
4245 ) ;
4346 void store . dispatch ( atlasAiServiceOptedIn ( ) ) ;
44- console . log ( store . getState ( ) ) ;
4547 await store . dispatch ( optIn ( ) ) ;
46- expect ( mockAtlasService . optIn ) . not . to . have . been . called ;
48+ expect ( mockAtlasAiService . optIntoGenAIFeaturesAtlas ) . not . to . have . been
49+ . called ;
4750 expect ( store . getState ( ) . optIn ) . to . have . nested . property (
4851 'state' ,
4952 'optin-success'
5053 ) ;
5154 } ) ;
5255
5356 it ( 'should start opt in, and set state to success' , async function ( ) {
54- const mockAtlasService = {
55- optIn : sandbox . stub ( ) . resolves ( { sub : '1234' } ) ,
57+ const mockAtlasAiService = {
58+ optIntoGenAIFeaturesAtlas : sandbox . stub ( ) . resolves ( { sub : '1234' } ) ,
5659 } ;
5760 const store = configureStore ( {
58- atlasAuthService : mockAtlasService as any ,
59- atlasAiService : mockAtlasService as any ,
61+ atlasAuthService : { } as any ,
62+ atlasAiService : mockAtlasAiService as any ,
6063 preferences : mockPreferences ,
6164 } ) ;
6265
@@ -66,20 +69,23 @@ describe('atlasOptInReducer', function () {
6669 ) ;
6770 void store . dispatch ( optIntoGenAIWithModalPrompt ( ) ) . catch ( ( ) => { } ) ;
6871 await store . dispatch ( optIn ( ) ) ;
69- expect ( mockAtlasService . optIn ) . to . have . been . calledOnce ;
72+ expect ( mockAtlasAiService . optIntoGenAIFeaturesAtlas ) . to . have . been
73+ . calledOnce ;
7074 expect ( store . getState ( ) . optIn ) . to . have . nested . property (
7175 'state' ,
7276 'optin-success'
7377 ) ;
7478 } ) ;
7579
7680 it ( 'should fail opt in if opt in failed' , async function ( ) {
77- const mockAtlasService = {
78- optIn : sandbox . stub ( ) . rejects ( new Error ( 'Pineapples!' ) ) ,
81+ const mockAtlasAiService = {
82+ optIntoGenAIFeaturesAtlas : sandbox
83+ . stub ( )
84+ . rejects ( new Error ( 'Whooops!' ) ) ,
7985 } ;
8086 const store = configureStore ( {
81- atlasAuthService : mockAtlasService as any ,
82- atlasAiService : mockAtlasService as any ,
87+ atlasAuthService : { } as any ,
88+ atlasAiService : mockAtlasAiService as any ,
8389 preferences : mockPreferences ,
8490 } ) ;
8591
@@ -88,7 +94,8 @@ describe('atlasOptInReducer', function () {
8894 // Avoid unhandled rejections.
8995 AttemptStateMap . get ( attemptId ) ?. promise . catch ( ( ) => { } ) ;
9096 await optInPromise ;
91- expect ( mockAtlasService . optIn ) . to . have . been . calledOnce ;
97+ expect ( mockAtlasAiService . optIntoGenAIFeaturesAtlas ) . to . have . been
98+ . calledOnce ;
9299 expect ( store . getState ( ) . optIn ) . to . have . nested . property ( 'state' , 'error' ) ;
93100 } ) ;
94101 } ) ;
@@ -112,8 +119,8 @@ describe('atlasOptInReducer', function () {
112119 } ) ;
113120
114121 it ( 'should cancel opt in if opt in is in progress' , async function ( ) {
115- const mockAtlasService = {
116- optIn : sandbox
122+ const mockAtlasAiService = {
123+ optIntoGenAIFeaturesAtlas : sandbox
117124 . stub ( )
118125 . callsFake ( ( { signal } : { signal : AbortSignal } ) => {
119126 return new Promise ( ( resolve , reject ) => {
@@ -123,9 +130,10 @@ describe('atlasOptInReducer', function () {
123130 } ) ;
124131 } ) ,
125132 } ;
133+
126134 const store = configureStore ( {
127- atlasAuthService : mockAtlasService as any ,
128- atlasAiService : mockAtlasService as any ,
135+ atlasAuthService : { } as any ,
136+ atlasAiService : mockAtlasAiService as any ,
129137 preferences : mockPreferences ,
130138 } ) ;
131139
@@ -144,12 +152,12 @@ describe('atlasOptInReducer', function () {
144152
145153 describe ( 'optIntoAtlasWithModalPrompt' , function ( ) {
146154 it ( 'should resolve when user finishes opt in with prompt flow' , async function ( ) {
147- const mockAtlasService = {
148- optIn : sandbox . stub ( ) . resolves ( { sub : '1234' } ) ,
155+ const mockAtlasAiService = {
156+ optIntoGenAIFeaturesAtlas : sandbox . stub ( ) . resolves ( { sub : '1234' } ) ,
149157 } ;
150158 const store = configureStore ( {
151- atlasAuthService : mockAtlasService as any ,
152- atlasAiService : mockAtlasService as any ,
159+ atlasAuthService : { } as any ,
160+ atlasAiService : mockAtlasAiService as any ,
153161 preferences : mockPreferences ,
154162 } ) ;
155163
@@ -161,12 +169,12 @@ describe('atlasOptInReducer', function () {
161169 } ) ;
162170
163171 it ( 'should reject if opt in flow fails' , async function ( ) {
164- const mockAtlasService = {
165- optIn : sandbox . stub ( ) . rejects ( new Error ( 'Whoops!' ) ) ,
172+ const mockAtlasAiService = {
173+ optIntoGenAIFeaturesAtlas : sandbox . stub ( ) . rejects ( new Error ( 'Whoops!' ) ) ,
166174 } ;
167175 const store = configureStore ( {
168- atlasAuthService : mockAtlasService as any ,
169- atlasAiService : mockAtlasService as any ,
176+ atlasAuthService : { } as any ,
177+ atlasAiService : mockAtlasAiService as any ,
170178 preferences : mockPreferences ,
171179 } ) ;
172180
@@ -184,12 +192,12 @@ describe('atlasOptInReducer', function () {
184192 } ) ;
185193
186194 it ( 'should reject if user dismissed the modal' , async function ( ) {
187- const mockAtlasService = {
188- optIn : sandbox . stub ( ) . resolves ( { sub : '1234' } ) ,
195+ const mockAtlasAiService = {
196+ optIntoGenAIFeaturesAtlas : sandbox . stub ( ) . resolves ( { sub : '1234' } ) ,
189197 } ;
190198 const store = configureStore ( {
191- atlasAuthService : mockAtlasService as any ,
192- atlasAiService : mockAtlasService as any ,
199+ atlasAuthService : { } as any ,
200+ atlasAiService : mockAtlasAiService as any ,
193201 preferences : mockPreferences ,
194202 } ) ;
195203
@@ -207,12 +215,12 @@ describe('atlasOptInReducer', function () {
207215 } ) ;
208216
209217 it ( 'should reject if provided signal was aborted' , async function ( ) {
210- const mockAtlasService = {
211- optIn : sandbox . stub ( ) . resolves ( { sub : '1234' } ) ,
218+ const mockAtlasAiService = {
219+ optIntoGenAIFeaturesAtlas : sandbox . stub ( ) . resolves ( { sub : '1234' } ) ,
212220 } ;
213221 const store = configureStore ( {
214- atlasAuthService : mockAtlasService as any ,
215- atlasAiService : mockAtlasService as any ,
222+ atlasAuthService : { } as any ,
223+ atlasAiService : mockAtlasAiService as any ,
216224 preferences : mockPreferences ,
217225 } ) ;
218226
0 commit comments