Merge remote-tracking branch 'origin/main' into feat/lexical-on-demand

This commit is contained in:
Alessio Gravili
2025-09-02 10:31:55 -07:00
19 changed files with 243 additions and 54 deletions

View File

@@ -590,6 +590,7 @@ describe('Fields', () => {
describe('timestamps', () => {
const tenMinutesAgo = new Date(Date.now() - 1000 * 60 * 10)
const tenMinutesLater = new Date(Date.now() + 1000 * 60 * 10)
let doc
beforeEach(async () => {
doc = await payload.create({
@@ -612,7 +613,7 @@ describe('Fields', () => {
expect(docs.map(({ id }) => id)).toContain(doc.id)
})
it('should query createdAt', async () => {
it('should query createdAt (greater_than_equal with results)', async () => {
const result = await payload.find({
collection: 'date-fields',
depth: 0,
@@ -626,6 +627,76 @@ describe('Fields', () => {
expect(result.docs[0].id).toEqual(doc.id)
})
it('should query createdAt (greater_than_equal with no results)', async () => {
const result = await payload.find({
collection: 'date-fields',
depth: 0,
where: {
createdAt: {
greater_than_equal: tenMinutesLater,
},
},
})
expect(result.totalDocs).toBe(0)
})
it('should query createdAt (less_than with results)', async () => {
const result = await payload.find({
collection: 'date-fields',
depth: 0,
where: {
createdAt: {
less_than: tenMinutesLater,
},
},
})
expect(result.docs[0].id).toEqual(doc.id)
})
it('should query createdAt (less_than with no results)', async () => {
const result = await payload.find({
collection: 'date-fields',
depth: 0,
where: {
createdAt: {
less_than: tenMinutesAgo,
},
},
})
expect(result.totalDocs).toBe(0)
})
it('should query createdAt (in with results)', async () => {
const result = await payload.find({
collection: 'date-fields',
depth: 0,
where: {
createdAt: {
in: [new Date(doc.createdAt)],
},
},
})
expect(result.docs[0].id).toBe(doc.id)
})
it('should query createdAt (in without results)', async () => {
const result = await payload.find({
collection: 'date-fields',
depth: 0,
where: {
createdAt: {
in: [tenMinutesAgo],
},
},
})
expect(result.totalDocs).toBe(0)
})
// Function to generate random date between start and end dates
function getRandomDate(start: Date, end: Date): string {
const date = new Date(start.getTime() + Math.random() * (end.getTime() - start.getTime()))

View File

@@ -4,6 +4,9 @@ export const noLocalizedFieldsCollectionSlug = 'no-localized-fields'
export const NoLocalizedFieldsCollection: CollectionConfig = {
slug: noLocalizedFieldsCollectionSlug,
versions: {
drafts: true,
},
fields: [
{
name: 'text',

View File

@@ -29,6 +29,7 @@ import { initPayloadE2ENoConfig } from '../helpers/initPayloadE2ENoConfig.js'
import { POLL_TOPASS_TIMEOUT, TEST_TIMEOUT_LONG } from '../playwright.config.js'
import { arrayCollectionSlug } from './collections/Array/index.js'
import { nestedToArrayAndBlockCollectionSlug } from './collections/NestedToArrayAndBlock/index.js'
import { noLocalizedFieldsCollectionSlug } from './collections/NoLocalizedFields/index.js'
import { richTextSlug } from './collections/RichText/index.js'
import {
arrayWithFallbackCollectionSlug,
@@ -61,6 +62,7 @@ let urlCannotCreateDefaultLocale: AdminUrlUtil
let urlPostsWithDrafts: AdminUrlUtil
let urlArray: AdminUrlUtil
let arrayWithFallbackURL: AdminUrlUtil
let noLocalizedFieldsURL: AdminUrlUtil
const title = 'english title'
const spanishTitle = 'spanish title'
@@ -87,6 +89,7 @@ describe('Localization', () => {
urlPostsWithDrafts = new AdminUrlUtil(serverURL, localizedDraftsSlug)
urlArray = new AdminUrlUtil(serverURL, arrayCollectionSlug)
arrayWithFallbackURL = new AdminUrlUtil(serverURL, arrayWithFallbackCollectionSlug)
noLocalizedFieldsURL = new AdminUrlUtil(serverURL, noLocalizedFieldsCollectionSlug)
context = await browser.newContext()
page = await context.newPage()
@@ -671,6 +674,13 @@ describe('Localization', () => {
await expect(page.locator('#field-title')).toBeEmpty()
})
})
test('should not show publish specific locale button when no localized fields exist', async () => {
await page.goto(urlPostsWithDrafts.create)
await expect(page.locator('#publish-locale')).toHaveCount(1)
await page.goto(noLocalizedFieldsURL.create)
await expect(page.locator('#publish-locale')).toHaveCount(0)
})
})
async function createLocalizedArrayItem(page: Page, url: AdminUrlUtil) {