* chore: ensures relationship fields react to locale changes in the admin panel - fixes #1870

* chore: patches in default values for fields, and localized fields using fallbacks - fixes #1859

* chore: organizes field localization and sanitizing

* Revert "Feat/1180 loading UI enhancements"

* Feat/1180 loading UI enhancements

* chore: safely sets tab if name field, only sets fallback value if it exists

* chore: adds test to ensure text fields use fallback locale value when empty
This commit is contained in:
Jarrod Flesch
2023-01-19 16:55:03 -05:00
committed by GitHub
parent 5d71d4bf6e
commit c0ac155a71
3 changed files with 68 additions and 15 deletions

View File

@@ -98,6 +98,28 @@ describe('Localization', () => {
expect(localized.title.es).toEqual(spanishTitle);
});
it('should fallback to english translation when empty', async () => {
const updated = await payload.update<LocalizedPost>({
collection,
id: post1.id,
locale: spanishLocale,
data: {
title: '',
},
});
expect(updated.title).toEqual(englishTitle);
const localizedFallback = await payload.findByID<LocalizedPostAllLocale>({
collection,
id: post1.id,
locale: 'all',
});
expect(localizedFallback.title.en).toEqual(englishTitle);
expect(localizedFallback.title.es).toEqual('');
});
describe('querying', () => {
let localizedPost: LocalizedPost;
beforeEach(async () => {