From 3305c65ae6babe01c1237175903b0397f4d9882b Mon Sep 17 00:00:00 2001 From: James Date: Thu, 4 Apr 2024 19:14:01 -0400 Subject: [PATCH] chore: adds retryWrites, fixes a few flakes --- test/fields/e2e.spec.ts | 5 +++-- test/helpers/startMemoryDB.ts | 8 ++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/test/fields/e2e.spec.ts b/test/fields/e2e.spec.ts index 2b99491d2e..8f22ec34a0 100644 --- a/test/fields/e2e.spec.ts +++ b/test/fields/e2e.spec.ts @@ -1917,9 +1917,10 @@ describe('fields', () => { test('should upload using the document drawer', async () => { await uploadImage() + await wait(500) // Open the media drawer and create a png upload await page.locator('.field-type.upload .upload__toggler.doc-drawer__toggler').click() - await wait(500) // TODO: Fix this. Need to wait a bit until the form in the drawer mounted, otherwise values sometimes disappear. This is an issue for all drawers + await wait(1000) // TODO: Fix this. Need to wait a bit until the form in the drawer mounted, otherwise values sometimes disappear. This is an issue for all drawers await page .locator('[id^=doc-drawer_uploads_1_] .file-field__upload input[type="file"]') .setInputFiles(path.resolve(dirname, './uploads/payload.png')) @@ -1945,8 +1946,8 @@ describe('fields', () => { test('should clear selected upload', async () => { await uploadImage() + await wait(1000) // TODO: Fix this. Need to wait a bit until the form in the drawer mounted, otherwise values sometimes disappear. This is an issue for all drawers await page.locator('.field-type.upload .upload__toggler.doc-drawer__toggler').click() - await wait(500) // TODO: Fix this. Need to wait a bit until the form in the drawer mounted, otherwise values sometimes disappear. This is an issue for all drawers await page .locator('[id^=doc-drawer_uploads_1_] .file-field__upload input[type="file"]') diff --git a/test/helpers/startMemoryDB.ts b/test/helpers/startMemoryDB.ts index 7244302da2..cc67692aa0 100644 --- a/test/helpers/startMemoryDB.ts +++ b/test/helpers/startMemoryDB.ts @@ -12,13 +12,17 @@ export default async () => { (!process.env.PAYLOAD_DATABASE || process.env.PAYLOAD_DATABASE === 'mongodb') && !global._mongoMemoryServer ) { - global._mongoMemoryServer = await MongoMemoryReplSet.create({ + const db = await MongoMemoryReplSet.create({ replSet: { count: 3, dbName: 'payloadmemory', }, }) - process.env.MONGODB_MEMORY_SERVER_URI = global._mongoMemoryServer.getUri() + global._mongoMemoryServer = db + + process.env.MONGODB_MEMORY_SERVER_URI = `${global._mongoMemoryServer.getUri()}&retryWrites=true` + + console.log(process.env.MONGODB_MEMORY_SERVER_URI) } }