+
{customNestedViewTitle}
+
This custom view was added through the Payload config:
+
+ -
+
components.views[key].Component
+
+
+
+
+
+
+
+
+ )
+}
diff --git a/test/admin/config.ts b/test/admin/config.ts
index 26d1fdd691..3532c44921 100644
--- a/test/admin/config.ts
+++ b/test/admin/config.ts
@@ -26,6 +26,7 @@ import { GlobalGroup1A } from './globals/Group1A.js'
import { GlobalGroup1B } from './globals/Group1B.js'
import { GlobalHidden } from './globals/Hidden.js'
import { GlobalNoApiView } from './globals/NoApiView.js'
+import { Settings } from './globals/Settings.js'
import { seed } from './seed.js'
import {
customAdminRoutes,
@@ -33,7 +34,11 @@ import {
customParamViewPath,
customRootViewMetaTitle,
customViewPath,
+ protectedCustomNestedViewPath,
+ publicCustomViewPath,
} from './shared.js'
+import { settingsGlobalSlug } from './slugs.js'
+
export default buildConfigWithDefaults({
admin: {
importMap: {
@@ -80,6 +85,17 @@ export default buildConfigWithDefaults({
path: customViewPath,
strict: true,
},
+ ProtectedCustomNestedView: {
+ Component: '/components/views/CustomProtectedView/index.js#CustomProtectedView',
+ exact: true,
+ path: protectedCustomNestedViewPath,
+ },
+ PublicCustomView: {
+ Component: '/components/views/CustomView/index.js#CustomView',
+ exact: true,
+ path: publicCustomViewPath,
+ strict: true,
+ },
CustomViewWithParam: {
Component: '/components/views/CustomViewWithParam/index.js#CustomViewWithParam',
path: customParamViewPath,
@@ -144,6 +160,7 @@ export default buildConfigWithDefaults({
CustomGlobalViews2,
GlobalGroup1A,
GlobalGroup1B,
+ Settings,
],
i18n: {
translations: {
diff --git a/test/admin/e2e/1/e2e.spec.ts b/test/admin/e2e/1/e2e.spec.ts
index cbb90522a6..f4c59ae54f 100644
--- a/test/admin/e2e/1/e2e.spec.ts
+++ b/test/admin/e2e/1/e2e.spec.ts
@@ -35,6 +35,8 @@ import {
customViewMetaTitle,
customViewPath,
customViewTitle,
+ protectedCustomNestedViewPath,
+ publicCustomViewPath,
slugPluralLabel,
} from '../../shared.js'
import {
@@ -50,6 +52,7 @@ import {
noApiViewCollectionSlug,
noApiViewGlobalSlug,
postsCollectionSlug,
+ settingsGlobalSlug,
} from '../../slugs.js'
const { beforeAll, beforeEach, describe } = test
@@ -494,6 +497,30 @@ describe('admin1', () => {
await expect(page.locator('h1#custom-view-title')).toContainText(customNestedViewTitle)
})
+ test('root — should render public custom view', async () => {
+ await page.goto(`${serverURL}${adminRoutes.routes.admin}${publicCustomViewPath}`)
+ await page.waitForURL(`**${adminRoutes.routes.admin}${publicCustomViewPath}`)
+ await expect(page.locator('h1#custom-view-title')).toContainText(customViewTitle)
+ })
+
+ test('root — should render protected nested custom view', async () => {
+ await page.goto(`${serverURL}${adminRoutes.routes.admin}${protectedCustomNestedViewPath}`)
+ await page.waitForURL(`**${adminRoutes.routes.admin}/unauthorized`)
+ await expect(page.locator('.unauthorized')).toBeVisible()
+
+ await page.goto(globalURL.global(settingsGlobalSlug))
+
+ const checkbox = page.locator('#field-canAccessProtected')
+
+ await checkbox.check()
+
+ await saveDocAndAssert(page)
+
+ await page.goto(`${serverURL}${adminRoutes.routes.admin}${protectedCustomNestedViewPath}`)
+ await page.waitForURL(`**${adminRoutes.routes.admin}${protectedCustomNestedViewPath}`)
+ await expect(page.locator('h1#custom-view-title')).toContainText(customNestedViewTitle)
+ })
+
test('collection - should render custom tab view', async () => {
await page.goto(customViewsURL.create)
await page.locator('#field-title').fill('Test')
diff --git a/test/admin/globals/Settings.ts b/test/admin/globals/Settings.ts
new file mode 100644
index 0000000000..669137091a
--- /dev/null
+++ b/test/admin/globals/Settings.ts
@@ -0,0 +1,13 @@
+import type { GlobalConfig } from 'payload'
+
+import { settingsGlobalSlug } from '../slugs.js'
+
+export const Settings: GlobalConfig = {
+ slug: settingsGlobalSlug,
+ fields: [
+ {
+ type: 'checkbox',
+ name: 'canAccessProtected',
+ },
+ ],
+}
diff --git a/test/admin/payload-types.ts b/test/admin/payload-types.ts
index 528c56170e..74b684358c 100644
--- a/test/admin/payload-types.ts
+++ b/test/admin/payload-types.ts
@@ -42,6 +42,7 @@ export interface Config {
'custom-global-views-two': CustomGlobalViewsTwo;
'group-globals-one': GroupGlobalsOne;
'group-globals-two': GroupGlobalsTwo;
+ settings: Setting;
};
locale: 'es' | 'en';
user: User & {
@@ -341,7 +342,6 @@ export interface PayloadLockedDocument {
relationTo: 'disable-duplicate';
value: string | DisableDuplicate;
} | null);
- editedAt?: string | null;
globalSlug?: string | null;
user: {
relationTo: 'users';
@@ -455,6 +455,16 @@ export interface GroupGlobalsTwo {
updatedAt?: string | null;
createdAt?: string | null;
}
+/**
+ * This interface was referenced by `Config`'s JSON-Schema
+ * via the `definition` "settings".
+ */
+export interface Setting {
+ id: string;
+ canAccessProtected?: boolean | null;
+ updatedAt?: string | null;
+ createdAt?: string | null;
+}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "auth".
diff --git a/test/admin/shared.ts b/test/admin/shared.ts
index 41e687bc73..7c24349c1d 100644
--- a/test/admin/shared.ts
+++ b/test/admin/shared.ts
@@ -6,6 +6,12 @@ export const slugPluralLabel = 'Posts'
export const customViewPath = '/custom-view'
+export const customNestedViewPath = `${customViewPath}/nested-view`
+
+export const publicCustomViewPath = '/public-custom-view'
+
+export const protectedCustomNestedViewPath = `${publicCustomViewPath}/protected-nested-view`
+
export const customParamViewPathBase = '/custom-param'
export const customParamViewPath = `${customParamViewPathBase}/:id`
@@ -14,8 +20,6 @@ export const customViewTitle = 'Custom View'
export const customParamViewTitle = 'Custom Param View'
-export const customNestedViewPath = `${customViewPath}/nested-view`
-
export const customNestedViewTitle = 'Custom Nested View'
export const customEditLabel = 'Custom Edit Label'
diff --git a/test/admin/slugs.ts b/test/admin/slugs.ts
index 38899b97c5..9be4911a2e 100644
--- a/test/admin/slugs.ts
+++ b/test/admin/slugs.ts
@@ -34,6 +34,8 @@ export const globalSlug = 'global'
export const group1GlobalSlug = 'group-globals-one'
export const group2GlobalSlug = 'group-globals-two'
export const hiddenGlobalSlug = 'hidden-global'
+
+export const settingsGlobalSlug = 'settings'
export const noApiViewGlobalSlug = 'global-no-api-view'
export const globalSlugs = [
customGlobalViews1GlobalSlug,