Compare commits

...

2 Commits

Author SHA1 Message Date
Jacob Fletcher
9c3bce1258 revert test 2025-06-30 23:52:45 -04:00
Jacob Fletcher
e6380159d9 revert: should select document after creation from relationship field 2025-06-30 23:43:35 -04:00
3 changed files with 5 additions and 54 deletions

View File

@@ -52,13 +52,7 @@ export const AddNewRelation: React.FC<Props> = ({
const onSave: DocumentDrawerContextType['onSave'] = useCallback(
({ doc, operation }) => {
// if autosave is enabled, the operation will be 'update'
const isAutosaveEnabled =
typeof collectionConfig?.versions?.drafts === 'object'
? collectionConfig.versions.drafts.autosave
: false
if (operation === 'create' || (operation === 'update' && isAutosaveEnabled)) {
if (operation === 'create') {
// ensure the value is not already in the array
let isNewValue = false
if (!value) {

View File

@@ -23,7 +23,6 @@ import { useLocale } from '../../providers/Locale/index.js'
import { useTranslation } from '../../providers/Translation/index.js'
import { formatTimeToNow } from '../../utilities/formatDocTitle/formatDateTitle.js'
import { reduceFieldsToValuesWithValidation } from '../../utilities/reduceFieldsToValuesWithValidation.js'
import { useDocumentDrawerContext } from '../DocumentDrawer/Provider.js'
import { LeaveWithoutSaving } from '../LeaveWithoutSaving/index.js'
import './index.scss'
@@ -57,8 +56,6 @@ export const Autosave: React.FC<Props> = ({ id, collection, global: globalDoc })
updateSavedDocumentData,
} = useDocumentInfo()
const { onSave: onSaveFromDocumentDrawer } = useDocumentDrawerContext()
const { reportUpdate } = useDocumentEvents()
const { dispatchFields, isValid, setBackgroundProcessing, setIsValid, setSubmitted } = useForm()
@@ -95,18 +92,18 @@ export const Autosave: React.FC<Props> = ({ id, collection, global: globalDoc })
// Store fields in ref so the autosave func
// can always retrieve the most to date copies
// after the timeout has executed
// eslint-disable-next-line react-compiler/react-compiler -- TODO: fix
fieldRef.current = fields
// Store modified in ref so the autosave func
// can bail out if modified becomes false while
// timing out during autosave
// eslint-disable-next-line react-compiler/react-compiler -- TODO: fix
modifiedRef.current = modified
// Store locale in ref so the autosave func
// can always retrieve the most to date locale
// eslint-disable-next-line react-compiler/react-compiler -- TODO: fix
localeRef.current = locale
const { queueTask } = useQueues()
@@ -186,8 +183,6 @@ export const Autosave: React.FC<Props> = ({ id, collection, global: globalDoc })
// We need to log the time in order to figure out if we need to trigger the state off later
endTimestamp = newDate.getTime()
const json = await res.json()
if (res.status === 200) {
setLastUpdateTime(newDate.getTime())
@@ -197,20 +192,13 @@ export const Autosave: React.FC<Props> = ({ id, collection, global: globalDoc })
updatedAt: newDate.toISOString(),
})
// if onSaveFromDocumentDrawer is defined, call it
if (typeof onSaveFromDocumentDrawer === 'function') {
void onSaveFromDocumentDrawer({
...json,
operation: 'update',
})
}
if (!mostRecentVersionIsAutosaved) {
incrementVersionCount()
setMostRecentVersionIsAutosaved(true)
setUnpublishedVersionCount((prev) => prev + 1)
}
}
const json = await res.json()
if (versionsConfig?.drafts && versionsConfig?.drafts?.validate && json?.errors) {
if (Array.isArray(json.errors)) {

View File

@@ -175,37 +175,6 @@ describe('Versions', () => {
}).toPass({ timeout: 10000, intervals: [100] })
})
test('autosave relationships - should select doc after creating from relationship field', async () => {
await page.goto(postURL.create)
const autosaveRelationField = page.locator('#field-relationToAutosaves')
await expect(autosaveRelationField).toBeVisible()
const addNewButton = autosaveRelationField.locator(
'.relationship-add-new__add-button.doc-drawer__toggler',
)
await addNewButton.click()
const titleField = page.locator('#field-title')
const descriptionField = page.locator('#field-description')
await titleField.fill('test')
await descriptionField.fill('test')
const createdDate = await page.textContent(
'li:has(p:has-text("Created:")) .doc-controls__value',
)
// wait for modified date and created date to be different
await expect(async () => {
const modifiedDateLocator = page.locator(
'li:has(p:has-text("Last Modified:")) .doc-controls__value',
)
await expect(modifiedDateLocator).not.toHaveText(createdDate ?? '')
}).toPass({ timeout: POLL_TOPASS_TIMEOUT, intervals: [100] })
const closeDrawer = page.locator('.doc-drawer__header-close')
await closeDrawer.click()
const fieldValue = autosaveRelationField.locator('.value-container')
await expect(fieldValue).toContainText('test')
})
test('should show collection versions view level action in collection versions view', async () => {
await page.goto(url.list)
await page.locator('tbody tr .cell-title a').first().click()