fix(ui): global documents disabled after save (#6652)

This commit is contained in:
Jacob Fletcher
2024-06-06 10:48:12 -04:00
committed by GitHub
parent 19f8cbcf76
commit 267c23616d
2 changed files with 27 additions and 5 deletions

View File

@@ -354,12 +354,14 @@ export const DocumentInfoProvider: React.FC<
const docPreferences = await getDocPreferences()
const newData = collectionSlug ? json.doc : json.result
const newState = await getFormState({
apiRoute: api,
body: {
id,
collectionSlug,
data: json.doc,
data: newData,
docPreferences,
globalSlug,
locale,
@@ -369,8 +371,6 @@ export const DocumentInfoProvider: React.FC<
serverURL,
})
const newData = json.doc
setInitialState(newState)
setData(newData)
await getDocPermissions(newData)

View File

@@ -69,6 +69,7 @@ describe('admin1', () => {
let page: Page
let geoUrl: AdminUrlUtil
let postsUrl: AdminUrlUtil
let globalURL: AdminUrlUtil
let customViewsURL: AdminUrlUtil
let disableDuplicateURL: AdminUrlUtil
let serverURL: string
@@ -87,6 +88,7 @@ describe('admin1', () => {
}))
geoUrl = new AdminUrlUtil(serverURL, geoCollectionSlug)
postsUrl = new AdminUrlUtil(serverURL, postsCollectionSlug)
globalURL = new AdminUrlUtil(serverURL, globalSlug)
customViewsURL = new AdminUrlUtil(serverURL, customViews2CollectionSlug)
disableDuplicateURL = new AdminUrlUtil(serverURL, disableDuplicateSlug)
@@ -616,6 +618,22 @@ describe('admin1', () => {
})
})
describe('form state', () => {
test('collection — should re-enable fields after save', async () => {
await page.goto(postsUrl.create)
await page.locator('#field-title').fill(title)
await saveDocAndAssert(page)
await expect(page.locator('#field-title')).toBeEnabled()
})
test('global — should re-enable fields after save', async () => {
await page.goto(globalURL.global(globalSlug))
await page.locator('#field-title').fill(title)
await saveDocAndAssert(page)
await expect(page.locator('#field-title')).toBeEnabled()
})
})
describe('document titles', () => {
test('collection — should render fallback titles when creating new', async () => {
await page.goto(postsUrl.create)
@@ -647,8 +665,8 @@ describe('admin1', () => {
})
test('global — should render custom, localized label', async () => {
await page.goto(postsUrl.admin)
await page.waitForURL(postsUrl.admin)
await page.goto(globalURL.global(globalSlug))
await page.waitForURL(globalURL.global(globalSlug))
await openNav(page)
const label = 'My Global Label'
const globalLabel = page.locator(`#nav-global-global`)
@@ -656,6 +674,10 @@ describe('admin1', () => {
await globalLabel.click()
await checkPageTitle(page, label)
await checkBreadcrumb(page, label)
await page.locator('#field-title').fill(title)
await saveDocAndAssert(page)
await checkPageTitle(page, label)
await checkBreadcrumb(page, label)
})
test('global — should render simple label strings', async () => {