chore: cleans up admin e2e tests (#3636)

This commit is contained in:
Jacob Fletcher
2023-10-13 12:04:05 -04:00
committed by GitHub
parent 4bd01df411
commit 483f93bfcf
18 changed files with 408 additions and 333 deletions

View File

@@ -0,0 +1,23 @@
import type { CollectionConfig } from '../../../packages/payload/src/collections/config/types'
import CustomEditView from '../components/views/CustomEdit'
export const CustomViews1: CollectionConfig = {
slug: 'custom-views-one',
versions: true,
admin: {
components: {
views: {
// This will override the entire Edit view including all nested views, i.e. `/edit/:id/*`
// To override one specific nested view, use the nested view's slug as the key
Edit: CustomEditView,
},
},
},
fields: [
{
name: 'title',
type: 'text',
},
],
}

View File

@@ -0,0 +1,41 @@
import type { CollectionConfig } from '../../../packages/payload/src/collections/config/types'
import CustomTabComponent from '../components/CustomTabComponent'
import CustomDefaultEditView from '../components/views/CustomDefaultEdit'
import CustomVersionsView from '../components/views/CustomVersions'
import CustomView from '../components/views/CustomView'
export const CustomViews2: CollectionConfig = {
slug: 'custom-views-two',
versions: true,
admin: {
components: {
views: {
Edit: {
// This will override one specific nested view within the `/edit/:id` route, i.e. `/edit/:id/versions`
Default: CustomDefaultEditView,
Versions: CustomVersionsView,
MyCustomView: {
path: '/custom-tab-view',
Component: CustomView,
Tab: {
label: 'Custom',
href: '/custom-tab-view',
},
},
MyCustomViewWithCustomTab: {
path: '/custom-tab-component',
Component: CustomView,
Tab: CustomTabComponent,
},
},
},
},
},
fields: [
{
name: 'title',
type: 'text',
},
],
}

View File

@@ -0,0 +1,11 @@
import type { CollectionConfig } from '../../../packages/payload/src/collections/config/types'
export const Geo: CollectionConfig = {
slug: 'geo',
fields: [
{
name: 'point',
type: 'point',
},
],
}

View File

@@ -0,0 +1,16 @@
import type { CollectionConfig } from '../../../packages/payload/src/collections/config/types'
import { group1Collection1Slug } from '../shared'
export const CollectionGroup1A: CollectionConfig = {
slug: group1Collection1Slug,
admin: {
group: 'One',
},
fields: [
{
name: 'title',
type: 'text',
},
],
}

View File

@@ -0,0 +1,16 @@
import type { CollectionConfig } from '../../../packages/payload/src/collections/config/types'
import { group1Collection2Slug } from '../shared'
export const CollectionGroup1B: CollectionConfig = {
slug: group1Collection2Slug,
admin: {
group: 'One',
},
fields: [
{
name: 'title',
type: 'text',
},
],
}

View File

@@ -0,0 +1,14 @@
import type { CollectionConfig } from '../../../packages/payload/src/collections/config/types'
export const CollectionGroup2A: CollectionConfig = {
slug: 'group-two-collection-ones',
admin: {
group: 'One',
},
fields: [
{
name: 'title',
type: 'text',
},
],
}

View File

@@ -0,0 +1,14 @@
import type { CollectionConfig } from '../../../packages/payload/src/collections/config/types'
export const CollectionGroup2B: CollectionConfig = {
slug: 'group-two-collection-twos',
admin: {
group: 'One',
},
fields: [
{
name: 'title',
type: 'text',
},
],
}

View File

@@ -0,0 +1,14 @@
import type { CollectionConfig } from '../../../packages/payload/src/collections/config/types'
export const CollectionHidden: CollectionConfig = {
slug: 'hidden-collection',
admin: {
hidden: () => true,
},
fields: [
{
name: 'title',
type: 'text',
},
],
}

View File

@@ -0,0 +1,78 @@
import type { CollectionConfig } from '../../../packages/payload/src/collections/config/types'
import { slateEditor } from '../../../packages/richtext-slate/src'
import DemoUIFieldCell from '../components/DemoUIField/Cell'
import DemoUIFieldField from '../components/DemoUIField/Field'
import { postsSlug, slugPluralLabel, slugSingularLabel } from '../shared'
export const Posts: CollectionConfig = {
slug: postsSlug,
labels: {
singular: slugSingularLabel,
plural: slugPluralLabel,
},
admin: {
description: 'Description',
listSearchableFields: ['title', 'description', 'number'],
group: 'One',
useAsTitle: 'title',
defaultColumns: ['id', 'number', 'title', 'description', 'demoUIField'],
preview: () => 'https://payloadcms.com',
},
versions: {
drafts: true,
},
fields: [
{
type: 'tabs',
tabs: [
{
label: 'Tab 1',
fields: [
{
name: 'title',
type: 'text',
},
{
name: 'description',
type: 'text',
},
{
name: 'number',
type: 'number',
},
{
name: 'richText',
type: 'richText',
editor: slateEditor({
admin: {
elements: ['relationship'],
},
}),
},
{
type: 'ui',
name: 'demoUIField',
label: 'Demo UI Field',
admin: {
components: {
Field: DemoUIFieldField,
Cell: DemoUIFieldCell,
},
},
},
],
},
],
},
{
name: 'sidebarField',
type: 'text',
admin: {
position: 'sidebar',
description:
'This is a very long description that takes many characters to complete and hopefully will wrap instead of push the sidebar open, lorem ipsum dolor sit amet consectetur adipisicing elit. Quisquam, voluptatum voluptates. Quisquam, voluptatum voluptates.',
},
},
],
}

View File

@@ -0,0 +1,10 @@
import type { CollectionConfig } from '../../../packages/payload/src/collections/config/types'
export const Users: CollectionConfig = {
slug: 'users',
auth: true,
admin: {
useAsTitle: 'email',
},
fields: [],
}

View File

@@ -6,7 +6,7 @@ import type { AdminViewComponent } from '../../../../../packages/payload/src/con
import { useStepNav } from '../../../../../packages/payload/src/admin/components/elements/StepNav'
import { useConfig } from '../../../../../packages/payload/src/admin/components/utilities/Config'
const CustomDefaultView: AdminViewComponent = ({
const CustomDefaultEditView: AdminViewComponent = ({
canAccessAdmin,
// collection,
// global,
@@ -72,4 +72,4 @@ const CustomDefaultView: AdminViewComponent = ({
)
}
export default CustomDefaultView
export default CustomDefaultEditView

View File

@@ -1,31 +1,31 @@
import path from 'path'
import { mapAsync } from '../../packages/payload/src/utilities/mapAsync'
import { slateEditor } from '../../packages/richtext-slate/src'
import { buildConfigWithDefaults } from '../buildConfigWithDefaults'
import { devUser } from '../credentials'
import { CustomViews1 } from './collections/CustomViews1'
import { CustomViews2 } from './collections/CustomViews2'
import { Geo } from './collections/Geo'
import { CollectionGroup1A } from './collections/Group1A'
import { CollectionGroup1B } from './collections/Group1B'
import { CollectionGroup2A } from './collections/Group2A'
import { CollectionGroup2B } from './collections/Group2B'
import { CollectionHidden } from './collections/Hidden'
import { Posts } from './collections/Posts'
import { Users } from './collections/Users'
import AfterDashboard from './components/AfterDashboard'
import AfterNavLinks from './components/AfterNavLinks'
import BeforeLogin from './components/BeforeLogin'
import CustomTabComponent from './components/CustomTabComponent'
import DemoUIFieldCell from './components/DemoUIField/Cell'
import DemoUIFieldField from './components/DemoUIField/Field'
import Logout from './components/Logout'
import CustomDefaultView from './components/views/CustomDefault'
import CustomDefaultEditView from './components/views/CustomDefaultEdit'
import CustomEditView from './components/views/CustomEdit'
import CustomMinimalRoute from './components/views/CustomMinimal'
import CustomVersionsView from './components/views/CustomVersions'
import CustomView from './components/views/CustomView'
import {
globalSlug,
group1Collection1Slug,
group1Collection2Slug,
group1GlobalSlug,
postsSlug,
slugPluralLabel,
slugSingularLabel,
} from './shared'
import { CustomGlobalViews1 } from './globals/CustomViews1'
import { CustomGlobalViews2 } from './globals/CustomViews2'
import { Global } from './globals/Global'
import { GlobalGroup1A } from './globals/Group1A'
import { GlobalGroup1B } from './globals/Group1B'
import { GlobalHidden } from './globals/Hidden'
import { postsSlug } from './shared'
export interface Post {
createdAt: Date
@@ -74,322 +74,24 @@ export default buildConfigWithDefaults({
locales: ['en', 'es'],
},
collections: [
{
slug: 'users',
auth: true,
admin: {
useAsTitle: 'email',
},
fields: [],
},
{
slug: 'hidden-collection',
admin: {
hidden: () => true,
},
fields: [
{
name: 'title',
type: 'text',
},
],
},
{
slug: postsSlug,
labels: {
singular: slugSingularLabel,
plural: slugPluralLabel,
},
admin: {
description: 'Description',
listSearchableFields: ['title', 'description', 'number'],
group: 'One',
useAsTitle: 'title',
defaultColumns: ['id', 'number', 'title', 'description', 'demoUIField'],
preview: () => 'https://payloadcms.com',
},
versions: {
drafts: true,
},
fields: [
{
type: 'tabs',
tabs: [
{
label: 'Tab 1',
fields: [
{
name: 'title',
type: 'text',
},
{
name: 'description',
type: 'text',
},
{
name: 'number',
type: 'number',
},
{
name: 'richText',
type: 'richText',
editor: slateEditor({
admin: {
elements: ['relationship'],
},
}),
},
{
type: 'ui',
name: 'demoUIField',
label: 'Demo UI Field',
admin: {
components: {
Field: DemoUIFieldField,
Cell: DemoUIFieldCell,
},
},
},
],
},
],
},
{
name: 'sidebarField',
type: 'text',
admin: {
position: 'sidebar',
description:
'This is a very long description that takes many characters to complete and hopefully will wrap instead of push the sidebar open, lorem ipsum dolor sit amet consectetur adipisicing elit. Quisquam, voluptatum voluptates. Quisquam, voluptatum voluptates.',
},
},
],
},
{
slug: 'custom-views-one',
versions: true,
admin: {
components: {
views: {
// This will override the entire Edit view including all nested views, i.e. `/edit/:id/*`
// To override one specific nested view, use the nested view's slug as the key
Edit: CustomEditView,
},
},
},
fields: [
{
name: 'title',
type: 'text',
},
],
},
{
slug: 'custom-views-two',
versions: true,
admin: {
components: {
views: {
Edit: {
// This will override one specific nested view within the `/edit/:id` route, i.e. `/edit/:id/versions`
Default: CustomDefaultEditView,
Versions: CustomVersionsView,
MyCustomView: {
path: '/custom-tab-view',
Component: CustomView,
Tab: {
label: 'Custom',
href: '/custom-tab-view',
},
},
MyCustomViewWithCustomTab: {
path: '/custom-tab-component',
Component: CustomView,
Tab: CustomTabComponent,
},
},
},
},
},
fields: [
{
name: 'title',
type: 'text',
},
],
},
{
slug: group1Collection1Slug,
admin: {
group: 'One',
},
fields: [
{
name: 'title',
type: 'text',
},
],
},
{
slug: group1Collection2Slug,
admin: {
group: 'One',
},
fields: [
{
name: 'title',
type: 'text',
},
],
},
{
slug: 'group-two-collection-ones',
admin: {
group: 'Two',
},
fields: [
{
name: 'title',
type: 'text',
},
],
},
{
slug: 'group-two-collection-twos',
admin: {
group: 'Two',
},
fields: [
{
name: 'title',
type: 'text',
},
],
},
{
slug: 'geo',
fields: [
{
name: 'point',
type: 'point',
},
],
},
Posts,
Users,
CollectionHidden,
CustomViews1,
CustomViews2,
CollectionGroup1A,
CollectionGroup1B,
CollectionGroup2A,
CollectionGroup2B,
Geo,
],
globals: [
{
slug: 'hidden-global',
admin: {
hidden: () => true,
},
fields: [
{
name: 'title',
type: 'text',
},
],
},
{
slug: globalSlug,
label: {
en: 'My Global Label',
},
admin: {
group: 'Group',
preview: () => 'https://payloadcms.com',
},
versions: {
drafts: true,
},
fields: [
{
name: 'title',
type: 'text',
},
{
name: 'sidebarField',
type: 'text',
admin: {
position: 'sidebar',
},
},
],
},
{
slug: 'custom-global-views-one',
versions: true,
admin: {
components: {
views: {
Edit: CustomEditView,
},
},
},
fields: [
{
name: 'title',
type: 'text',
},
],
},
{
slug: 'custom-global-views-two',
versions: true,
admin: {
components: {
views: {
Edit: {
Default: CustomDefaultEditView,
Versions: CustomVersionsView,
MyCustomView: {
path: '/custom-tab-view',
Component: CustomView,
Tab: {
label: 'Custom',
href: '/custom-tab-view',
},
},
MyCustomViewWithCustomTab: {
path: '/custom-tab-component',
Component: CustomView,
Tab: CustomTabComponent,
},
},
},
},
},
fields: [
{
name: 'title',
type: 'text',
},
],
},
{
slug: group1GlobalSlug,
label: 'Group Globals 1',
admin: {
group: 'Group',
},
fields: [
{
name: 'title',
type: 'text',
},
],
},
{
slug: 'group-globals-two',
admin: {
group: 'Group',
},
fields: [
{
name: 'title',
type: 'text',
},
],
},
GlobalHidden,
Global,
CustomGlobalViews1,
CustomGlobalViews2,
GlobalGroup1A,
GlobalGroup1B,
],
onInit: async (payload) => {
await payload.create({

View File

@@ -0,0 +1,21 @@
import type { GlobalConfig } from '../../../packages/payload/src/globals/config/types'
import CustomEditView from '../components/views/CustomEdit'
export const CustomGlobalViews1: GlobalConfig = {
slug: 'custom-global-views-one',
versions: true,
admin: {
components: {
views: {
Edit: CustomEditView,
},
},
},
fields: [
{
name: 'title',
type: 'text',
},
],
}

View File

@@ -0,0 +1,40 @@
import type { GlobalConfig } from '../../../packages/payload/src/globals/config/types'
import CustomTabComponent from '../components/CustomTabComponent'
import CustomDefaultEditView from '../components/views/CustomDefaultEdit'
import CustomVersionsView from '../components/views/CustomVersions'
import CustomView from '../components/views/CustomView'
export const CustomGlobalViews2: GlobalConfig = {
slug: 'custom-global-views-two',
versions: true,
admin: {
components: {
views: {
Edit: {
Default: CustomDefaultEditView,
Versions: CustomVersionsView,
MyCustomView: {
path: '/custom-tab-view',
Component: CustomView,
Tab: {
label: 'Custom',
href: '/custom-tab-view',
},
},
MyCustomViewWithCustomTab: {
path: '/custom-tab-component',
Component: CustomView,
Tab: CustomTabComponent,
},
},
},
},
},
fields: [
{
name: 'title',
type: 'text',
},
],
}

View File

@@ -0,0 +1,30 @@
import type { GlobalConfig } from '../../../packages/payload/src/globals/config/types'
import { globalSlug } from '../shared'
export const Global: GlobalConfig = {
slug: globalSlug,
label: {
en: 'My Global Label',
},
admin: {
group: 'Group',
preview: () => 'https://payloadcms.com',
},
versions: {
drafts: true,
},
fields: [
{
name: 'title',
type: 'text',
},
{
name: 'sidebarField',
type: 'text',
admin: {
position: 'sidebar',
},
},
],
}

View File

@@ -0,0 +1,17 @@
import type { GlobalConfig } from '../../../packages/payload/src/globals/config/types'
import { group1GlobalSlug } from '../shared'
export const GlobalGroup1A: GlobalConfig = {
slug: group1GlobalSlug,
label: 'Group Globals 1',
admin: {
group: 'Group',
},
fields: [
{
name: 'title',
type: 'text',
},
],
}

View File

@@ -0,0 +1,14 @@
import type { GlobalConfig } from '../../../packages/payload/src/globals/config/types'
export const GlobalGroup1B: GlobalConfig = {
slug: 'group-globals-two',
admin: {
group: 'Group',
},
fields: [
{
name: 'title',
type: 'text',
},
],
}

View File

@@ -0,0 +1,14 @@
import type { GlobalConfig } from '../../../packages/payload/src/globals/config/types'
export const GlobalHidden: GlobalConfig = {
slug: 'hidden-global',
admin: {
hidden: () => true,
},
fields: [
{
name: 'title',
type: 'text',
},
],
}