chore: start live-preview int test migration

This commit is contained in:
Jarrod Flesch
2024-02-16 22:49:08 -05:00
parent dcf23d0952
commit 28dc5a5b8c
3 changed files with 12 additions and 19 deletions

View File

@@ -28,8 +28,8 @@ export const deleteAssociatedFiles: (args: Args) => Promise<void> = async ({
}) => {
if (!collectionConfig.upload) return
if (overrideDelete || files.length > 0) {
const { staticDir } = collectionConfig.upload
const staticPath = path.resolve(config.paths.configDir, staticDir)
const staticPath = path.resolve(collectionConfig.upload.staticDir)
// const staticPath = path.resolve(config.paths.configDir, collectionConfig.upload.staticDir)
const fileToDelete = `${staticPath}/${doc.filename}`

View File

@@ -61,7 +61,8 @@ export const generateFileData = async <T>({
let staticPath = staticDir
if (staticDir.indexOf('/') !== 0) {
staticPath = path.resolve(config.paths.configDir, staticDir)
staticPath = path.resolve(staticDir)
// staticPath = path.resolve(config.paths.configDir, staticDir)
}
if (!file && uploadEdits && data) {

View File

@@ -1,26 +1,25 @@
import path from 'path'
import type { Payload } from '../../packages/payload/src'
import type { Media, Page, Post, Tenant } from './payload-types'
import { handleMessage } from '../../packages/live-preview/src/handleMessage'
import { mergeData } from '../../packages/live-preview/src/mergeData'
import { traverseRichText } from '../../packages/live-preview/src/traverseRichText'
import payload from '../../packages/payload/src'
import { getPayload } from '../../packages/payload/src'
import getFileByPath from '../../packages/payload/src/uploads/getFileByPath'
import { fieldSchemaToJSON } from '../../packages/payload/src/utilities/fieldSchemaToJSON'
import { initPayloadTest } from '../helpers/configHelpers'
import { RESTClient } from '../helpers/rest'
import { startMemoryDB } from '../startMemoryDB'
import { Pages } from './collections/Pages'
import { postsSlug } from './collections/Posts'
import configPromise from './config'
import { pagesSlug, tenantsSlug } from './shared'
require('isomorphic-fetch')
import { tenantsSlug } from './shared'
const schemaJSON = fieldSchemaToJSON(Pages.fields)
let payload: Payload
describe('Collections - Live Preview', () => {
let client
let serverURL
let testPost: Post
@@ -28,15 +27,8 @@ describe('Collections - Live Preview', () => {
let media: Media
beforeAll(async () => {
const { serverURL: incomingServerURL } = await initPayloadTest({
__dirname,
init: { local: false },
})
serverURL = incomingServerURL
const config = await configPromise
client = new RESTClient(config, { serverURL, defaultSlug: pagesSlug })
await client.login()
const config = await startMemoryDB(configPromise)
payload = await getPayload({ config })
tenant = await payload.create({
collection: tenantsSlug,