Merge pull request #21510 from overleaf/jpa-dependency-cleanup

[web] dependency cleanup

GitOrigin-RevId: 5b1e0ace2b0acfd7b1b839520f7c24acda8027e3
This commit is contained in:
Jakob Ackermann
2024-11-01 09:05:28 +00:00
committed by Copybot
parent 5bb90dc6cb
commit 9745c045ba
8 changed files with 57 additions and 112 deletions
@@ -44,8 +44,7 @@ describe('ArchiveManager', function () {
open: sinon.stub().callsArgWith(2, null, this.zipfile),
}),
'@overleaf/metrics': this.metrics,
fs: (this.fs = {}),
'fs-extra': (this.fse = {}),
fs: (this.fs = { mkdir: sinon.stub().yields() }),
'./ArchiveErrors': ArchiveErrors,
},
})
@@ -70,7 +69,6 @@ describe('ArchiveManager', function () {
.callsArgWith(1, null, this.readStream)
this.writeStream = new events.EventEmitter()
this.fs.createWriteStream = sinon.stub().returns(this.writeStream)
this.fse.ensureDir = sinon.stub().callsArg(1)
this.ArchiveManager.extractZipArchive(
this.source,
this.destination,
@@ -101,7 +99,6 @@ describe('ArchiveManager', function () {
.callsArgWith(1, null, this.readStream)
this.writeStream = new events.EventEmitter()
this.fs.createWriteStream = sinon.stub().returns(this.writeStream)
this.fse.ensureDir = sinon.stub().callsArg(1)
this.ArchiveManager.extractZipArchive(
this.source,
this.destination,
@@ -267,7 +264,6 @@ describe('ArchiveManager', function () {
this.zipfile.openReadStream = sinon
.stub()
.callsArgWith(1, null, this.readStream)
this.fse.ensureDir = sinon.stub().callsArg(1)
this.ArchiveManager.extractZipArchive(
this.source,
this.destination,
@@ -291,10 +287,12 @@ describe('ArchiveManager', function () {
})
it('should treat the backslashes as a directory separator when creating the directory', function () {
this.fse.ensureDir.should.be.calledWith(`${this.destination}/wombat`)
return this.fse.ensureDir.should.be.calledWith(
`${this.destination}/potato`
)
this.fs.mkdir.should.be.calledWith(`${this.destination}/wombat`, {
recursive: true,
})
this.fs.mkdir.should.be.calledWith(`${this.destination}/potato`, {
recursive: true,
})
})
it('should treat the backslashes as a directory separator when creating the file', function () {
@@ -367,7 +365,6 @@ describe('ArchiveManager', function () {
.callsArgWith(1, null, this.readStream)
this.writeStream = new events.EventEmitter()
this.fs.createWriteStream = sinon.stub().returns(this.writeStream)
this.fse.ensureDir = sinon.stub().callsArg(1)
this.ArchiveManager.extractZipArchive(
this.source,
this.destination,
@@ -405,7 +402,6 @@ describe('ArchiveManager', function () {
.callsArgWith(1, null, this.readStream)
this.writeStream = new events.EventEmitter()
this.fs.createWriteStream = sinon.stub().returns(this.writeStream)
this.fse.ensureDir = sinon.stub().callsArg(1)
this.ArchiveManager.extractZipArchive(
this.source,
this.destination,
@@ -62,7 +62,9 @@ describe('ProjectUploadManager', function () {
]
this.fs = {
remove: sinon.stub().resolves(),
promises: {
rm: sinon.stub().resolves(),
},
}
this.ArchiveManager = {
promises: {
@@ -146,7 +148,7 @@ describe('ProjectUploadManager', function () {
this.ProjectUploadManager = SandboxedModule.require(MODULE_PATH, {
requires: {
'fs-extra': this.fs,
fs: this.fs,
'./ArchiveManager': this.ArchiveManager,
'../../models/Doc': { Doc: this.Doc },
'../Docstore/DocstoreManager': this.DocstoreManager,
@@ -230,7 +232,10 @@ describe('ProjectUploadManager', function () {
})
it('should remove the destination directory afterwards', function () {
this.fs.remove.should.have.been.calledWith(this.extractedZipPath)
this.fs.promises.rm.should.have.been.calledWith(this.extractedZipPath, {
recursive: true,
force: true,
})
})
})
@@ -311,7 +316,10 @@ describe('ProjectUploadManager', function () {
})
it('should remove the destination directory afterwards', function () {
this.fs.remove.should.have.been.calledWith(this.extractedZipPath)
this.fs.promises.rm.should.have.been.calledWith(this.extractedZipPath, {
recursive: true,
force: true,
})
})
describe('when initializing the folder structure fails', function () {