@@ -1068,6 +1068,73 @@ describe('lexicalMain', () => {
1068
1068
await expect ( page . locator ( '#blocks-row-1 .section-title__input' ) ) . toHaveValue ( '1' ) // block name
1069
1069
} )
1070
1070
1071
+ test ( 'ensure blocks can be created from plus button' , async ( ) => {
1072
+ await navigateToLexicalFields ( )
1073
+ const richTextField = page . locator ( '.rich-text-lexical' ) . first ( )
1074
+ await richTextField . scrollIntoViewIfNeeded ( )
1075
+ await expect ( richTextField ) . toBeVisible ( )
1076
+ // Wait until there at least 10 blocks visible in that richtext field - thus wait for it to be fully loaded
1077
+ await expect ( page . locator ( '.rich-text-lexical' ) . nth ( 2 ) . locator ( '.lexical-block' ) ) . toHaveCount (
1078
+ 10 ,
1079
+ )
1080
+ await expect ( page . locator ( '.shimmer-effect' ) ) . toHaveCount ( 0 )
1081
+
1082
+ // click contenteditable
1083
+ await richTextField . locator ( '.ContentEditable__root' ) . first ( ) . click ( )
1084
+
1085
+ const lastParagraph = richTextField . locator ( 'p' ) . first ( )
1086
+ await lastParagraph . scrollIntoViewIfNeeded ( )
1087
+ await expect ( lastParagraph ) . toBeVisible ( )
1088
+
1089
+ /**
1090
+ * Create new upload node
1091
+ */
1092
+ // type / to open the slash menu
1093
+ await lastParagraph . click ( )
1094
+ // hover over the last paragraph to make the plus button visible
1095
+ await lastParagraph . hover ( )
1096
+ await wait ( 600 )
1097
+ //await richTextField.locator('.add-block-menu').first().click()
1098
+ const plusButton = richTextField . locator ( '.add-block-menu' ) . first ( )
1099
+
1100
+ // hover over plusButton
1101
+ await plusButton . hover ( )
1102
+ await wait ( 100 )
1103
+ // click the plus button
1104
+ await plusButton . click ( )
1105
+
1106
+ await expect ( richTextField . locator ( '.slash-menu-popup' ) ) . toBeVisible ( )
1107
+ // click button with text "Text"
1108
+ await richTextField . locator ( '.slash-menu-popup button' ) . getByText ( 'My Block' ) . click ( )
1109
+
1110
+ await expect ( richTextField . locator ( '.lexical-block' ) ) . toHaveCount ( 1 )
1111
+ await richTextField . locator ( '#field-someTextRequired' ) . first ( ) . fill ( 'test' )
1112
+
1113
+ await saveDocAndAssert ( page )
1114
+
1115
+ await expect ( async ( ) => {
1116
+ const lexicalDoc : LexicalField = (
1117
+ await payload . find ( {
1118
+ collection : lexicalFieldsSlug ,
1119
+ depth : 0 ,
1120
+ overrideAccess : true ,
1121
+ where : {
1122
+ title : {
1123
+ equals : lexicalDocData . title ,
1124
+ } ,
1125
+ } ,
1126
+ } )
1127
+ ) . docs [ 0 ] as never
1128
+
1129
+ const lexicalField : SerializedEditorState = lexicalDoc . lexicalRootEditor
1130
+
1131
+ // @ts -expect-error no need to type this
1132
+ await expect ( lexicalField ?. root ?. children [ 1 ] . fields . someTextRequired ) . toEqual ( 'test' )
1133
+ } ) . toPass ( {
1134
+ timeout : POLL_TOPASS_TIMEOUT ,
1135
+ } )
1136
+ } )
1137
+
1071
1138
describe ( 'localization' , ( ) => {
1072
1139
test . skip ( 'ensure simple localized lexical field works' , async ( ) => {
1073
1140
await navigateToLexicalFields ( true , true )
0 commit comments