@@ -3,10 +3,12 @@ import type { GeneratedTypes } from 'helpers/sdk/types.js'
3
3
4
4
import { expect , test } from '@playwright/test'
5
5
import { addArrayRow } from 'helpers/e2e/fields/array/index.js'
6
+ import { addBlock } from 'helpers/e2e/fields/blocks/addBlock.js'
6
7
import { navigateToDoc } from 'helpers/e2e/navigateToDoc.js'
7
8
import { openDocControls } from 'helpers/e2e/openDocControls.js'
8
9
import { upsertPreferences } from 'helpers/e2e/preferences.js'
9
10
import { openDocDrawer } from 'helpers/e2e/toggleDocDrawer.js'
11
+ import { waitForAutoSaveToRunAndComplete } from 'helpers/e2e/waitForAutoSaveToRunAndComplete.js'
10
12
import { RESTClient } from 'helpers/rest.js'
11
13
import path from 'path'
12
14
import { fileURLToPath } from 'url'
@@ -28,6 +30,7 @@ import { AdminUrlUtil } from '../helpers/adminUrlUtil.js'
28
30
import { initPayloadE2ENoConfig } from '../helpers/initPayloadE2ENoConfig.js'
29
31
import { POLL_TOPASS_TIMEOUT , TEST_TIMEOUT_LONG } from '../playwright.config.js'
30
32
import { arrayCollectionSlug } from './collections/Array/index.js'
33
+ import { blocksCollectionSlug } from './collections/Blocks/index.js'
31
34
import { nestedToArrayAndBlockCollectionSlug } from './collections/NestedToArrayAndBlock/index.js'
32
35
import { noLocalizedFieldsCollectionSlug } from './collections/NoLocalizedFields/index.js'
33
36
import { richTextSlug } from './collections/RichText/index.js'
@@ -63,6 +66,7 @@ let urlPostsWithDrafts: AdminUrlUtil
63
66
let urlArray : AdminUrlUtil
64
67
let arrayWithFallbackURL : AdminUrlUtil
65
68
let noLocalizedFieldsURL : AdminUrlUtil
69
+ let urlBlocks : AdminUrlUtil
66
70
67
71
const title = 'english title'
68
72
const spanishTitle = 'spanish title'
@@ -90,6 +94,7 @@ describe('Localization', () => {
90
94
urlArray = new AdminUrlUtil ( serverURL , arrayCollectionSlug )
91
95
arrayWithFallbackURL = new AdminUrlUtil ( serverURL , arrayWithFallbackCollectionSlug )
92
96
noLocalizedFieldsURL = new AdminUrlUtil ( serverURL , noLocalizedFieldsCollectionSlug )
97
+ urlBlocks = new AdminUrlUtil ( serverURL , blocksCollectionSlug )
93
98
94
99
context = await browser . newContext ( )
95
100
page = await context . newPage ( )
@@ -651,6 +656,41 @@ describe('Localization', () => {
651
656
} )
652
657
. toBeTruthy ( )
653
658
} )
659
+
660
+ test ( 'blocks - should show fallback checkbox for non-default locale' , async ( ) => {
661
+ await page . goto ( urlBlocks . create )
662
+ await addBlock ( { page, blockToSelect : 'Block Inside Block' , fieldName : 'content' } )
663
+ const rowTextInput = page . locator ( `#field-content__0__text` )
664
+ await rowTextInput . fill ( 'text' )
665
+ await saveDocAndAssert ( page )
666
+ await changeLocale ( page , 'pt' )
667
+ const fallbackCheckbox = page . locator ( '#field-content' , {
668
+ hasText : 'Fallback to default locale' ,
669
+ } )
670
+
671
+ await expect ( fallbackCheckbox ) . toBeVisible ( )
672
+ } )
673
+
674
+ test ( 'blocks - should successfully save with the fallback' , async ( ) => {
675
+ await page . goto ( urlBlocks . create )
676
+ await addBlock ( { page, blockToSelect : 'Block Inside Block' , fieldName : 'content' } )
677
+ const rowTextInput = page . locator ( `#field-content__0__text` )
678
+ await rowTextInput . fill ( 'text' )
679
+ await saveDocAndAssert ( page )
680
+ await changeLocale ( page , 'pt' )
681
+ await rowTextInput . fill ( 'changed' )
682
+ await waitForAutoSaveToRunAndComplete ( page )
683
+ await saveDocAndAssert ( page )
684
+ const docID = page . url ( ) . split ( '/' ) . pop ( ) ?. split ( '?' ) . shift ( )
685
+
686
+ const doc = await payload . find ( {
687
+ collection : 'blocks-fields' ,
688
+ where : { id : { equals : docID } } ,
689
+ locale : 'all' ,
690
+ } )
691
+ // eslint-disable-next-line payload/no-flaky-assertions
692
+ expect ( doc . docs ) . toHaveLength ( 1 )
693
+ } )
654
694
} )
655
695
656
696
test ( 'should use label in search filter when string or object' , async ( ) => {
0 commit comments