feat: duplicate doc moved from frontend to backend concern (#5342)
BREAKING CHANGE: collection.admin.hooks.beforeDuplicate removed and instead should be handled using field beforeDuplicate hooks which take the full field hook arguments. * feat: duplicate doc moved from frontend to backend concern * feat: default beforeDuplicate hook functions on unique fields * docs: beforeDuplicate field hook * test: duplicate doc local api * chore: fix build errors * chore: add access.create call to duplicate operation * chore: perfectionist reorder imports
This commit is contained in:
@@ -619,6 +619,23 @@ describe('Fields', () => {
|
||||
|
||||
expect(result.id).toBeDefined()
|
||||
})
|
||||
|
||||
it('should duplicate with unique fields', async () => {
|
||||
const data = {
|
||||
text: 'a',
|
||||
}
|
||||
const doc = await payload.create({
|
||||
collection: 'indexed-fields',
|
||||
data,
|
||||
})
|
||||
const result = await payload.duplicate({
|
||||
collection: 'indexed-fields',
|
||||
id: doc.id,
|
||||
})
|
||||
|
||||
expect(result.id).not.toEqual(doc.id)
|
||||
expect(result.uniqueRequiredText).toStrictEqual('uniqueRequired - Copy')
|
||||
})
|
||||
})
|
||||
|
||||
describe('array', () => {
|
||||
|
||||
Reference in New Issue
Block a user