chore: converts e2e suites to new pattern
This commit is contained in:
@@ -1,11 +1,13 @@
|
|||||||
import type { Payload } from 'payload'
|
import type { Payload } from 'payload'
|
||||||
|
|
||||||
|
import path from 'path'
|
||||||
|
import { fileURLToPath } from 'url'
|
||||||
|
|
||||||
import type { NextRESTClient } from '../helpers/NextRESTClient.js'
|
import type { NextRESTClient } from '../helpers/NextRESTClient.js'
|
||||||
|
|
||||||
import { devUser } from '../credentials.js'
|
import { devUser } from '../credentials.js'
|
||||||
import { initPayloadInt } from '../helpers/initPayloadInt.js'
|
import { initPayloadInt } from '../helpers/initPayloadInt.js'
|
||||||
import { postsSlug } from './collections/Posts/index.js'
|
import { postsSlug } from './collections/Posts/index.js'
|
||||||
import configPromise from './config.js'
|
|
||||||
|
|
||||||
let payload: Payload
|
let payload: Payload
|
||||||
let token: string
|
let token: string
|
||||||
@@ -13,12 +15,15 @@ let restClient: NextRESTClient
|
|||||||
|
|
||||||
const { email, password } = devUser
|
const { email, password } = devUser
|
||||||
|
|
||||||
|
const filename = fileURLToPath(import.meta.url)
|
||||||
|
const dirname = path.dirname(filename)
|
||||||
|
|
||||||
describe('_Community Tests', () => {
|
describe('_Community Tests', () => {
|
||||||
// --__--__--__--__--__--__--__--__--__
|
// --__--__--__--__--__--__--__--__--__
|
||||||
// Boilerplate test setup/teardown
|
// Boilerplate test setup/teardown
|
||||||
// --__--__--__--__--__--__--__--__--__
|
// --__--__--__--__--__--__--__--__--__
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
const initialized = await initPayloadInt(configPromise)
|
const initialized = await initPayloadInt(dirname)
|
||||||
;({ payload, restClient } = initialized)
|
;({ payload, restClient } = initialized)
|
||||||
|
|
||||||
const data = await restClient
|
const data = await restClient
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import {
|
|||||||
import { AdminUrlUtil } from '../helpers/adminUrlUtil.js'
|
import { AdminUrlUtil } from '../helpers/adminUrlUtil.js'
|
||||||
import { initPayloadE2E } from '../helpers/initPayloadE2E.js'
|
import { initPayloadE2E } from '../helpers/initPayloadE2E.js'
|
||||||
import { POLL_TOPASS_TIMEOUT } from '../playwright.config.js'
|
import { POLL_TOPASS_TIMEOUT } from '../playwright.config.js'
|
||||||
import config from './config.js'
|
|
||||||
import {
|
import {
|
||||||
docLevelAccessSlug,
|
docLevelAccessSlug,
|
||||||
readOnlySlug,
|
readOnlySlug,
|
||||||
@@ -50,7 +49,7 @@ describe('access control', () => {
|
|||||||
let serverURL: string
|
let serverURL: string
|
||||||
|
|
||||||
beforeAll(async ({ browser }) => {
|
beforeAll(async ({ browser }) => {
|
||||||
;({ payload, serverURL } = await initPayloadE2E({ config, dirname }))
|
;({ payload, serverURL } = await initPayloadE2E({ dirname }))
|
||||||
|
|
||||||
url = new AdminUrlUtil(serverURL, slug)
|
url = new AdminUrlUtil(serverURL, slug)
|
||||||
restrictedUrl = new AdminUrlUtil(serverURL, restrictedSlug)
|
restrictedUrl = new AdminUrlUtil(serverURL, restrictedSlug)
|
||||||
|
|||||||
@@ -5,11 +5,10 @@ import { expect, test } from '@playwright/test'
|
|||||||
import path from 'path'
|
import path from 'path'
|
||||||
import { fileURLToPath } from 'url'
|
import { fileURLToPath } from 'url'
|
||||||
|
|
||||||
import { delayNetwork, initPageConsoleErrorCatch, login, saveDocAndAssert } from '../helpers.js'
|
import { initPageConsoleErrorCatch, login, saveDocAndAssert } from '../helpers.js'
|
||||||
import { AdminUrlUtil } from '../helpers/adminUrlUtil.js'
|
import { AdminUrlUtil } from '../helpers/adminUrlUtil.js'
|
||||||
import { initPayloadE2E } from '../helpers/initPayloadE2E.js'
|
import { initPayloadE2E } from '../helpers/initPayloadE2E.js'
|
||||||
import { POLL_TOPASS_TIMEOUT } from '../playwright.config.js'
|
import { POLL_TOPASS_TIMEOUT } from '../playwright.config.js'
|
||||||
import config from './config.js'
|
|
||||||
import { apiKeysSlug, slug } from './shared.js'
|
import { apiKeysSlug, slug } from './shared.js'
|
||||||
const filename = fileURLToPath(import.meta.url)
|
const filename = fileURLToPath(import.meta.url)
|
||||||
const dirname = path.dirname(filename)
|
const dirname = path.dirname(filename)
|
||||||
@@ -35,7 +34,7 @@ describe('auth', () => {
|
|||||||
let apiURL: string
|
let apiURL: string
|
||||||
|
|
||||||
beforeAll(async ({ browser }) => {
|
beforeAll(async ({ browser }) => {
|
||||||
;({ serverURL, payload } = await initPayloadE2E({ config, dirname }))
|
;({ serverURL, payload } = await initPayloadE2E({ dirname }))
|
||||||
apiURL = `${serverURL}/api`
|
apiURL = `${serverURL}/api`
|
||||||
url = new AdminUrlUtil(serverURL, slug)
|
url = new AdminUrlUtil(serverURL, slug)
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,13 @@
|
|||||||
import type { Page } from '@playwright/test'
|
import type { Page } from '@playwright/test'
|
||||||
|
|
||||||
import { expect, test } from '@playwright/test'
|
import { expect, test } from '@playwright/test'
|
||||||
|
import path from 'path'
|
||||||
|
import { fileURLToPath } from 'url'
|
||||||
|
|
||||||
import { initPageConsoleErrorCatch } from '../helpers.js'
|
import { initPageConsoleErrorCatch } from '../helpers.js'
|
||||||
import { initPayloadE2E } from '../helpers/initPayloadE2E.js'
|
import { initPayloadE2E } from '../helpers/initPayloadE2E.js'
|
||||||
import config from './config.js'
|
|
||||||
|
|
||||||
const { beforeAll, describe } = test
|
const { beforeAll, describe } = test
|
||||||
|
|
||||||
import path from 'path'
|
|
||||||
import { fileURLToPath } from 'url'
|
|
||||||
const filename = fileURLToPath(import.meta.url)
|
const filename = fileURLToPath(import.meta.url)
|
||||||
const dirname = path.dirname(filename)
|
const dirname = path.dirname(filename)
|
||||||
|
|
||||||
@@ -18,7 +16,7 @@ describe('field error states', () => {
|
|||||||
let page: Page
|
let page: Page
|
||||||
|
|
||||||
beforeAll(async ({ browser }) => {
|
beforeAll(async ({ browser }) => {
|
||||||
;({ serverURL } = await initPayloadE2E({ config, dirname }))
|
;({ serverURL } = await initPayloadE2E({ dirname }))
|
||||||
const context = await browser.newContext()
|
const context = await browser.newContext()
|
||||||
page = await context.newPage()
|
page = await context.newPage()
|
||||||
initPageConsoleErrorCatch(page)
|
initPageConsoleErrorCatch(page)
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import { initPayloadE2E } from '../helpers/initPayloadE2E.js'
|
|||||||
import { RESTClient } from '../helpers/rest.js'
|
import { RESTClient } from '../helpers/rest.js'
|
||||||
import { POLL_TOPASS_TIMEOUT } from '../playwright.config.js'
|
import { POLL_TOPASS_TIMEOUT } from '../playwright.config.js'
|
||||||
import { lexicalDocData } from './collections/Lexical/data.js'
|
import { lexicalDocData } from './collections/Lexical/data.js'
|
||||||
import config from './config.js'
|
|
||||||
import { clearAndSeedEverything } from './seed.js'
|
import { clearAndSeedEverything } from './seed.js'
|
||||||
import { lexicalFieldsSlug } from './slugs.js'
|
import { lexicalFieldsSlug } from './slugs.js'
|
||||||
const filename = fileURLToPath(import.meta.url)
|
const filename = fileURLToPath(import.meta.url)
|
||||||
@@ -49,7 +48,7 @@ async function navigateToLexicalFields(navigateToListView: boolean = true) {
|
|||||||
describe('lexical', () => {
|
describe('lexical', () => {
|
||||||
beforeAll(async ({ browser }) => {
|
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
|
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 }))
|
;({ payload, serverURL } = await initPayloadE2E({ dirname }))
|
||||||
|
|
||||||
const context = await browser.newContext()
|
const context = await browser.newContext()
|
||||||
page = await context.newPage()
|
page = await context.newPage()
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import type { SanitizedConfig } from 'payload/config'
|
import type { SanitizedConfig } from 'payload/config'
|
||||||
|
|
||||||
|
import path from 'path'
|
||||||
import { type Payload, getPayload } from 'payload'
|
import { type Payload, getPayload } from 'payload'
|
||||||
|
|
||||||
import { NextRESTClient } from './NextRESTClient.js'
|
import { NextRESTClient } from './NextRESTClient.js'
|
||||||
@@ -9,9 +10,10 @@ import { startMemoryDB } from './startMemoryDB.js'
|
|||||||
* Initialize Payload configured for integration tests
|
* Initialize Payload configured for integration tests
|
||||||
*/
|
*/
|
||||||
export async function initPayloadInt(
|
export async function initPayloadInt(
|
||||||
config: Promise<SanitizedConfig>,
|
dirname: string,
|
||||||
): Promise<{ config: SanitizedConfig; payload: Payload; restClient: NextRESTClient }> {
|
): Promise<{ config: SanitizedConfig; payload: Payload; restClient: NextRESTClient }> {
|
||||||
await startMemoryDB()
|
await startMemoryDB()
|
||||||
|
const { default: config } = await import(path.resolve(dirname, 'config.ts'))
|
||||||
const payload = await getPayload({ config })
|
const payload = await getPayload({ config })
|
||||||
const restClient = new NextRESTClient(payload.config)
|
const restClient = new NextRESTClient(payload.config)
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import { fileURLToPath } from 'url'
|
|||||||
import { exactText, initPageConsoleErrorCatch, saveDocAndAssert } from '../helpers.js'
|
import { exactText, initPageConsoleErrorCatch, saveDocAndAssert } from '../helpers.js'
|
||||||
import { AdminUrlUtil } from '../helpers/adminUrlUtil.js'
|
import { AdminUrlUtil } from '../helpers/adminUrlUtil.js'
|
||||||
import { initPayloadE2E } from '../helpers/initPayloadE2E.js'
|
import { initPayloadE2E } from '../helpers/initPayloadE2E.js'
|
||||||
import config from './config.js'
|
|
||||||
import { mobileBreakpoint } from './shared.js'
|
import { mobileBreakpoint } from './shared.js'
|
||||||
const filename = fileURLToPath(import.meta.url)
|
const filename = fileURLToPath(import.meta.url)
|
||||||
const dirname = path.dirname(filename)
|
const dirname = path.dirname(filename)
|
||||||
@@ -47,7 +46,7 @@ describe('Live Preview', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
beforeAll(async ({ browser }) => {
|
beforeAll(async ({ browser }) => {
|
||||||
;({ serverURL, payload } = await initPayloadE2E({ config, dirname }))
|
;({ serverURL, payload } = await initPayloadE2E({ dirname }))
|
||||||
url = new AdminUrlUtil(serverURL, 'pages')
|
url = new AdminUrlUtil(serverURL, 'pages')
|
||||||
const context = await browser.newContext()
|
const context = await browser.newContext()
|
||||||
page = await context.newPage()
|
page = await context.newPage()
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import {
|
|||||||
import { AdminUrlUtil } from '../helpers/adminUrlUtil.js'
|
import { AdminUrlUtil } from '../helpers/adminUrlUtil.js'
|
||||||
import { initPayloadE2E } from '../helpers/initPayloadE2E.js'
|
import { initPayloadE2E } from '../helpers/initPayloadE2E.js'
|
||||||
import { POLL_TOPASS_TIMEOUT } from '../playwright.config.js'
|
import { POLL_TOPASS_TIMEOUT } from '../playwright.config.js'
|
||||||
import config from './config.js'
|
|
||||||
import {
|
import {
|
||||||
englishTitle,
|
englishTitle,
|
||||||
localizedPostsSlug,
|
localizedPostsSlug,
|
||||||
@@ -52,10 +51,7 @@ let serverURL: string
|
|||||||
|
|
||||||
describe('Localization', () => {
|
describe('Localization', () => {
|
||||||
beforeAll(async ({ browser }) => {
|
beforeAll(async ({ browser }) => {
|
||||||
;({ payload, serverURL } = await initPayloadE2E({
|
;({ payload, serverURL } = await initPayloadE2E({ dirname }))
|
||||||
config,
|
|
||||||
dirname,
|
|
||||||
}))
|
|
||||||
|
|
||||||
url = new AdminUrlUtil(serverURL, localizedPostsSlug)
|
url = new AdminUrlUtil(serverURL, localizedPostsSlug)
|
||||||
urlWithRequiredLocalizedFields = new AdminUrlUtil(serverURL, withRequiredLocalizedFields)
|
urlWithRequiredLocalizedFields = new AdminUrlUtil(serverURL, withRequiredLocalizedFields)
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import type { Page as PayloadPage } from './payload-types.js'
|
|||||||
import { initPageConsoleErrorCatch } from '../helpers.js'
|
import { initPageConsoleErrorCatch } from '../helpers.js'
|
||||||
import { AdminUrlUtil } from '../helpers/adminUrlUtil.js'
|
import { AdminUrlUtil } from '../helpers/adminUrlUtil.js'
|
||||||
import { initPayloadE2E } from '../helpers/initPayloadE2E.js'
|
import { initPayloadE2E } from '../helpers/initPayloadE2E.js'
|
||||||
import config from './config.js'
|
|
||||||
|
|
||||||
const filename = fileURLToPath(import.meta.url)
|
const filename = fileURLToPath(import.meta.url)
|
||||||
const dirname = path.dirname(filename)
|
const dirname = path.dirname(filename)
|
||||||
@@ -24,7 +23,7 @@ let childId: string
|
|||||||
|
|
||||||
describe('Nested Docs Plugin', () => {
|
describe('Nested Docs Plugin', () => {
|
||||||
beforeAll(async ({ browser }) => {
|
beforeAll(async ({ browser }) => {
|
||||||
const { serverURL, payload } = await initPayloadE2E({ config, dirname })
|
const { serverURL, payload } = await initPayloadE2E({ dirname })
|
||||||
url = new AdminUrlUtil(serverURL, 'pages')
|
url = new AdminUrlUtil(serverURL, 'pages')
|
||||||
const context = await browser.newContext()
|
const context = await browser.newContext()
|
||||||
page = await context.newPage()
|
page = await context.newPage()
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import type { Page as PayloadPage } from './payload-types.js'
|
|||||||
import { initPageConsoleErrorCatch } from '../helpers.js'
|
import { initPageConsoleErrorCatch } from '../helpers.js'
|
||||||
import { AdminUrlUtil } from '../helpers/adminUrlUtil.js'
|
import { AdminUrlUtil } from '../helpers/adminUrlUtil.js'
|
||||||
import { initPayloadE2E } from '../helpers/initPayloadE2E.js'
|
import { initPayloadE2E } from '../helpers/initPayloadE2E.js'
|
||||||
import config from './config.js'
|
|
||||||
import { mediaSlug } from './shared.js'
|
import { mediaSlug } from './shared.js'
|
||||||
|
|
||||||
const filename = fileURLToPath(import.meta.url)
|
const filename = fileURLToPath(import.meta.url)
|
||||||
@@ -24,7 +23,7 @@ let id: string
|
|||||||
|
|
||||||
describe('SEO Plugin', () => {
|
describe('SEO Plugin', () => {
|
||||||
beforeAll(async ({ browser }) => {
|
beforeAll(async ({ browser }) => {
|
||||||
const { serverURL, payload } = await initPayloadE2E({ config, dirname })
|
const { serverURL, payload } = await initPayloadE2E({ dirname })
|
||||||
url = new AdminUrlUtil(serverURL, 'pages')
|
url = new AdminUrlUtil(serverURL, 'pages')
|
||||||
|
|
||||||
const context = await browser.newContext()
|
const context = await browser.newContext()
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ import {
|
|||||||
import { AdminUrlUtil } from '../helpers/adminUrlUtil.js'
|
import { AdminUrlUtil } from '../helpers/adminUrlUtil.js'
|
||||||
import { initPayloadE2E } from '../helpers/initPayloadE2E.js'
|
import { initPayloadE2E } from '../helpers/initPayloadE2E.js'
|
||||||
import { POLL_TOPASS_TIMEOUT } from '../playwright.config.js'
|
import { POLL_TOPASS_TIMEOUT } from '../playwright.config.js'
|
||||||
import config from './config.js'
|
|
||||||
import { clearAndSeedEverything } from './seed.js'
|
import { clearAndSeedEverything } from './seed.js'
|
||||||
import { titleToDelete } from './shared.js'
|
import { titleToDelete } from './shared.js'
|
||||||
import {
|
import {
|
||||||
@@ -89,7 +88,7 @@ describe('versions', () => {
|
|||||||
|
|
||||||
beforeAll(async ({ browser }) => {
|
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
|
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 }))
|
;({ payload, serverURL } = await initPayloadE2E({ dirname }))
|
||||||
const context = await browser.newContext()
|
const context = await browser.newContext()
|
||||||
page = await context.newPage()
|
page = await context.newPage()
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
],
|
],
|
||||||
"paths": {
|
"paths": {
|
||||||
"@payload-config": [
|
"@payload-config": [
|
||||||
"./test/access-control/config.ts"
|
"./test/_community/config.ts"
|
||||||
],
|
],
|
||||||
"@payloadcms/live-preview": [
|
"@payloadcms/live-preview": [
|
||||||
"./packages/live-preview/src"
|
"./packages/live-preview/src"
|
||||||
@@ -160,4 +160,4 @@
|
|||||||
".next/types/**/*.ts",
|
".next/types/**/*.ts",
|
||||||
"scripts/**/*.ts"
|
"scripts/**/*.ts"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user