@@ -1005,63 +1005,50 @@ describe('util.submit-addon', () => {
10051005 await client . putVersion ( uploadUuid , `${ addonId } ` , { } ) ;
10061006 } ) ;
10071007
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 ;
10091012 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 ( ) ;
10241013
1014+ let approvalStub ;
1015+ let downloadStub ;
10251016 let doFormDataPatchStub ;
10261017
10271018 before ( ( ) => {
1019+ approvalStub = sinon
1020+ . stub ( client , 'waitForApproval' )
1021+ . resolves ( downloadUrl ) ;
1022+ downloadStub = sinon . stub ( client , 'downloadSignedFile' ) . resolves ( ) ;
10281023 doFormDataPatchStub = sinon
1029- . stub ( stubbedClient , 'doFormDataPatch' )
1024+ . stub ( client , 'doFormDataPatch' )
10301025 . resolves ( ) ;
10311026 } ) ;
10321027
10331028 afterEach ( ( ) => {
1034- doFormDataPatchStub . reset ( ) ;
1029+ approvalStub . resetHistory ( ) ;
1030+ downloadStub . resetHistory ( ) ;
1031+ doFormDataPatchStub . resetHistory ( ) ;
10351032 } ) ;
10361033
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+ } ) ;
10471040
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 ) ;
10541046 } ) ;
10551047
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 ) ;
10631051
1064- sinon . assert . called ( doFormDataPatchStub ) ;
10651052 sinon . assert . calledWith (
10661053 doFormDataPatchStub ,
10671054 patchData . version ,
@@ -1070,53 +1057,13 @@ describe('util.submit-addon', () => {
10701057 ) ;
10711058 } ) ;
10721059
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 ( ) => {
11091061 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+ } ) ;
11141065
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 ) ;
11201067 } ) ;
11211068 } ) ;
11221069 } ) ;
0 commit comments