chore: speed up tests by not running seed twice for the first test, and reduce flakiness of lexical e2e test suite
This commit is contained in:
@@ -126,6 +126,8 @@ export default buildConfigWithDefaults({
|
||||
],
|
||||
},
|
||||
onInit: async (payload) => {
|
||||
await clearAndSeedEverything(payload)
|
||||
if (process.env.SEED_IN_CONFIG_ONINIT !== 'false') {
|
||||
await clearAndSeedEverything(payload)
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
@@ -68,6 +68,7 @@ describe('admin', () => {
|
||||
let serverURL: string
|
||||
|
||||
beforeAll(async ({ browser }) => {
|
||||
process.env.SEED_IN_CONFIG_ONINIT = 'false' // Makes it so the payload config onInit seed is not run. Otherwise, the seed would be run unnecessarily twice for the initial test run - once for beforeEach and once for onInit
|
||||
;({ payload, serverURL } = await initPayloadE2E({ config, dirname }))
|
||||
geoUrl = new AdminUrlUtil(serverURL, geoCollectionSlug)
|
||||
url = new AdminUrlUtil(serverURL, postsCollectionSlug)
|
||||
|
||||
@@ -78,6 +78,8 @@ export default buildConfigWithDefaults({
|
||||
locales: ['en', 'es'],
|
||||
},
|
||||
onInit: async (payload) => {
|
||||
await clearAndSeedEverything(payload)
|
||||
if (process.env.SEED_IN_CONFIG_ONINIT !== 'false') {
|
||||
await clearAndSeedEverything(payload)
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
@@ -42,18 +42,18 @@ let serverURL: string
|
||||
|
||||
describe('fields', () => {
|
||||
beforeAll(async ({ browser }) => {
|
||||
process.env.SEED_IN_CONFIG_ONINIT = 'false' // Makes it so the payload config onInit seed is not run. Otherwise, the seed would be run unnecessarily twice for the initial test run - once for beforeEach and once for onInit
|
||||
;({ payload, serverURL } = await initPayloadE2E({ config, dirname }))
|
||||
|
||||
client = new RESTClient(null, { defaultSlug: 'users', serverURL })
|
||||
await client.login()
|
||||
|
||||
const context = await browser.newContext()
|
||||
page = await context.newPage()
|
||||
initPageConsoleErrorCatch(page)
|
||||
})
|
||||
beforeEach(async () => {
|
||||
await clearAndSeedEverything(payload)
|
||||
await client.logout()
|
||||
if (client) {
|
||||
await client.logout()
|
||||
}
|
||||
client = new RESTClient(null, { defaultSlug: 'users', serverURL })
|
||||
await client.login()
|
||||
})
|
||||
|
||||
@@ -41,20 +41,8 @@ import { initPayloadInt } from '../helpers/initPayloadInt.js'
|
||||
|
||||
describe('Fields', () => {
|
||||
beforeAll(async () => {
|
||||
process.env.SEED_IN_CONFIG_ONINIT = 'false' // Makes it so the payload config onInit seed is not run. Otherwise, the seed would be run unnecessarily twice for the initial test run - once for beforeEach and once for onInit
|
||||
;({ payload, restClient } = await initPayloadInt(configPromise))
|
||||
|
||||
await restClient.login({
|
||||
slug: 'users',
|
||||
credentials: devUser,
|
||||
})
|
||||
|
||||
user = await payload.login({
|
||||
collection: 'users',
|
||||
data: {
|
||||
email: devUser.email,
|
||||
password: devUser.password,
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
@@ -69,6 +57,14 @@ describe('Fields', () => {
|
||||
slug: 'users',
|
||||
credentials: devUser,
|
||||
})
|
||||
|
||||
user = await payload.login({
|
||||
collection: 'users',
|
||||
data: {
|
||||
email: devUser.email,
|
||||
password: devUser.password,
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
describe('text', () => {
|
||||
|
||||
@@ -31,14 +31,19 @@ let serverURL: string
|
||||
async function navigateToLexicalFields() {
|
||||
const url: AdminUrlUtil = new AdminUrlUtil(serverURL, 'lexical-fields')
|
||||
await page.goto(url.list)
|
||||
await page.locator('.row-1 .cell-title a').click()
|
||||
const linkToDoc = page.locator('tbody tr:first-child .cell-title a').first()
|
||||
await expect(() => expect(linkToDoc).toBeTruthy()).toPass({ timeout: 45000 })
|
||||
const linkDocHref = await linkToDoc.getAttribute('href')
|
||||
|
||||
await linkToDoc.click()
|
||||
|
||||
await page.waitForURL(`**${linkDocHref}`)
|
||||
}
|
||||
|
||||
describe('lexical', () => {
|
||||
beforeAll(async ({ browser }) => {
|
||||
process.env.SEED_IN_CONFIG_ONINIT = 'false' // Makes it so the payload config onInit seed is not run. Otherwise, the seed would be run unnecessarily twice for the initial test run - once for beforeEach and once for onInit
|
||||
;({ payload, serverURL } = await initPayloadE2E({ config, dirname }))
|
||||
client = new RESTClient(null, { defaultSlug: 'rich-text-fields', serverURL })
|
||||
await client.login()
|
||||
|
||||
const context = await browser.newContext()
|
||||
page = await context.newPage()
|
||||
@@ -47,7 +52,9 @@ describe('lexical', () => {
|
||||
})
|
||||
beforeEach(async () => {
|
||||
await clearAndSeedEverything(payload)
|
||||
await client.logout()
|
||||
if (client) {
|
||||
await client.logout()
|
||||
}
|
||||
client = new RESTClient(null, { defaultSlug: 'rich-text-fields', serverURL })
|
||||
await client.login()
|
||||
})
|
||||
|
||||
@@ -44,13 +44,14 @@ let createdRichTextDocID: number | string = null
|
||||
|
||||
describe('Lexical', () => {
|
||||
beforeAll(async () => {
|
||||
process.env.SEED_IN_CONFIG_ONINIT = 'false' // Makes it so the payload config onInit seed is not run. Otherwise, the seed would be run unnecessarily twice for the initial test run - once for beforeEach and once for onInit
|
||||
const config = await startMemoryDB(configPromise)
|
||||
payload = await getPayload({ config })
|
||||
restClient = new NextRESTClient(payload.config)
|
||||
})
|
||||
|
||||
beforeEach(async () => {
|
||||
await clearAndSeedEverything(payload)
|
||||
restClient = new NextRESTClient(payload.config)
|
||||
await restClient.login({
|
||||
slug: 'users',
|
||||
credentials: devUser,
|
||||
|
||||
@@ -28,9 +28,9 @@ describe('Live Preview', () => {
|
||||
const linkToDoc = page.locator('tbody tr:first-child .cell-slug a').first()
|
||||
|
||||
await expect(() => expect(linkToDoc).toBeTruthy()).toPass({ timeout: 45000 })
|
||||
const linkDocHref = await linkToDoc.getAttribute('href')
|
||||
|
||||
await linkToDoc.click()
|
||||
const linkDocHref = await linkToDoc.getAttribute('href')
|
||||
|
||||
await page.waitForURL(`**${linkDocHref}`)
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@ export default buildConfigWithDefaults({
|
||||
locales: ['en', 'es'],
|
||||
},
|
||||
onInit: async (payload) => {
|
||||
await clearAndSeedEverything(payload)
|
||||
if (process.env.SEED_IN_CONFIG_ONINIT !== 'false') {
|
||||
await clearAndSeedEverything(payload)
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
@@ -72,6 +72,7 @@ describe('versions', () => {
|
||||
let postURL: AdminUrlUtil
|
||||
|
||||
beforeAll(async ({ browser }) => {
|
||||
process.env.SEED_IN_CONFIG_ONINIT = 'false' // Makes it so the payload config onInit seed is not run. Otherwise, the seed would be run unnecessarily twice for the initial test run - once for beforeEach and once for onInit
|
||||
;({ payload, serverURL } = await initPayloadE2E({ config, dirname }))
|
||||
const context = await browser.newContext()
|
||||
page = await context.newPage()
|
||||
|
||||
@@ -35,7 +35,18 @@ const formatGraphQLID = (id: number | string) =>
|
||||
|
||||
describe('Versions', () => {
|
||||
beforeAll(async () => {
|
||||
process.env.SEED_IN_CONFIG_ONINIT = 'false' // Makes it so the payload config onInit seed is not run. Otherwise, the seed would be run unnecessarily twice for the initial test run - once for beforeEach and once for onInit
|
||||
;({ payload, restClient } = await initPayloadInt(configPromise))
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
if (typeof payload.db.destroy === 'function') {
|
||||
await payload.db.destroy()
|
||||
}
|
||||
})
|
||||
|
||||
beforeEach(async () => {
|
||||
await clearAndSeedEverything(payload)
|
||||
|
||||
const login = `
|
||||
mutation {
|
||||
@@ -51,16 +62,6 @@ describe('Versions', () => {
|
||||
.then((res) => res.json())
|
||||
|
||||
token = data.loginUser.token
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
if (typeof payload.db.destroy === 'function') {
|
||||
await payload.db.destroy()
|
||||
}
|
||||
})
|
||||
|
||||
beforeEach(async () => {
|
||||
await clearAndSeedEverything(payload)
|
||||
|
||||
// now: initialize
|
||||
const autosavePost = await payload.create({
|
||||
|
||||
Reference in New Issue
Block a user