From f48335444bf11231ab2409b59280c9191dd25ec2 Mon Sep 17 00:00:00 2001 From: James Date: Thu, 4 Apr 2024 21:01:38 -0400 Subject: [PATCH 01/17] chore: flake --- test/fields/e2e.spec.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/fields/e2e.spec.ts b/test/fields/e2e.spec.ts index 8f22ec34a0..ace2c2ba7c 100644 --- a/test/fields/e2e.spec.ts +++ b/test/fields/e2e.spec.ts @@ -696,6 +696,8 @@ describe('fields', () => { '#field-customBlocks input[name="customBlocks.0.block1Title"]', ) + await page.mouse.wheel(0, 1750) + await customBlocks.scrollIntoViewIfNeeded() await expect(customBlocks).toHaveValue('Block 1: Prefilled Title') @@ -775,6 +777,7 @@ describe('fields', () => { const assertText3 = 'array row 3' const assertGroupText3 = 'text in group in row 3' await page.goto(url.create) + await page.mouse.wheel(0, 1750) await page.locator('#field-potentiallyEmptyArray').scrollIntoViewIfNeeded() await wait(300) From 0c45d5773a51aef5e5d7688b84a4ab3c345321fd Mon Sep 17 00:00:00 2001 From: James Date: Thu, 4 Apr 2024 21:02:31 -0400 Subject: [PATCH 02/17] chore: brings back admin and fields --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cc8af141cd..2cb9cfc6c7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -246,11 +246,11 @@ jobs: suite: - _community - access-control - # - admin + - admin - auth - field-error-states - fields-relationship - # - fields + - fields - fields/lexical - live-preview - localization From 3bd455ced2abb3ead297ca8b923b2cb334b19f0d Mon Sep 17 00:00:00 2001 From: James Date: Fri, 5 Apr 2024 11:46:02 -0400 Subject: [PATCH 03/17] chore: pre-builds in CI --- .../admin/[[...segments]]/not-found.tsx | 4 ++-- next.config.mjs | 6 ++++++ packages/next/src/views/NotFound/index.tsx | 12 +++++++++--- packages/next/src/views/Root/meta.ts | 2 +- test/helpers/initPayloadE2ENoConfig.ts | 18 +++++++++++++++++- tsconfig.json | 3 ++- 6 files changed, 37 insertions(+), 8 deletions(-) diff --git a/app/(payload)/admin/[[...segments]]/not-found.tsx b/app/(payload)/admin/[[...segments]]/not-found.tsx index f3a7743293..8b7a445fe7 100644 --- a/app/(payload)/admin/[[...segments]]/not-found.tsx +++ b/app/(payload)/admin/[[...segments]]/not-found.tsx @@ -14,8 +14,8 @@ type Args = { } } -export const generateMetadata = ({ params, searchParams }: Args): Promise => - generatePageMetadata({ config, params, searchParams }) +export const generateMetadata = ({ params }: Args): Promise => + generatePageMetadata({ config, params }) const NotFound = ({ params, searchParams }: Args) => NotFoundPage({ config, params, searchParams }) diff --git a/next.config.mjs b/next.config.mjs index bbc02170f4..891e51caf9 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -10,6 +10,12 @@ const withBundleAnalyzer = bundleAnalyzer({ export default withBundleAnalyzer( withPayload({ reactStrictMode: false, + eslint: { + ignoreDuringBuilds: true, + }, + typescript: { + ignoreBuildErrors: true, + }, async redirects() { return [ { diff --git a/packages/next/src/views/NotFound/index.tsx b/packages/next/src/views/NotFound/index.tsx index 3b8718a9d2..a87050e0a5 100644 --- a/packages/next/src/views/NotFound/index.tsx +++ b/packages/next/src/views/NotFound/index.tsx @@ -2,6 +2,7 @@ import type { I18n } from '@payloadcms/translations' import type { Metadata } from 'next' import type { SanitizedConfig } from 'payload/types' +import { getNextI18n } from '@payloadcms/next/utilities/getNextI18n.js' import { HydrateClientUser } from '@payloadcms/ui/elements/HydrateClientUser' import { DefaultTemplate } from '@payloadcms/ui/templates/Default' import React, { Fragment } from 'react' @@ -10,13 +11,18 @@ import { initPage } from '../../utilities/initPage.js' import { NotFoundClient } from './index.client.js' export const generatePageMetadata = async ({ - i18n, + config: configPromise, }: { - config: SanitizedConfig - i18n: I18n + config: Promise | SanitizedConfig params?: { [key: string]: string | string[] } //eslint-disable-next-line @typescript-eslint/require-await }): Promise => { + const config = await configPromise + + const i18n = getNextI18n({ + config, + }) + return { title: i18n.t('general:notFound'), } diff --git a/packages/next/src/views/Root/meta.ts b/packages/next/src/views/Root/meta.ts index dbbed934d6..0edcfd5319 100644 --- a/packages/next/src/views/Root/meta.ts +++ b/packages/next/src/views/Root/meta.ts @@ -49,7 +49,7 @@ export const generatePageMetadata = async ({ config: configPromise, params }: Ar const isGlobal = segmentOne === 'globals' const isCollection = segmentOne === 'collections' - const i18n = await getNextI18n({ + const i18n = getNextI18n({ config, }) diff --git a/test/helpers/initPayloadE2ENoConfig.ts b/test/helpers/initPayloadE2ENoConfig.ts index 278fd23e98..c3c1643cc9 100644 --- a/test/helpers/initPayloadE2ENoConfig.ts +++ b/test/helpers/initPayloadE2ENoConfig.ts @@ -1,5 +1,6 @@ import { createServer } from 'http' import nextImport from 'next' +import nextBuild from 'next/dist/build/index.js' import path from 'path' import { wait } from 'payload/utilities' import { parse } from 'url' @@ -32,9 +33,24 @@ export async function initPayloadE2ENoConfig>({ await startMemoryDB() + // process.env.CI = 'true' + + if (process.env.CI) { + await nextBuild.default( + path.resolve(dirname, '../../'), + false, + false, + false, + true, + true, + false, + 'default', + ) + } + // @ts-expect-error const app = nextImport({ - dev: true, + dev: !process.env.CI, hostname: 'localhost', port, dir: path.resolve(dirname, '../../'), diff --git a/tsconfig.json b/tsconfig.json index 5e34fd5bc9..55baff19c7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -37,7 +37,7 @@ ], "paths": { "@payload-config": [ - "./test/fields/config.ts" + "./test/_community/config.ts" ], "@payloadcms/live-preview": [ "./packages/live-preview/src" @@ -156,6 +156,7 @@ } ], "include": [ + "app", "next-env.d.ts", ".next/types/**/*.ts", "scripts/**/*.ts" From 6217c70fb57950c1e178e595e78751b114cec0f3 Mon Sep 17 00:00:00 2001 From: James Date: Fri, 5 Apr 2024 14:13:14 -0400 Subject: [PATCH 04/17] chore: prebuilds fields and admin in ci --- app/live-preview/_api/fetchDoc.ts | 35 ------------- app/live-preview/_api/fetchDocs.ts | 19 ------- app/live-preview/_api/fetchFooter.ts | 25 --------- app/live-preview/_api/fetchHeader.ts | 25 --------- test/admin/e2e.spec.ts | 5 +- test/dev.js | 10 ++-- test/fields/e2e.spec.ts | 5 +- test/helpers/getNextJSRootDir.js | 25 +++++++++ test/helpers/initPayloadE2ENoConfig.ts | 23 +++----- test/helpers/startMemoryDB.ts | 2 - .../admin/[[...segments]]/not-found.tsx | 22 ++++++++ .../(payload)/admin/[[...segments]]/page.tsx | 22 ++++++++ .../app/(payload)/api/[...slug]/route.ts | 9 ++++ .../(payload)/api/graphql-playground/route.ts | 6 +++ .../app/(payload)/api/graphql/route.ts | 6 +++ test/live-preview/app/(payload)/custom.scss | 8 +++ test/live-preview/app/(payload)/layout.tsx | 15 ++++++ .../(pages)/[slug]/page.client.tsx | 0 .../app}/live-preview/(pages)/[slug]/page.tsx | 0 .../(pages)/posts/[slug]/page.client.tsx | 2 +- .../(pages)/posts/[slug]/page.tsx | 2 +- .../app/live-preview/_api/fetchDoc.ts | 35 +++++++++++++ .../app/live-preview/_api/fetchDocs.ts | 20 +++++++ .../app/live-preview/_api/fetchFooter.ts | 20 +++++++ .../app/live-preview/_api/fetchHeader.ts | 20 +++++++ .../app}/live-preview/_api/serverURL.ts | 0 .../_blocks/ArchiveBlock/index.module.scss | 0 .../_blocks/ArchiveBlock/index.tsx | 0 .../_blocks/ArchiveBlock/types.ts | 2 +- .../_blocks/CallToAction/index.module.scss | 0 .../_blocks/CallToAction/index.tsx | 2 +- .../_blocks/Content/index.module.scss | 0 .../live-preview/_blocks/Content/index.tsx | 2 +- .../_blocks/MediaBlock/index.module.scss | 0 .../live-preview/_blocks/MediaBlock/index.tsx | 2 +- .../_blocks/RelatedPosts/index.module.scss | 0 .../_blocks/RelatedPosts/index.tsx | 2 +- .../_blocks/Relationships/index.module.scss | 0 .../_blocks/Relationships/index.tsx | 2 +- .../BackgroundColor/index.module.scss | 0 .../_components/BackgroundColor/index.tsx | 0 .../live-preview/_components/Blocks/index.tsx | 2 +- .../_components/Button/index.module.scss | 0 .../live-preview/_components/Button/index.tsx | 0 .../_components/Card/index.module.scss | 0 .../live-preview/_components/Card/index.tsx | 2 +- .../_components/Chevron/index.tsx | 0 .../PopulateByCollection/index.module.scss | 0 .../PopulateByCollection/index.tsx | 2 +- .../PopulateBySelection/index.module.scss | 0 .../PopulateBySelection/index.tsx | 0 .../_components/CollectionArchive/index.tsx | 0 .../_components/Footer/index.module.scss | 0 .../live-preview/_components/Footer/index.tsx | 0 .../_components/Gutter/index.module.scss | 0 .../live-preview/_components/Gutter/index.tsx | 0 .../_components/Header/Nav/index.module.scss | 0 .../_components/Header/Nav/index.tsx | 0 .../_components/Header/index.module.scss | 0 .../live-preview/_components/Header/index.tsx | 0 .../live-preview/_components/Hero/index.tsx | 0 .../live-preview/_components/Link/index.tsx | 2 +- .../_components/Media/Image/index.module.scss | 0 .../_components/Media/Image/index.tsx | 0 .../_components/Media/Video/index.module.scss | 0 .../_components/Media/Video/index.tsx | 0 .../live-preview/_components/Media/index.tsx | 2 +- .../live-preview/_components/Media/types.ts | 2 +- .../_components/PageRange/index.module.scss | 0 .../_components/PageRange/index.tsx | 0 .../_components/Pagination/index.module.scss | 0 .../_components/Pagination/index.tsx | 0 .../_components/RichText/index.module.scss | 0 .../_components/RichText/index.tsx | 0 .../_components/RichText/serializeLexical.tsx | 0 .../_components/RichText/serializeSlate.tsx | 0 .../VerticalPadding/index.module.scss | 0 .../_components/VerticalPadding/index.tsx | 0 .../app}/live-preview/_css/app.scss | 0 .../app}/live-preview/_css/colors.scss | 0 .../app}/live-preview/_css/common.scss | 0 .../app}/live-preview/_css/queries.scss | 0 .../app}/live-preview/_css/type.scss | 0 .../_heros/HighImpact/index.module.scss | 0 .../live-preview/_heros/HighImpact/index.tsx | 0 .../_heros/LowImpact/index.module.scss | 0 .../live-preview/_heros/LowImpact/index.tsx | 0 .../_heros/PostHero/index.module.scss | 0 .../live-preview/_heros/PostHero/index.tsx | 2 +- .../live-preview/_utilities/formatDateTime.ts | 0 .../live-preview/_utilities/toKebabCase.ts | 0 .../app}/live-preview/cssVariables.js | 0 .../live-preview/app}/live-preview/layout.tsx | 0 .../app}/live-preview/not-found.tsx | 0 .../live-preview/app}/live-preview/page.tsx | 0 test/live-preview/next-env.d.ts | 5 ++ test/live-preview/next.config.mjs | 3 ++ test/live-preview/tsconfig.json | 52 +++++++++++++++++++ test/tsconfig.json | 5 +- tsconfig.json | 5 +- 100 files changed, 310 insertions(+), 147 deletions(-) delete mode 100644 app/live-preview/_api/fetchDoc.ts delete mode 100644 app/live-preview/_api/fetchDocs.ts delete mode 100644 app/live-preview/_api/fetchFooter.ts delete mode 100644 app/live-preview/_api/fetchHeader.ts create mode 100644 test/helpers/getNextJSRootDir.js create mode 100644 test/live-preview/app/(payload)/admin/[[...segments]]/not-found.tsx create mode 100644 test/live-preview/app/(payload)/admin/[[...segments]]/page.tsx create mode 100644 test/live-preview/app/(payload)/api/[...slug]/route.ts create mode 100644 test/live-preview/app/(payload)/api/graphql-playground/route.ts create mode 100644 test/live-preview/app/(payload)/api/graphql/route.ts create mode 100644 test/live-preview/app/(payload)/custom.scss create mode 100644 test/live-preview/app/(payload)/layout.tsx rename {app => test/live-preview/app}/live-preview/(pages)/[slug]/page.client.tsx (100%) rename {app => test/live-preview/app}/live-preview/(pages)/[slug]/page.tsx (100%) rename {app => test/live-preview/app}/live-preview/(pages)/posts/[slug]/page.client.tsx (95%) rename {app => test/live-preview/app}/live-preview/(pages)/posts/[slug]/page.tsx (90%) create mode 100644 test/live-preview/app/live-preview/_api/fetchDoc.ts create mode 100644 test/live-preview/app/live-preview/_api/fetchDocs.ts create mode 100644 test/live-preview/app/live-preview/_api/fetchFooter.ts create mode 100644 test/live-preview/app/live-preview/_api/fetchHeader.ts rename {app => test/live-preview/app}/live-preview/_api/serverURL.ts (100%) rename {app => test/live-preview/app}/live-preview/_blocks/ArchiveBlock/index.module.scss (100%) rename {app => test/live-preview/app}/live-preview/_blocks/ArchiveBlock/index.tsx (100%) rename {app => test/live-preview/app}/live-preview/_blocks/ArchiveBlock/types.ts (59%) rename {app => test/live-preview/app}/live-preview/_blocks/CallToAction/index.module.scss (100%) rename {app => test/live-preview/app}/live-preview/_blocks/CallToAction/index.tsx (93%) rename {app => test/live-preview/app}/live-preview/_blocks/Content/index.module.scss (100%) rename {app => test/live-preview/app}/live-preview/_blocks/Content/index.tsx (93%) rename {app => test/live-preview/app}/live-preview/_blocks/MediaBlock/index.module.scss (100%) rename {app => test/live-preview/app}/live-preview/_blocks/MediaBlock/index.tsx (93%) rename {app => test/live-preview/app}/live-preview/_blocks/RelatedPosts/index.module.scss (100%) rename {app => test/live-preview/app}/live-preview/_blocks/RelatedPosts/index.tsx (94%) rename {app => test/live-preview/app}/live-preview/_blocks/Relationships/index.module.scss (100%) rename {app => test/live-preview/app}/live-preview/_blocks/Relationships/index.tsx (98%) rename {app => test/live-preview/app}/live-preview/_components/BackgroundColor/index.module.scss (100%) rename {app => test/live-preview/app}/live-preview/_components/BackgroundColor/index.tsx (100%) rename {app => test/live-preview/app}/live-preview/_components/Blocks/index.tsx (97%) rename {app => test/live-preview/app}/live-preview/_components/Button/index.module.scss (100%) rename {app => test/live-preview/app}/live-preview/_components/Button/index.tsx (100%) rename {app => test/live-preview/app}/live-preview/_components/Card/index.module.scss (100%) rename {app => test/live-preview/app}/live-preview/_components/Card/index.tsx (97%) rename {app => test/live-preview/app}/live-preview/_components/Chevron/index.tsx (100%) rename {app => test/live-preview/app}/live-preview/_components/CollectionArchive/PopulateByCollection/index.module.scss (100%) rename {app => test/live-preview/app}/live-preview/_components/CollectionArchive/PopulateByCollection/index.tsx (98%) rename {app => test/live-preview/app}/live-preview/_components/CollectionArchive/PopulateBySelection/index.module.scss (100%) rename {app => test/live-preview/app}/live-preview/_components/CollectionArchive/PopulateBySelection/index.tsx (100%) rename {app => test/live-preview/app}/live-preview/_components/CollectionArchive/index.tsx (100%) rename {app => test/live-preview/app}/live-preview/_components/Footer/index.module.scss (100%) rename {app => test/live-preview/app}/live-preview/_components/Footer/index.tsx (100%) rename {app => test/live-preview/app}/live-preview/_components/Gutter/index.module.scss (100%) rename {app => test/live-preview/app}/live-preview/_components/Gutter/index.tsx (100%) rename {app => test/live-preview/app}/live-preview/_components/Header/Nav/index.module.scss (100%) rename {app => test/live-preview/app}/live-preview/_components/Header/Nav/index.tsx (100%) rename {app => test/live-preview/app}/live-preview/_components/Header/index.module.scss (100%) rename {app => test/live-preview/app}/live-preview/_components/Header/index.tsx (100%) rename {app => test/live-preview/app}/live-preview/_components/Hero/index.tsx (100%) rename {app => test/live-preview/app}/live-preview/_components/Link/index.tsx (94%) rename {app => test/live-preview/app}/live-preview/_components/Media/Image/index.module.scss (100%) rename {app => test/live-preview/app}/live-preview/_components/Media/Image/index.tsx (100%) rename {app => test/live-preview/app}/live-preview/_components/Media/Video/index.module.scss (100%) rename {app => test/live-preview/app}/live-preview/_components/Media/Video/index.tsx (100%) rename {app => test/live-preview/app}/live-preview/_components/Media/index.tsx (92%) rename {app => test/live-preview/app}/live-preview/_components/Media/types.ts (89%) rename {app => test/live-preview/app}/live-preview/_components/PageRange/index.module.scss (100%) rename {app => test/live-preview/app}/live-preview/_components/PageRange/index.tsx (100%) rename {app => test/live-preview/app}/live-preview/_components/Pagination/index.module.scss (100%) rename {app => test/live-preview/app}/live-preview/_components/Pagination/index.tsx (100%) rename {app => test/live-preview/app}/live-preview/_components/RichText/index.module.scss (100%) rename {app => test/live-preview/app}/live-preview/_components/RichText/index.tsx (100%) rename {app => test/live-preview/app}/live-preview/_components/RichText/serializeLexical.tsx (100%) rename {app => test/live-preview/app}/live-preview/_components/RichText/serializeSlate.tsx (100%) rename {app => test/live-preview/app}/live-preview/_components/VerticalPadding/index.module.scss (100%) rename {app => test/live-preview/app}/live-preview/_components/VerticalPadding/index.tsx (100%) rename {app => test/live-preview/app}/live-preview/_css/app.scss (100%) rename {app => test/live-preview/app}/live-preview/_css/colors.scss (100%) rename {app => test/live-preview/app}/live-preview/_css/common.scss (100%) rename {app => test/live-preview/app}/live-preview/_css/queries.scss (100%) rename {app => test/live-preview/app}/live-preview/_css/type.scss (100%) rename {app => test/live-preview/app}/live-preview/_heros/HighImpact/index.module.scss (100%) rename {app => test/live-preview/app}/live-preview/_heros/HighImpact/index.tsx (100%) rename {app => test/live-preview/app}/live-preview/_heros/LowImpact/index.module.scss (100%) rename {app => test/live-preview/app}/live-preview/_heros/LowImpact/index.tsx (100%) rename {app => test/live-preview/app}/live-preview/_heros/PostHero/index.module.scss (100%) rename {app => test/live-preview/app}/live-preview/_heros/PostHero/index.tsx (96%) rename {app => test/live-preview/app}/live-preview/_utilities/formatDateTime.ts (100%) rename {app => test/live-preview/app}/live-preview/_utilities/toKebabCase.ts (100%) rename {app => test/live-preview/app}/live-preview/cssVariables.js (100%) rename {app => test/live-preview/app}/live-preview/layout.tsx (100%) rename {app => test/live-preview/app}/live-preview/not-found.tsx (100%) rename {app => test/live-preview/app}/live-preview/page.tsx (100%) create mode 100644 test/live-preview/next-env.d.ts create mode 100644 test/live-preview/next.config.mjs create mode 100644 test/live-preview/tsconfig.json diff --git a/app/live-preview/_api/fetchDoc.ts b/app/live-preview/_api/fetchDoc.ts deleted file mode 100644 index d1dc1c2a3a..0000000000 --- a/app/live-preview/_api/fetchDoc.ts +++ /dev/null @@ -1,35 +0,0 @@ -import QueryString from 'qs' - -import { PAYLOAD_SERVER_URL } from './serverURL.js' - -export const fetchDoc = async (args: { - collection: string - depth?: number - id?: string - slug?: string -}): Promise => { - const { id, slug, collection, depth = 2 } = args || {} - - const queryString = QueryString.stringify( - { - ...(slug ? { 'where[slug][equals]': slug } : {}), - ...(depth ? { depth } : {}), - }, - { addQueryPrefix: true }, - ) - - const doc: T = await fetch(`${PAYLOAD_SERVER_URL}/api/${collection}${queryString}`, { - cache: 'no-store', - headers: { - 'Content-Type': 'application/json', - }, - method: 'GET', - }) - ?.then((res) => res.json()) - ?.then((res) => { - if (res.errors) throw new Error(res?.errors?.[0]?.message ?? 'Error fetching doc') - return res?.docs?.[0] - }) - - return doc -} diff --git a/app/live-preview/_api/fetchDocs.ts b/app/live-preview/_api/fetchDocs.ts deleted file mode 100644 index 104f5e2586..0000000000 --- a/app/live-preview/_api/fetchDocs.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { PAYLOAD_SERVER_URL } from './serverURL.js' - -export const fetchDocs = async (collection: string): Promise => { - const docs: T[] = await fetch(`${PAYLOAD_SERVER_URL}/api/${collection}?depth=0&limit=100`, { - cache: 'no-store', - headers: { - 'Content-Type': 'application/json', - }, - method: 'GET', - }) - ?.then((res) => res.json()) - ?.then((res) => { - if (res.errors) throw new Error(res?.errors?.[0]?.message ?? 'Error fetching docs') - - return res?.docs - }) - - return docs -} diff --git a/app/live-preview/_api/fetchFooter.ts b/app/live-preview/_api/fetchFooter.ts deleted file mode 100644 index 26b531b620..0000000000 --- a/app/live-preview/_api/fetchFooter.ts +++ /dev/null @@ -1,25 +0,0 @@ -import type { Footer } from '../../../test/live-preview/payload-types.js' - -import { PAYLOAD_SERVER_URL } from './serverURL.js' - -export async function fetchFooter(): Promise