test: misc test dir type fixes
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import type { SanitizedConfig } from 'payload/config'
|
||||
|
||||
import { APIError } from '../../packages/payload/src/errors/index.js'
|
||||
import { APIError } from 'payload/errors'
|
||||
|
||||
import { buildConfigWithDefaults } from '../buildConfigWithDefaults.js'
|
||||
import AfterOperation from './collections/AfterOperation/index.js'
|
||||
import ChainingHooks from './collections/ChainingHooks/index.js'
|
||||
|
||||
@@ -116,7 +116,7 @@ describe('Hooks', () => {
|
||||
})
|
||||
|
||||
it('should save data generated with afterRead hooks in nested field structures', async () => {
|
||||
const document: NestedAfterReadHook = await payload.create({
|
||||
const document = await payload.create({
|
||||
collection: nestedAfterReadHooksSlug,
|
||||
data: {
|
||||
group: {
|
||||
|
||||
@@ -17,7 +17,6 @@ export default function deepMerge<T extends object, R extends object>(target: T,
|
||||
if (isObject(target) && isObject(source)) {
|
||||
Object.keys(source).forEach((key) => {
|
||||
if (isObject(source[key])) {
|
||||
// @ts-expect-error
|
||||
if (!(key in target)) {
|
||||
Object.assign(output, { [key]: source[key] })
|
||||
} else {
|
||||
|
||||
@@ -22,27 +22,10 @@ let parentId: string
|
||||
let draftChildId: string
|
||||
let childId: string
|
||||
|
||||
type Args = {
|
||||
parent?: string
|
||||
slug: string
|
||||
status?: 'draft' | 'published'
|
||||
title?: string
|
||||
}
|
||||
|
||||
async function createPage({
|
||||
slug,
|
||||
title = 'Title page',
|
||||
parent,
|
||||
status = 'published',
|
||||
}: Args): Promise<PayloadPage> {
|
||||
async function createPage(data: Partial<PayloadPage>): Promise<PayloadPage> {
|
||||
return payload.create({
|
||||
collection: 'pages',
|
||||
data: {
|
||||
title,
|
||||
slug,
|
||||
_status: status,
|
||||
parent,
|
||||
},
|
||||
data,
|
||||
}) as unknown as Promise<PayloadPage>
|
||||
}
|
||||
|
||||
@@ -65,14 +48,14 @@ describe('Nested Docs Plugin', () => {
|
||||
})
|
||||
childId = childPage.id
|
||||
|
||||
const draftParentPage = await createPage({ slug: 'parent-slug-draft', status: 'draft' })
|
||||
const draftParentPage = await createPage({ slug: 'parent-slug-draft', _status: 'draft' })
|
||||
draftParentId = draftParentPage.id
|
||||
|
||||
const draftChildPage = await createPage({
|
||||
slug: 'child-slug-draft',
|
||||
title: 'Child page',
|
||||
parent: draftParentId,
|
||||
status: 'draft',
|
||||
_status: 'draft',
|
||||
})
|
||||
draftChildId = draftChildPage.id
|
||||
})
|
||||
|
||||
@@ -52,7 +52,7 @@ describe('SEO Plugin', () => {
|
||||
},
|
||||
title: 'Test Page',
|
||||
},
|
||||
})) as unknown as Promise<PayloadPage>
|
||||
})) as unknown as PayloadPage
|
||||
id = createdPage.id
|
||||
})
|
||||
|
||||
|
||||
@@ -64,14 +64,14 @@ describe('Relationships', () => {
|
||||
const nameToQuery = 'name'
|
||||
|
||||
beforeEach(async () => {
|
||||
relation = await payload.create<Relation>({
|
||||
relation = await payload.create({
|
||||
collection: relationSlug,
|
||||
data: {
|
||||
name: nameToQuery,
|
||||
},
|
||||
})
|
||||
|
||||
filteredRelation = await payload.create<Relation>({
|
||||
filteredRelation = await payload.create({
|
||||
collection: relationSlug,
|
||||
data: {
|
||||
name: nameToQuery,
|
||||
@@ -79,21 +79,21 @@ describe('Relationships', () => {
|
||||
},
|
||||
})
|
||||
|
||||
defaultAccessRelation = await payload.create<Relation>({
|
||||
defaultAccessRelation = await payload.create({
|
||||
collection: defaultAccessRelSlug,
|
||||
data: {
|
||||
name: 'default access',
|
||||
},
|
||||
})
|
||||
|
||||
chained3 = await payload.create<ChainedRelation>({
|
||||
chained3 = await payload.create({
|
||||
collection: chainedRelSlug,
|
||||
data: {
|
||||
name: 'chain3',
|
||||
},
|
||||
})
|
||||
|
||||
chained2 = await payload.create<ChainedRelation>({
|
||||
chained2 = await payload.create({
|
||||
collection: chainedRelSlug,
|
||||
data: {
|
||||
name: 'chain2',
|
||||
@@ -101,7 +101,7 @@ describe('Relationships', () => {
|
||||
},
|
||||
})
|
||||
|
||||
chained = await payload.create<ChainedRelation>({
|
||||
chained = await payload.create({
|
||||
collection: chainedRelSlug,
|
||||
data: {
|
||||
name: 'chain1',
|
||||
@@ -109,7 +109,7 @@ describe('Relationships', () => {
|
||||
},
|
||||
})
|
||||
|
||||
chained3 = await payload.update<ChainedRelation>({
|
||||
chained3 = await payload.update({
|
||||
id: chained3.id,
|
||||
collection: chainedRelSlug,
|
||||
data: {
|
||||
@@ -119,7 +119,7 @@ describe('Relationships', () => {
|
||||
})
|
||||
|
||||
generatedCustomId = `custom-${randomBytes(32).toString('hex').slice(0, 12)}`
|
||||
customIdRelation = await payload.create<CustomIdRelation>({
|
||||
customIdRelation = await payload.create({
|
||||
collection: customIdSlug,
|
||||
data: {
|
||||
id: generatedCustomId,
|
||||
@@ -128,7 +128,7 @@ describe('Relationships', () => {
|
||||
})
|
||||
|
||||
generatedCustomIdNumber = Math.floor(Math.random() * 1_000_000) + 1
|
||||
customIdNumberRelation = await payload.create<CustomIdNumberRelation>({
|
||||
customIdNumberRelation = await payload.create({
|
||||
collection: customIdNumberSlug,
|
||||
data: {
|
||||
id: generatedCustomIdNumber,
|
||||
@@ -431,7 +431,7 @@ describe('Relationships', () => {
|
||||
},
|
||||
})
|
||||
|
||||
thirdLevelID = thirdLevelDoc.id
|
||||
thirdLevelID = thirdLevelDoc.id as string
|
||||
|
||||
const secondLevelDoc = await payload.create({
|
||||
collection: 'chained',
|
||||
@@ -441,7 +441,7 @@ describe('Relationships', () => {
|
||||
},
|
||||
})
|
||||
|
||||
secondLevelID = secondLevelDoc.id
|
||||
secondLevelID = secondLevelDoc.id as string
|
||||
|
||||
const firstLevelDoc = await payload.create({
|
||||
collection: 'chained',
|
||||
@@ -451,7 +451,7 @@ describe('Relationships', () => {
|
||||
},
|
||||
})
|
||||
|
||||
firstLevelID = firstLevelDoc.id
|
||||
firstLevelID = firstLevelDoc.id as string
|
||||
})
|
||||
|
||||
it('should allow querying one level deep', async () => {
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
draftCollectionSlug,
|
||||
postCollectionSlug,
|
||||
versionCollectionSlug,
|
||||
} from '../slugs'
|
||||
} from '../slugs.js'
|
||||
|
||||
const Posts: CollectionConfig = {
|
||||
slug: postCollectionSlug,
|
||||
|
||||
@@ -70,7 +70,7 @@ describe('Versions', () => {
|
||||
title: 'Here is an autosave post in EN',
|
||||
},
|
||||
})
|
||||
collectionLocalPostID = autosavePost.id
|
||||
collectionLocalPostID = autosavePost.id as string
|
||||
|
||||
await payload.update({
|
||||
id: collectionLocalPostID,
|
||||
@@ -334,7 +334,6 @@ describe('Versions', () => {
|
||||
draft: true,
|
||||
})
|
||||
|
||||
// @ts-expect-error
|
||||
let updatedPost = await payload.update({
|
||||
id: versionedPost.id,
|
||||
collection: draftCollectionSlug,
|
||||
@@ -350,7 +349,7 @@ describe('Versions', () => {
|
||||
},
|
||||
draft: true,
|
||||
})
|
||||
// @ts-expect-error
|
||||
|
||||
updatedPost = await payload.update({
|
||||
id: versionedPost.id,
|
||||
collection: draftCollectionSlug,
|
||||
|
||||
Reference in New Issue
Block a user