Merge branch 'main' into fix/localized-status-UI
This commit is contained in:
@@ -16,7 +16,7 @@ const AutosavePosts: CollectionConfig = {
|
||||
maxPerDoc: 35,
|
||||
drafts: {
|
||||
autosave: {
|
||||
interval: 2000,
|
||||
interval: 100,
|
||||
},
|
||||
schedulePublish: true,
|
||||
},
|
||||
@@ -53,12 +53,30 @@ const AutosavePosts: CollectionConfig = {
|
||||
unique: true,
|
||||
localized: true,
|
||||
},
|
||||
{
|
||||
name: 'computedTitle',
|
||||
label: 'Computed Title',
|
||||
type: 'text',
|
||||
hooks: {
|
||||
beforeChange: [({ data }) => data?.title],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'description',
|
||||
label: 'Description',
|
||||
type: 'textarea',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
name: 'array',
|
||||
type: 'array',
|
||||
fields: [
|
||||
{
|
||||
name: 'text',
|
||||
type: 'text',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
@@ -1285,6 +1285,63 @@ describe('Versions', () => {
|
||||
// Remove listener
|
||||
page.removeListener('dialog', acceptAlert)
|
||||
})
|
||||
|
||||
test('- with autosave - applies field hooks to form state after autosave runs', async () => {
|
||||
const url = new AdminUrlUtil(serverURL, autosaveCollectionSlug)
|
||||
await page.goto(url.create)
|
||||
const titleField = page.locator('#field-title')
|
||||
await titleField.fill('Initial')
|
||||
|
||||
await waitForAutoSaveToRunAndComplete(page)
|
||||
|
||||
const computedTitleField = page.locator('#field-computedTitle')
|
||||
await expect(computedTitleField).toHaveValue('Initial')
|
||||
})
|
||||
|
||||
test('- with autosave - does not override local changes to form state after autosave runs', async () => {
|
||||
const url = new AdminUrlUtil(serverURL, autosaveCollectionSlug)
|
||||
await page.goto(url.create)
|
||||
const titleField = page.locator('#field-title')
|
||||
|
||||
// press slower than the autosave interval, but not faster than the response and processing
|
||||
await titleField.pressSequentially('Initial', {
|
||||
delay: 150,
|
||||
})
|
||||
|
||||
await waitForAutoSaveToRunAndComplete(page)
|
||||
|
||||
await expect(titleField).toHaveValue('Initial')
|
||||
const computedTitleField = page.locator('#field-computedTitle')
|
||||
await expect(computedTitleField).toHaveValue('Initial')
|
||||
})
|
||||
|
||||
test('- with autosave - does not display success toast after autosave complete', async () => {
|
||||
const url = new AdminUrlUtil(serverURL, autosaveCollectionSlug)
|
||||
await page.goto(url.create)
|
||||
const titleField = page.locator('#field-title')
|
||||
await titleField.fill('Initial')
|
||||
|
||||
let hasDisplayedToast = false
|
||||
|
||||
const startTime = Date.now()
|
||||
const timeout = 5000
|
||||
const interval = 100
|
||||
|
||||
while (Date.now() - startTime < timeout) {
|
||||
const isHidden = await page.locator('.payload-toast-item').isHidden()
|
||||
console.log(`Toast is hidden: ${isHidden}`)
|
||||
|
||||
// eslint-disable-next-line playwright/no-conditional-in-test
|
||||
if (!isHidden) {
|
||||
hasDisplayedToast = true
|
||||
break
|
||||
}
|
||||
|
||||
await wait(interval)
|
||||
}
|
||||
|
||||
expect(hasDisplayedToast).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe('Globals - publish individual locale', () => {
|
||||
|
||||
@@ -197,7 +197,14 @@ export interface Post {
|
||||
export interface AutosavePost {
|
||||
id: string;
|
||||
title: string;
|
||||
computedTitle?: string | null;
|
||||
description: string;
|
||||
array?:
|
||||
| {
|
||||
text?: string | null;
|
||||
id?: string | null;
|
||||
}[]
|
||||
| null;
|
||||
updatedAt: string;
|
||||
createdAt: string;
|
||||
_status?: ('draft' | 'published') | null;
|
||||
@@ -366,7 +373,6 @@ export interface Diff {
|
||||
textInNamedTab1InBlock?: string | null;
|
||||
};
|
||||
textInUnnamedTab2InBlock?: string | null;
|
||||
textInUnnamedTab2InBlockAccessFalse?: string | null;
|
||||
id?: string | null;
|
||||
blockName?: string | null;
|
||||
blockType: 'TabsBlock';
|
||||
@@ -469,7 +475,6 @@ export interface Diff {
|
||||
};
|
||||
textInUnnamedTab2?: string | null;
|
||||
text?: string | null;
|
||||
textCannotRead?: string | null;
|
||||
textArea?: string | null;
|
||||
upload?: (string | null) | Media;
|
||||
uploadHasMany?: (string | Media)[] | null;
|
||||
@@ -787,7 +792,14 @@ export interface PostsSelect<T extends boolean = true> {
|
||||
*/
|
||||
export interface AutosavePostsSelect<T extends boolean = true> {
|
||||
title?: T;
|
||||
computedTitle?: T;
|
||||
description?: T;
|
||||
array?:
|
||||
| T
|
||||
| {
|
||||
text?: T;
|
||||
id?: T;
|
||||
};
|
||||
updatedAt?: T;
|
||||
createdAt?: T;
|
||||
_status?: T;
|
||||
@@ -960,7 +972,6 @@ export interface DiffSelect<T extends boolean = true> {
|
||||
textInNamedTab1InBlock?: T;
|
||||
};
|
||||
textInUnnamedTab2InBlock?: T;
|
||||
textInUnnamedTab2InBlockAccessFalse?: T;
|
||||
id?: T;
|
||||
blockName?: T;
|
||||
};
|
||||
@@ -995,7 +1006,6 @@ export interface DiffSelect<T extends boolean = true> {
|
||||
};
|
||||
textInUnnamedTab2?: T;
|
||||
text?: T;
|
||||
textCannotRead?: T;
|
||||
textArea?: T;
|
||||
upload?: T;
|
||||
uploadHasMany?: T;
|
||||
|
||||
Reference in New Issue
Block a user