chore(test): fix flakey relationship tests (#5892)
This commit is contained in:
12
test/dev.js
12
test/dev.js
@@ -2,9 +2,16 @@ import minimist from 'minimist'
|
||||
import { nextDev } from 'next/dist/cli/next-dev.js'
|
||||
import open from 'open'
|
||||
import { getNextJSRootDir } from './helpers/getNextJSRootDir.js'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import path from 'node:path'
|
||||
import fs from 'node:fs'
|
||||
import chalk from 'chalk'
|
||||
|
||||
import { createTestHooks } from './testHooks.js'
|
||||
|
||||
const filename = fileURLToPath(import.meta.url)
|
||||
const dirname = path.dirname(filename)
|
||||
|
||||
process.env.PAYLOAD_DROP_DATABASE = 'true'
|
||||
|
||||
const {
|
||||
@@ -12,6 +19,11 @@ const {
|
||||
...args
|
||||
} = minimist(process.argv.slice(2))
|
||||
|
||||
if (!fs.existsSync(path.resolve(dirname, testSuiteArg))) {
|
||||
console.log(chalk.red(`ERROR: The test folder "${testSuiteArg}" does not exist`))
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
if (args.turbo === true) {
|
||||
process.env.TURBOPACK = '1'
|
||||
}
|
||||
|
||||
@@ -388,7 +388,13 @@ describe('relationship', () => {
|
||||
await page.waitForURL(url.create)
|
||||
|
||||
const field = page.locator('#field-relationHasManyPolymorphic')
|
||||
|
||||
// wait for relationship options to load
|
||||
const textFieldPromise = page.waitForResponse(/api\/text-fields/)
|
||||
const arrayFieldPromise = page.waitForResponse(/api\/array-fields/)
|
||||
await field.click()
|
||||
await textFieldPromise
|
||||
await arrayFieldPromise
|
||||
|
||||
const textDocsGroup = page.locator('.rs__group-heading:has-text("Text Fields")')
|
||||
const firstTextDocOption = textDocsGroup.locator('+div .rs__option').first()
|
||||
|
||||
@@ -145,8 +145,8 @@ export async function openNav(page: Page): Promise<void> {
|
||||
}
|
||||
|
||||
export async function openDocDrawer(page: Page, selector: string): Promise<void> {
|
||||
await wait(300) // wait for parent form state to initialize
|
||||
await page.locator(selector).click({ delay: 100 })
|
||||
await wait(500) // wait for parent form state to initialize
|
||||
await page.locator(selector).click()
|
||||
await wait(500) // wait for drawer form state to initialize
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user