@@ -95,6 +95,51 @@ describe('Cloud Code', () => {
95
95
} ) ;
96
96
} ) ;
97
97
98
+ it ( 'can edit cloud code file from dashboard' , async done => {
99
+ const cloudDir = './spec/cloud/cloudCodeRequireFiles.js' ;
100
+ await reconfigureServer ( { cloud : cloudDir } ) ;
101
+ const options = Object . assign ( { } , masterKeyOptions , {
102
+ method : 'GET' ,
103
+ url : Parse . serverURL + '/releases/latest' ,
104
+ } ) ;
105
+ let originalFile = '' ;
106
+ request ( options )
107
+ . then ( res => {
108
+ expect ( Array . isArray ( res . data ) ) . toBe ( true ) ;
109
+ const first = res . data [ 0 ] ;
110
+ expect ( first . userFiles ) . toBeDefined ( ) ;
111
+ expect ( first . checksums ) . toBeDefined ( ) ;
112
+ expect ( first . userFiles ) . toContain ( cloudDir ) ;
113
+ expect ( first . checksums ) . toContain ( cloudDir ) ;
114
+ options . url = Parse . serverURL + '/scripts/spec/cloud/cloudCodeRequireFiles.js' ;
115
+ return request ( options ) ;
116
+ } )
117
+ . then ( res => {
118
+ originalFile = res . data ;
119
+ let response = res . data ;
120
+ expect ( response ) . toContain ( `require('./cloudCodeAbsoluteFile.js` ) ;
121
+ response = response + '\nconst additionalData;\n' ;
122
+ options . method = 'POST' ;
123
+ options . url = Parse . serverURL + '/scripts/spec/cloud/cloudCodeRequireFiles.js' ;
124
+ options . body = {
125
+ data : response ,
126
+ } ;
127
+ return request ( options ) ;
128
+ } )
129
+ . then ( res => {
130
+ expect ( res . data ) . toBe ( 'This file has been saved.' ) ;
131
+ options . method = 'POST' ;
132
+ options . url = Parse . serverURL + '/scripts/spec/cloud/cloudCodeRequireFiles.js' ;
133
+ options . body = {
134
+ data : originalFile ,
135
+ } ;
136
+ return request ( options ) ;
137
+ } )
138
+ . then ( ( ) => {
139
+ done ( ) ;
140
+ } ) ;
141
+ } ) ;
142
+
98
143
it ( 'can create functions' , done => {
99
144
Parse . Cloud . define ( 'hello' , ( ) => {
100
145
return 'Hello world!' ;
0 commit comments