@@ -191,26 +191,24 @@ describe('FilePatchController', () => {
191
191
const hunkViewsByHunk = new Map ( ) ;
192
192
function registerHunkView ( hunk , view ) { hunkViewsByHunk . set ( hunk , view ) ; }
193
193
194
- // enqueue two stage operations before the first has a chance to be applied
195
194
const controller = new FilePatchController ( { filePatch : unstagedFilePatch , repository, stagingStatus : 'unstaged' , registerHunkView} ) ;
196
195
const view = controller . refs . filePatchView ;
197
196
let hunk = unstagedFilePatch . getHunks ( ) [ 0 ] ;
198
197
let lines = hunk . getLines ( ) ;
199
198
let hunkView = hunkViewsByHunk . get ( hunk ) ;
200
199
hunkView . props . mousedownOnLine ( { detail : 1 } , hunk , lines [ 1 ] ) ;
201
200
view . mouseup ( ) ;
202
- const firstOpPromises = hunkView . props . didClickStageButton ( ) ;
203
201
202
+ // stage lines in rapid succession
203
+ // second stage action is a no-op since the first staging operation is in flight
204
+ const line1StagingPromises = hunkView . props . didClickStageButton ( ) ;
204
205
await hunkView . props . didClickStageButton ( ) ;
205
206
206
- await firstOpPromises . stageOperationPromise ;
207
-
208
- // refresh the hunks
209
- await repository . refresh ( ) ;
207
+ await line1StagingPromises . stageOperationPromise ;
208
+ await repository . refresh ( ) ; // clear the cached file patches
210
209
const modifiedFilePatch = await repository . getFilePatchForPath ( 'sample.js' ) ;
211
210
await controller . update ( { filePatch : modifiedFilePatch , repository, stagingStatus : 'unstaged' , registerHunkView} ) ;
212
-
213
- await firstOpPromises . selectionUpdatePromise ;
211
+ await line1StagingPromises . selectionUpdatePromise ;
214
212
215
213
// assert that only line 1 has been staged
216
214
let expectedLines = originalLines . slice ( ) ;
@@ -226,9 +224,8 @@ describe('FilePatchController', () => {
226
224
hunkView . props . mousedownOnLine ( { detail : 1 } , hunk , lines [ 2 ] ) ;
227
225
view . mouseup ( ) ;
228
226
229
- const thirdOpPromises = hunkView . props . didClickStageButton ( ) ;
230
-
231
- await thirdOpPromises . stageOperationPromise ;
227
+ const line2StagingPromises = hunkView . props . didClickStageButton ( ) ;
228
+ await line2StagingPromises . stageOperationPromise ;
232
229
233
230
// assert that line 2 has now been staged
234
231
expectedLines = originalLines . slice ( ) ;
0 commit comments