@@ -1005,63 +1005,50 @@ describe('util.submit-addon', () => {
1005
1005
await client . putVersion ( uploadUuid , `${ addonId } ` , { } ) ;
1006
1006
} ) ;
1007
1007
1008
- describe ( 'doFormDataPatch called correctly' , ( ) => {
1008
+ describe ( 'doAfterSubmit' , ( ) => {
1009
+ const downloadUrl = 'https://a.download/url' ;
1010
+ const newVersionId = sampleVersionDetail . id ;
1011
+ const editUrl = sampleVersionDetail . editUrl ;
1009
1012
const patchData = { version : { source : 'somesource' } } ;
1010
- const metaDataJson = { some : 'metadata' } ;
1011
- const newVersionId = 123456 ;
1012
- const editUrl = 'http://some/url' ;
1013
- const stubbedClient = new Client ( clientDefaults ) ;
1014
-
1015
- const submitResponse = {
1016
- guid : addonId ,
1017
- version : { id : newVersionId , edit_url : editUrl } ,
1018
- } ;
1019
- sinon
1020
- . stub ( stubbedClient , 'doNewAddonOrVersionSubmit' )
1021
- . resolves ( submitResponse ) ;
1022
- sinon . stub ( stubbedClient , 'doNewAddonSubmit' ) . resolves ( submitResponse ) ;
1023
- sinon . stub ( stubbedClient , 'doAfterSubmit' ) . resolves ( ) ;
1024
1013
1014
+ let approvalStub ;
1015
+ let downloadStub ;
1025
1016
let doFormDataPatchStub ;
1026
1017
1027
1018
before ( ( ) => {
1019
+ approvalStub = sinon
1020
+ . stub ( client , 'waitForApproval' )
1021
+ . resolves ( downloadUrl ) ;
1022
+ downloadStub = sinon . stub ( client , 'downloadSignedFile' ) . resolves ( ) ;
1028
1023
doFormDataPatchStub = sinon
1029
- . stub ( stubbedClient , 'doFormDataPatch' )
1024
+ . stub ( client , 'doFormDataPatch' )
1030
1025
. resolves ( ) ;
1031
1026
} ) ;
1032
1027
1033
1028
afterEach ( ( ) => {
1034
- doFormDataPatchStub . reset ( ) ;
1029
+ approvalStub . resetHistory ( ) ;
1030
+ downloadStub . resetHistory ( ) ;
1031
+ doFormDataPatchStub . resetHistory ( ) ;
1035
1032
} ) ;
1036
1033
1037
- it ( 'calls doFormDataPatch if patchData.version is defined for postNewAddon' , async ( ) => {
1038
- const saveIdToFileStub = sinon . stub ( ) . resolves ( ) ;
1039
- const savedIdPath = 'some/saved/id/path' ;
1040
- await stubbedClient . postNewAddon (
1041
- uploadUuid ,
1042
- savedIdPath ,
1043
- metaDataJson ,
1044
- patchData ,
1045
- saveIdToFileStub ,
1046
- ) ;
1034
+ it ( 'skips download if approval timeout is 0' , async ( ) => {
1035
+ client . approvalCheckTimeout = 0 ;
1036
+ await client . doAfterSubmit ( addonId , newVersionId , editUrl ) ;
1037
+ sinon . assert . notCalled ( approvalStub ) ;
1038
+ sinon . assert . notCalled ( downloadStub ) ;
1039
+ } ) ;
1047
1040
1048
- sinon . assert . calledWith (
1049
- doFormDataPatchStub ,
1050
- patchData . version ,
1051
- addonId ,
1052
- newVersionId ,
1053
- ) ;
1041
+ it ( 'downloads the signed xpi if approval timeout > 0' , async ( ) => {
1042
+ client . approvalCheckTimeout = 1 ;
1043
+ await client . doAfterSubmit ( addonId , newVersionId , editUrl ) ;
1044
+ sinon . assert . calledWith ( approvalStub , addonId , newVersionId ) ;
1045
+ sinon . assert . calledWith ( downloadStub , new URL ( downloadUrl ) , addonId ) ;
1054
1046
} ) ;
1055
1047
1056
- it ( 'calls doFormDataPatch if patchData.version is defined for putVersion' , async ( ) => {
1057
- await stubbedClient . putVersion (
1058
- uploadUuid ,
1059
- addonId ,
1060
- metaDataJson ,
1061
- patchData ,
1062
- ) ;
1048
+ it ( 'calls doFormDataPatch if patchData.version is defined' , async ( ) => {
1049
+ client . approvalCheckTimeout = 0 ;
1050
+ await client . doAfterSubmit ( addonId , newVersionId , editUrl , patchData ) ;
1063
1051
1064
- sinon . assert . called ( doFormDataPatchStub ) ;
1065
1052
sinon . assert . calledWith (
1066
1053
doFormDataPatchStub ,
1067
1054
patchData . version ,
@@ -1070,53 +1057,13 @@ describe('util.submit-addon', () => {
1070
1057
) ;
1071
1058
} ) ;
1072
1059
1073
- it ( 'does not call doFormDataPatch is patchData.version is undefined for postNewAddon' , async ( ) => {
1074
- const saveIdToFileStub = sinon . stub ( ) . resolves ( ) ;
1075
- const savedIdPath = 'some/saved/id/path' ;
1076
- await stubbedClient . postNewAddon (
1077
- uploadUuid ,
1078
- savedIdPath ,
1079
- metaDataJson ,
1080
- { } ,
1081
- saveIdToFileStub ,
1082
- ) ;
1083
-
1084
- sinon . assert . notCalled ( doFormDataPatchStub ) ;
1085
- } ) ;
1086
-
1087
- it ( 'does not call doFormDataPatch is patchData.version is undefined for putVersion' , async ( ) => {
1088
- await stubbedClient . putVersion ( uploadUuid , addonId , metaDataJson ) ;
1089
-
1090
- sinon . assert . notCalled ( doFormDataPatchStub ) ;
1091
- } ) ;
1092
- } ) ;
1093
-
1094
- describe ( 'doAfterSubmit' , ( ) => {
1095
- const downloadUrl = 'https://a.download/url' ;
1096
- let approvalStub ;
1097
- let downloadStub ;
1098
- const newVersionId = sampleVersionDetail . id ;
1099
- const editUrl = sampleVersionDetail . editUrl ;
1100
-
1101
- before ( ( ) => {
1102
- approvalStub = sinon
1103
- . stub ( client , 'waitForApproval' )
1104
- . resolves ( downloadUrl ) ;
1105
- downloadStub = sinon . stub ( client , 'downloadSignedFile' ) . resolves ( ) ;
1106
- } ) ;
1107
-
1108
- it ( 'skips download if approval timeout is 0' , async ( ) => {
1060
+ it ( 'does not call doFormDataPatch is patchData.version is undefined' , async ( ) => {
1109
1061
client . approvalCheckTimeout = 0 ;
1110
- await client . doAfterSubmit ( addonId , newVersionId , editUrl ) ;
1111
- sinon . assert . notCalled ( approvalStub ) ;
1112
- sinon . assert . notCalled ( downloadStub ) ;
1113
- } ) ;
1062
+ await client . doAfterSubmit ( addonId , newVersionId , editUrl , {
1063
+ version : undefined ,
1064
+ } ) ;
1114
1065
1115
- it ( 'downloads the signed xpi if approval timeout > 0' , async ( ) => {
1116
- client . approvalCheckTimeout = 1 ;
1117
- await client . doAfterSubmit ( addonId , newVersionId , editUrl ) ;
1118
- sinon . assert . calledWith ( approvalStub , addonId , newVersionId ) ;
1119
- sinon . assert . calledWith ( downloadStub , new URL ( downloadUrl ) , addonId ) ;
1066
+ sinon . assert . notCalled ( doFormDataPatchStub ) ;
1120
1067
} ) ;
1121
1068
} ) ;
1122
1069
} ) ;
0 commit comments