@@ -184,19 +184,23 @@ describe('templateSpecifications', () => {
184
184
const gotLabels = got . map ( ( template ) => template . name )
185
185
186
186
// Then
187
- expect ( vi . mocked ( businessPlatformOrganizationsRequest ) ) . toHaveBeenCalledWith (
188
- `
187
+ expect ( vi . mocked ( businessPlatformOrganizationsRequest ) ) . toHaveBeenCalledWith ( {
188
+ query : `
189
189
query OrganizationBetaFlags($organizationId: OrganizationID!) {
190
190
organization(organizationId: $organizationId) {
191
191
id
192
192
flag_allowedFlag: hasFeatureFlag(handle: "allowedFlag")
193
193
flag_notAllowedFlag: hasFeatureFlag(handle: "notAllowedFlag")
194
194
}
195
195
}` ,
196
- 'business-platform-token' ,
197
- orgApp . organizationId ,
198
- { organizationId : encodedGidFromOrganizationId ( orgApp . organizationId ) } ,
199
- )
196
+ token : 'business-platform-token' ,
197
+ organizationId : orgApp . organizationId ,
198
+ variables : { organizationId : encodedGidFromOrganizationId ( orgApp . organizationId ) } ,
199
+ unauthorizedHandler : {
200
+ type : 'token_refresh' ,
201
+ handler : expect . any ( Function ) ,
202
+ } ,
203
+ } )
200
204
const expectedAllowedTemplates = [ templateWithoutRules , allowedTemplate ]
201
205
expect ( gotLabels ) . toEqual ( expectedAllowedTemplates . map ( ( template ) => template . name ) )
202
206
} )
@@ -308,18 +312,16 @@ describe('searching for apps', () => {
308
312
const got = await client . appsForOrg ( orgId , query )
309
313
310
314
// Then
311
- expect ( vi . mocked ( appManagementRequestDoc ) ) . toHaveBeenCalledWith (
312
- orgId ,
313
- ListApps ,
314
- 'token' ,
315
- { query : queryVariable } ,
316
- undefined ,
317
- undefined ,
318
- expect . objectContaining ( {
319
- handler : expect . any ( Function ) ,
315
+ expect ( vi . mocked ( appManagementRequestDoc ) ) . toHaveBeenCalledWith ( {
316
+ organizationId : orgId ,
317
+ query : ListApps ,
318
+ token : 'token' ,
319
+ variables : { query : queryVariable } ,
320
+ unauthorizedHandler : {
320
321
type : 'token_refresh' ,
321
- } ) ,
322
- )
322
+ handler : expect . any ( Function ) ,
323
+ } ,
324
+ } )
323
325
expect ( got ) . toEqual ( {
324
326
apps : apps . map ( ( app , index ) => ( {
325
327
apiKey : `key-${ index } ` ,
@@ -367,11 +369,11 @@ describe('createApp', () => {
367
369
368
370
// Then
369
371
expect ( webhooksRequest ) . toHaveBeenCalledWith ( org . id , expect . anything ( ) , 'token' , expect . any ( Object ) )
370
- expect ( vi . mocked ( appManagementRequestDoc ) ) . toHaveBeenCalledWith (
371
- org . id ,
372
- CreateApp ,
373
- 'token' ,
374
- {
372
+ expect ( vi . mocked ( appManagementRequestDoc ) ) . toHaveBeenCalledWith ( {
373
+ organizationId : org . id ,
374
+ query : CreateApp ,
375
+ token : 'token' ,
376
+ variables : {
375
377
initialVersion : {
376
378
source : {
377
379
name : 'app-name' ,
@@ -386,13 +388,11 @@ describe('createApp', () => {
386
388
} ,
387
389
} ,
388
390
} ,
389
- undefined ,
390
- undefined ,
391
- expect . objectContaining ( {
391
+ unauthorizedHandler : {
392
392
handler : expect . any ( Function ) ,
393
393
type : 'token_refresh' ,
394
- } ) ,
395
- )
394
+ } ,
395
+ } )
396
396
} )
397
397
398
398
test ( 'creates app successfully and returns expected app structure' , async ( ) => {
@@ -458,11 +458,11 @@ describe('createApp', () => {
458
458
await client . createApp ( org , { name : 'app-name' } )
459
459
460
460
// Then
461
- expect ( vi . mocked ( appManagementRequestDoc ) ) . toHaveBeenCalledWith (
462
- org . id ,
463
- CreateApp ,
464
- 'token' ,
465
- {
461
+ expect ( vi . mocked ( appManagementRequestDoc ) ) . toHaveBeenCalledWith ( {
462
+ organizationId : org . id ,
463
+ query : CreateApp ,
464
+ token : 'token' ,
465
+ variables : {
466
466
initialVersion : {
467
467
source : {
468
468
name : 'app-name' ,
@@ -478,13 +478,11 @@ describe('createApp', () => {
478
478
} ,
479
479
} ,
480
480
} ,
481
- undefined ,
482
- undefined ,
483
- expect . objectContaining ( {
481
+ unauthorizedHandler : {
484
482
handler : expect . any ( Function ) ,
485
483
type : 'token_refresh' ,
486
- } ) ,
487
- )
484
+ } ,
485
+ } )
488
486
} )
489
487
} )
490
488
@@ -716,11 +714,11 @@ describe('deploy', () => {
716
714
} )
717
715
718
716
// Then
719
- expect ( vi . mocked ( appManagementRequestDoc ) ) . toHaveBeenCalledWith (
720
- 'gid://shopify/Organization/123' ,
721
- expect . anything ( ) ,
722
- 'token' ,
723
- {
717
+ expect ( vi . mocked ( appManagementRequestDoc ) ) . toHaveBeenCalledWith ( {
718
+ organizationId : 'gid://shopify/Organization/123' ,
719
+ query : expect . anything ( ) ,
720
+ token : 'token' ,
721
+ variables : {
724
722
appId : 'gid://shopify/App/123' ,
725
723
version : {
726
724
source : {
@@ -742,13 +740,12 @@ describe('deploy', () => {
742
740
sourceControlUrl : commitReference ,
743
741
} ,
744
742
} ,
745
- undefined ,
746
- { requestMode : 'slow-request' } ,
747
- expect . objectContaining ( {
743
+ requestOptions : { requestMode : 'slow-request' } ,
744
+ unauthorizedHandler : {
748
745
handler : expect . any ( Function ) ,
749
746
type : 'token_refresh' ,
750
- } ) ,
751
- )
747
+ } ,
748
+ } )
752
749
} )
753
750
754
751
test ( 'includes the target property when context is provided' , async ( ) => {
@@ -800,11 +797,11 @@ describe('deploy', () => {
800
797
} )
801
798
802
799
// Then
803
- expect ( vi . mocked ( appManagementRequestDoc ) ) . toHaveBeenCalledWith (
804
- 'gid://shopify/Organization/123' ,
805
- expect . anything ( ) ,
806
- 'token' ,
807
- {
800
+ expect ( vi . mocked ( appManagementRequestDoc ) ) . toHaveBeenCalledWith ( {
801
+ organizationId : 'gid://shopify/Organization/123' ,
802
+ query : expect . anything ( ) ,
803
+ token : 'token' ,
804
+ variables : {
808
805
appId : 'gid://shopify/App/123' ,
809
806
version : {
810
807
source : {
@@ -826,13 +823,12 @@ describe('deploy', () => {
826
823
sourceControlUrl : commitReference ,
827
824
} ,
828
825
} ,
829
- undefined ,
830
- { requestMode : 'slow-request' } ,
831
- expect . objectContaining ( {
826
+ requestOptions : { requestMode : 'slow-request' } ,
827
+ unauthorizedHandler : {
832
828
handler : expect . any ( Function ) ,
833
829
type : 'token_refresh' ,
834
- } ) ,
835
- )
830
+ } ,
831
+ } )
836
832
} )
837
833
838
834
test ( 'does not include target property when context is empty' , async ( ) => {
@@ -884,11 +880,11 @@ describe('deploy', () => {
884
880
} )
885
881
886
882
// Then
887
- expect ( vi . mocked ( appManagementRequestDoc ) ) . toHaveBeenCalledWith (
888
- 'gid://shopify/Organization/123' ,
889
- expect . anything ( ) ,
890
- 'token' ,
891
- {
883
+ expect ( vi . mocked ( appManagementRequestDoc ) ) . toHaveBeenCalledWith ( {
884
+ organizationId : 'gid://shopify/Organization/123' ,
885
+ query : expect . anything ( ) ,
886
+ token : 'token' ,
887
+ variables : {
892
888
appId : 'gid://shopify/App/123' ,
893
889
version : {
894
890
source : {
@@ -910,13 +906,12 @@ describe('deploy', () => {
910
906
sourceControlUrl : commitReference ,
911
907
} ,
912
908
} ,
913
- undefined ,
914
- expect . objectContaining ( { requestMode : 'slow-request' } ) ,
915
- expect . objectContaining ( {
909
+ requestOptions : { requestMode : 'slow-request' } ,
910
+ unauthorizedHandler : {
916
911
handler : expect . any ( Function ) ,
917
912
type : 'token_refresh' ,
918
- } ) ,
919
- )
913
+ } ,
914
+ } )
920
915
} )
921
916
922
917
test ( 'uses bundleUrl when provided instead of modules' , async ( ) => {
@@ -946,24 +941,23 @@ describe('deploy', () => {
946
941
} )
947
942
948
943
// Then
949
- expect ( vi . mocked ( appManagementRequestDoc ) ) . toHaveBeenCalledWith (
950
- 'gid://shopify/Organization/123' ,
951
- expect . anything ( ) ,
952
- 'token' ,
953
- {
944
+ expect ( vi . mocked ( appManagementRequestDoc ) ) . toHaveBeenCalledWith ( {
945
+ organizationId : 'gid://shopify/Organization/123' ,
946
+ query : expect . anything ( ) ,
947
+ token : 'token' ,
948
+ variables : {
954
949
appId : 'gid://shopify/App/123' ,
955
950
version : {
956
951
sourceUrl : bundleUrl ,
957
952
} ,
958
953
metadata : expect . any ( Object ) ,
959
954
} ,
960
- undefined ,
961
- expect . objectContaining ( { requestMode : 'slow-request' } ) ,
962
- expect . objectContaining ( {
955
+ requestOptions : { requestMode : 'slow-request' } ,
956
+ unauthorizedHandler : {
963
957
handler : expect . any ( Function ) ,
964
958
type : 'token_refresh' ,
965
- } ) ,
966
- )
959
+ } ,
960
+ } )
967
961
} )
968
962
969
963
test ( 'updates name from branding module if present' , async ( ) => {
@@ -1001,25 +995,24 @@ describe('deploy', () => {
1001
995
} )
1002
996
1003
997
// Then
1004
- expect ( vi . mocked ( appManagementRequestDoc ) ) . toHaveBeenCalledWith (
1005
- 'gid://shopify/Organization/123' ,
1006
- expect . anything ( ) ,
1007
- 'token' ,
1008
- expect . objectContaining ( {
998
+ expect ( vi . mocked ( appManagementRequestDoc ) ) . toHaveBeenCalledWith ( {
999
+ organizationId : 'gid://shopify/Organization/123' ,
1000
+ query : expect . anything ( ) ,
1001
+ token : 'token' ,
1002
+ variables : expect . objectContaining ( {
1009
1003
version : {
1010
1004
source : {
1011
1005
name : 'Updated App Name' ,
1012
1006
modules : expect . any ( Array ) ,
1013
1007
} ,
1014
1008
} ,
1015
1009
} ) ,
1016
- undefined ,
1017
- expect . objectContaining ( { requestMode : 'slow-request' } ) ,
1018
- expect . objectContaining ( {
1010
+ requestOptions : { requestMode : 'slow-request' } ,
1011
+ unauthorizedHandler : {
1019
1012
handler : expect . any ( Function ) ,
1020
1013
type : 'token_refresh' ,
1021
- } ) ,
1022
- )
1014
+ } ,
1015
+ } )
1023
1016
} )
1024
1017
1025
1018
test ( 'handles version creation errors' , async ( ) => {
@@ -1147,18 +1140,16 @@ describe('deploy', () => {
1147
1140
} )
1148
1141
1149
1142
// Then
1150
- expect ( vi . mocked ( appManagementRequestDoc ) ) . toHaveBeenCalledWith (
1151
- 'gid://shopify/Organization/123' ,
1152
- AppVersions ,
1153
- 'token' ,
1154
- expect . objectContaining ( { appId} ) ,
1155
- undefined ,
1156
- undefined ,
1157
- expect . objectContaining ( {
1143
+ expect ( vi . mocked ( appManagementRequestDoc ) ) . toHaveBeenCalledWith ( {
1144
+ organizationId : 'gid://shopify/Organization/123' ,
1145
+ query : AppVersions ,
1146
+ token : 'token' ,
1147
+ variables : expect . objectContaining ( { appId} ) ,
1148
+ unauthorizedHandler : {
1158
1149
handler : expect . any ( Function ) ,
1159
1150
type : 'token_refresh' ,
1160
- } ) ,
1161
- )
1151
+ } ,
1152
+ } )
1162
1153
expect ( result ) . toEqual ( {
1163
1154
app : {
1164
1155
id : appId ,
@@ -1224,22 +1215,21 @@ describe('AppManagementClient', () => {
1224
1215
await client . generateSignedUploadUrl ( app )
1225
1216
1226
1217
// Then
1227
- expect ( appManagementRequestDoc ) . toHaveBeenCalledWith (
1228
- app . organizationId ,
1229
- CreateAssetUrl ,
1230
- 'token' ,
1231
- {
1218
+ expect ( appManagementRequestDoc ) . toHaveBeenCalledWith ( {
1219
+ organizationId : app . organizationId ,
1220
+ query : CreateAssetUrl ,
1221
+ token : 'token' ,
1222
+ variables : expect . objectContaining ( {
1232
1223
sourceExtension : 'BR' as SourceExtension ,
1233
- } ,
1234
- expect . objectContaining ( {
1235
- cacheTTL : expect . anything ( ) ,
1236
1224
} ) ,
1237
- undefined ,
1238
- expect . objectContaining ( {
1225
+ unauthorizedHandler : {
1239
1226
handler : expect . any ( Function ) ,
1240
1227
type : 'token_refresh' ,
1241
- } ) ,
1242
- )
1228
+ } ,
1229
+ cacheOptions : {
1230
+ cacheTTL : { minutes : 59 } ,
1231
+ } ,
1232
+ } )
1243
1233
} )
1244
1234
} )
1245
1235
0 commit comments