From 933ae663f092b445f3ab3fb40f06be26561f9dd4 Mon Sep 17 00:00:00 2001 From: Jarrod Flesch Date: Mon, 4 Mar 2024 16:21:55 -0500 Subject: [PATCH] chore: e2e improvements --- test/admin/collections/CustomViews1.ts | 2 +- .../components/views/CustomEdit/index.tsx | 4 +--- test/admin/config.ts | 17 +++------------ test/admin/globals/CustomViews1.ts | 2 +- test/auth/AuthDebug.tsx | 2 +- test/auth/config.ts | 21 ++++++++++--------- test/auth/e2e.spec.ts | 2 +- test/dev.js | 2 +- 8 files changed, 20 insertions(+), 32 deletions(-) diff --git a/test/admin/collections/CustomViews1.ts b/test/admin/collections/CustomViews1.ts index 1495d707ee..fdba0e6285 100644 --- a/test/admin/collections/CustomViews1.ts +++ b/test/admin/collections/CustomViews1.ts @@ -1,6 +1,6 @@ import type { CollectionConfig } from '../../../packages/payload/src/collections/config/types' -import CustomEditView from '../components/views/CustomEdit' +import { CustomEditView } from '../components/views/CustomEdit' import { customViews1CollectionSlug } from '../slugs' export const CustomViews1: CollectionConfig = { diff --git a/test/admin/components/views/CustomEdit/index.tsx b/test/admin/components/views/CustomEdit/index.tsx index f0024feef8..5edd585fc1 100644 --- a/test/admin/components/views/CustomEdit/index.tsx +++ b/test/admin/components/views/CustomEdit/index.tsx @@ -8,7 +8,7 @@ import type { AdminViewComponent } from '../../../../../packages/payload/src/adm import { useStepNav } from '../../../../../packages/ui/src/elements/StepNav' import { useConfig } from '../../../../../packages/ui/src/providers/Config' -const CustomEditView: AdminViewComponent = ({ +export const CustomEditView: AdminViewComponent = ({ canAccessAdmin, // collection, // global, @@ -58,5 +58,3 @@ const CustomEditView: AdminViewComponent = ({ ) } - -export default CustomEditView diff --git a/test/admin/config.ts b/test/admin/config.ts index ab05c411a0..b8493ad9a3 100644 --- a/test/admin/config.ts +++ b/test/admin/config.ts @@ -1,6 +1,8 @@ import path from 'path' import { buildConfigWithDefaults } from '../buildConfigWithDefaults' +import { CustomIdRow } from './collections/CustomIdRow' +import { CustomIdTab } from './collections/CustomIdTab' import { CustomViews1 } from './collections/CustomViews1' import { CustomViews2 } from './collections/CustomViews2' import { Geo } from './collections/Geo' @@ -9,8 +11,6 @@ import { CollectionGroup1B } from './collections/Group1B' import { CollectionGroup2A } from './collections/Group2A' import { CollectionGroup2B } from './collections/Group2B' import { CollectionHidden } from './collections/Hidden' -import { CustomIdTab } from './collections/CustomIdTab' -import { CustomIdRow } from './collections/CustomIdRow' import { CollectionNoApiView } from './collections/NoApiView' import { Posts } from './collections/Posts' import { Users } from './collections/Users' @@ -35,7 +35,6 @@ import { customNestedViewPath, customViewPath } from './shared' export default buildConfigWithDefaults({ admin: { - css: path.resolve(__dirname, 'styles.scss'), components: { // providers: [CustomProvider, CustomProvider], actions: [AdminButton], @@ -67,19 +66,9 @@ export default buildConfigWithDefaults({ }, }, }, - webpack: (config) => ({ - ...config, - resolve: { - ...config.resolve, - alias: { - ...config?.resolve?.alias, - fs: path.resolve(__dirname, './mocks/emptyModule.js'), - }, - }, - }), }, i18n: { - resources: { + translations: { en: { general: { dashboard: 'Home', diff --git a/test/admin/globals/CustomViews1.ts b/test/admin/globals/CustomViews1.ts index d613630eb1..cb562746a8 100644 --- a/test/admin/globals/CustomViews1.ts +++ b/test/admin/globals/CustomViews1.ts @@ -1,6 +1,6 @@ import type { GlobalConfig } from '../../../packages/payload/src/globals/config/types' -import CustomEditView from '../components/views/CustomEdit' +import { CustomEditView } from '../components/views/CustomEdit' import { customGlobalViews1GlobalSlug } from '../slugs' export const CustomGlobalViews1: GlobalConfig = { diff --git a/test/auth/AuthDebug.tsx b/test/auth/AuthDebug.tsx index c2a1a79a25..0670756737 100644 --- a/test/auth/AuthDebug.tsx +++ b/test/auth/AuthDebug.tsx @@ -17,7 +17,7 @@ export const AuthDebug: React.FC = () => { setState(userRes) } - fetchUser() + void fetchUser() }, [user]) return ( diff --git a/test/auth/config.ts b/test/auth/config.ts index 81384c6f62..372e3079ba 100644 --- a/test/auth/config.ts +++ b/test/auth/config.ts @@ -3,6 +3,7 @@ import { v4 as uuid } from 'uuid' import { mapAsync } from '../../packages/payload/src/utilities/mapAsync' import { buildConfigWithDefaults } from '../buildConfigWithDefaults' import { devUser } from '../credentials' +import { AuthDebug } from './AuthDebug' import { apiKeysSlug, namedSaveToJWTValue, saveToJWTKey, slug } from './shared' export default buildConfigWithDefaults({ @@ -153,16 +154,16 @@ export default buildConfigWithDefaults({ label: 'Custom', type: 'text', }, - // { - // name: 'authDebug', - // label: 'Auth Debug', - // type: 'ui', - // admin: { - // components: { - // Field: AuthDebug, - // }, - // }, - // }, + { + name: 'authDebug', + label: 'Auth Debug', + type: 'ui', + admin: { + components: { + Field: AuthDebug, + }, + }, + }, ], }, { diff --git a/test/auth/e2e.spec.ts b/test/auth/e2e.spec.ts index 9eb38dfcf7..bd10726cca 100644 --- a/test/auth/e2e.spec.ts +++ b/test/auth/e2e.spec.ts @@ -29,7 +29,7 @@ describe('auth', () => { let apiURL: string beforeAll(async ({ browser }) => { - const { serverURL } = await initPayloadE2E({ config, dirname: __dirname }) + ;({ serverURL } = await initPayloadE2E({ config, dirname: __dirname })) url = new AdminUrlUtil(serverURL, slug) const context = await browser.newContext() diff --git a/test/dev.js b/test/dev.js index 4502c902c5..d00f4a3c51 100644 --- a/test/dev.js +++ b/test/dev.js @@ -39,5 +39,5 @@ async function main() { const PAYLOAD_CONFIG_PATH = path.resolve(testSuite, 'config') process.env.PAYLOAD_CONFIG_PATH = PAYLOAD_CONFIG_PATH - nextDev({ _: [path.resolve(__dirname, '..')] }) + nextDev({ _: [path.resolve(__dirname, '..')], port: process.env.PORT || 3000 }) }