Skip to content

Commit

Permalink
test: Fix tests failing intermittently on CI (#2339)
Browse files Browse the repository at this point in the history
  • Loading branch information
taratatach authored Jul 31, 2024
2 parents 3338647 + 42a9f34 commit 278c081
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 23 deletions.
3 changes: 2 additions & 1 deletion test/support/builders/metadata/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ module.exports = class BaseMetadataBuilder {
) /*: this */ {
this.doc = {
..._.cloneDeep(was),
...this.doc
...this.doc,
updated_at: was.updated_at || this.doc.updated_at
}
this.doc.moveFrom = was
if (childMove) this.doc.moveFrom.childMove = true
Expand Down
36 changes: 14 additions & 22 deletions test/unit/remote/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -712,35 +712,27 @@ describe('remote.Remote', function () {

describe('moveAsync', () => {
context('with a file', () => {
let old /*: Metadata */
let doc /*: Metadata */
let newDir /*: RemoteDoc */

beforeEach(async () => {
newDir = await builders
it('moves the file', async function () {
const dstDir = await builders
.remoteDir()
.name('moved-to')
.inRootDir()
.create()
await builders.metadir().fromRemote(newDir).upToDate().create()
await builders.metadir().fromRemote(dstDir).upToDate().create()

const remoteDoc = await builders
.remoteFile()
.name('cat6.jpg')
.data('meow')
.create()
old = builders
.metafile()
.fromRemote(remoteDoc)
.changedSide('local')
.build()
doc = builders
const old = builders.metafile().fromRemote(remoteDoc).upToDate().build()
const doc = builders
.metafile()
.moveFrom(old)
.path('moved-to/cat7.jpg')
.changedSide('local')
.build()
})

it('moves the file', async function () {
await this.remote.moveAsync(doc, old)

const file = await cozy.files.statById(doc.remote._id)
Expand All @@ -749,7 +741,7 @@ describe('remote.Remote', function () {
_rev: doc.remote._rev
})
should(file.attributes).have.properties({
dir_id: newDir._id,
dir_id: dstDir._id,
name: 'cat7.jpg',
type: 'file',
size: '4'
Expand All @@ -762,7 +754,7 @@ describe('remote.Remote', function () {

context('with a folder', function () {
it('moves the folder in the Cozy', async function () {
const created = await builders
const remoteDoc = await builders
.remoteDir()
.name('folder-4')
.inDir(couchdbFolder)
Expand All @@ -771,15 +763,15 @@ describe('remote.Remote', function () {
.create()
const old = await builders
.metadir()
.fromRemote(created)
.changedSide('local')
.create()
.fromRemote(remoteDoc)
.upToDate()
.build()
const doc = await builders
.metadir()
.moveFrom(old)
.path('couchdb-folder/folder-5')
.updatedAt('2018-07-31T05:37:43.770Z')
.create()
.changedSide('local')
.build()

await this.remote.moveAsync(doc, old)

Expand Down

0 comments on commit 278c081

Please sign in to comment.