diff --git a/packages/payload/src/index.ts b/packages/payload/src/index.ts index 03d9d14e2..062c9a333 100644 --- a/packages/payload/src/index.ts +++ b/packages/payload/src/index.ts @@ -79,7 +79,7 @@ export class BasePayload { return create(this, options) } - db: BaseDatabaseAdapter + db: DatabaseAdapter decrypt = decrypt @@ -469,6 +469,6 @@ interface RequestContext { [key: string]: unknown } -// type DatabaseAdapter = BaseDatabaseAdapter +type DatabaseAdapter = BaseDatabaseAdapter -export type { GeneratedTypes, Payload, RequestContext } +export type { DatabaseAdapter, GeneratedTypes, Payload, RequestContext } diff --git a/test/admin/e2e.spec.ts b/test/admin/e2e.spec.ts index 12337a7dd..fad521a77 100644 --- a/test/admin/e2e.spec.ts +++ b/test/admin/e2e.spec.ts @@ -367,6 +367,7 @@ describe('admin', () => { test('collection — should render preview button when `admin.preview` is set', async () => { const collectionWithPreview = new AdminUrlUtil(serverURL, postsCollectionSlug) await page.goto(collectionWithPreview.create) + await page.waitForURL(collectionWithPreview.create) await page.locator('#field-title').fill(title) await saveDocAndAssert(page) await expect(page.locator('.btn.preview-btn')).toBeVisible() @@ -375,6 +376,7 @@ describe('admin', () => { test('collection — should not render preview button when `admin.preview` is not set', async () => { const collectionWithoutPreview = new AdminUrlUtil(serverURL, group1Collection1Slug) await page.goto(collectionWithoutPreview.create) + await page.waitForURL(collectionWithoutPreview.create) await page.locator('#field-title').fill(title) await saveDocAndAssert(page) await expect(page.locator('.btn.preview-btn')).toBeHidden() @@ -769,6 +771,7 @@ describe('admin', () => { test('should link second cell', async () => { const { id } = await createPost() + await page.reload() const linkCell = page.locator(`${tableRowLocator} td`).nth(1).locator('a') await expect(linkCell).toHaveAttribute('href', `/admin/collections/posts/${id}`) @@ -1180,6 +1183,7 @@ describe('admin', () => { }) test('should select multiple rows', async () => { + await page.reload() const selectAll = page.locator('.checkbox-input:has(#select-all)') await page.locator('.row-1 .cell-_select input').check() @@ -1251,6 +1255,7 @@ describe('admin', () => { }) test('should sort', async () => { + await page.reload() const upChevron = page.locator('#heading-number .sort-column__asc') const downChevron = page.locator('#heading-number .sort-column__desc') diff --git a/test/admin/seed.ts b/test/admin/seed.ts index d3d818010..3ce5f37df 100644 --- a/test/admin/seed.ts +++ b/test/admin/seed.ts @@ -15,6 +15,19 @@ import { } from './slugs.js' export const seed = async (_payload) => { + if (_payload.db.name === 'mongoose') { + await Promise.all( + _payload.config.collections.map(async (coll) => { + await new Promise((resolve, reject) => { + _payload.db?.collections[coll.slug]?.ensureIndexes(function (err) { + if (err) reject(err) + resolve(true) + }) + }) + }), + ) + } + await executePromises( [ () => diff --git a/test/fields-relationship/e2e.spec.ts b/test/fields-relationship/e2e.spec.ts index 14cad4204..db42490b1 100644 --- a/test/fields-relationship/e2e.spec.ts +++ b/test/fields-relationship/e2e.spec.ts @@ -396,6 +396,8 @@ describe('fields - relationship', () => { ) await button.click() + await wait(500) + const documentDrawer = page.locator('[id^=doc-drawer_relation-one_1_]') await expect(documentDrawer).toBeVisible() }) diff --git a/test/fields/e2e.spec.ts b/test/fields/e2e.spec.ts index 2b99491d2..8f22ec34a 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 7244302da..cc67692aa 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) } }