소스 검색

[web] return file type in revertFile (#18995)

* [web] return file type in revertFile

* fix revertFile unit test

* fix formatting

GitOrigin-RevId: e4ac0500ff6c72c7f7fa23a5f61b09ed31a28da0
Domagoj Kriskovic 2 년 전
부모
커밋
c3c97d9fb9
2개의 변경된 파일과 9개의 추가작업 그리고 6개의 파일을 삭제
  1. 6 1
      services/web/app/src/Features/History/RestoreManager.js
  2. 3 5
      services/web/test/unit/src/History/RestoreManagerTests.js

+ 6 - 1
services/web/app/src/Features/History/RestoreManager.js

@@ -185,7 +185,7 @@ const RestoreManager = {
       newCommentThreadData
     )
 
-    return await EditorController.promises.addDocWithRanges(
+    const { _id } = await EditorController.promises.addDocWithRanges(
       projectId,
       parentFolderId,
       basename,
@@ -194,6 +194,11 @@ const RestoreManager = {
       origin,
       userId
     )
+
+    return {
+      _id,
+      type: importInfo.type,
+    }
   },
 
   async _findOrCreateFolder(projectId, dirname) {

+ 3 - 5
services/web/test/unit/src/History/RestoreManagerTests.js

@@ -291,9 +291,7 @@ describe('RestoreManager', function () {
           .resolves([{ toV: this.version, meta: { end_ts: Date.now() } }])
         this.EditorController.promises.addDocWithRanges = sinon
           .stub()
-          .resolves(
-            (this.addedFile = { doc: 'mock-doc', folderId: 'mock-folder' })
-          )
+          .resolves((this.addedFile = { _id: 'mock-doc', type: 'doc' }))
       })
 
       describe("when reverting a file that doesn't current exist", function () {
@@ -327,7 +325,7 @@ describe('RestoreManager', function () {
         })
 
         it('should return the created entity', function () {
-          expect(this.data).to.equal(this.addedFile)
+          expect(this.data).to.deep.equal(this.addedFile)
         })
 
         it('should look up ranges', function () {
@@ -408,7 +406,7 @@ describe('RestoreManager', function () {
         })
 
         it('should return the created entity', function () {
-          expect(this.data).to.equal(this.addedFile)
+          expect(this.data).to.deep.equal(this.addedFile)
         })
 
         it('should look up ranges', function () {