11import { createTestPage , pasteContent } from '../../../support/paste-utils' ;
2- import { EditorSelectors } from '../../../support/selectors' ;
2+ import { EditorSelectors , waitForReactUpdate } from '../../../support/selectors' ;
33import { testLog } from '../../../support/test-helpers' ;
44
5- describe ( 'Paste Formatting Tests' , ( ) => {
6- it ( 'should paste all formatted content correctly' , ( ) => {
5+ describe ( 'Paste Formatting Tests' , { testIsolation : false } , ( ) => {
6+ before ( ( ) => {
77 createTestPage ( ) ;
8+ } ) ;
89
9- // --- HTML Inline Formatting ---
10+ beforeEach ( ( ) => {
11+ // Clear editor content before each test to ensure a clean state
12+ EditorSelectors . slateEditor ( ) . click ( ) . type ( '{selectall}{backspace}' ) ;
13+ waitForReactUpdate ( 500 ) ;
14+ } ) ;
1015
16+ it ( 'should paste HTML inline formatting (Bold, Italic, Underline, Strikethrough)' , ( ) => {
1117 testLog . info ( '=== Pasting HTML Bold Text ===' ) ;
1218 pasteContent ( '<p>This is <strong>bold</strong> text</p>' , 'This is bold text' ) ;
1319 cy . wait ( 500 ) ;
1420 EditorSelectors . slateEditor ( ) . find ( 'strong' ) . should ( 'contain' , 'bold' ) ;
1521 testLog . info ( '✓ HTML bold text pasted successfully' ) ;
1622
23+ EditorSelectors . slateEditor ( ) . click ( ) . type ( '{selectall}{backspace}' ) ;
24+ waitForReactUpdate ( 200 ) ;
25+
1726 testLog . info ( '=== Pasting HTML Italic Text ===' ) ;
1827 pasteContent ( '<p>This is <em>italic</em> text</p>' , 'This is italic text' ) ;
1928 cy . wait ( 500 ) ;
2029 EditorSelectors . slateEditor ( ) . find ( 'em' ) . should ( 'contain' , 'italic' ) ;
2130 testLog . info ( '✓ HTML italic text pasted successfully' ) ;
2231
32+ EditorSelectors . slateEditor ( ) . click ( ) . type ( '{selectall}{backspace}' ) ;
33+ waitForReactUpdate ( 200 ) ;
34+
2335 testLog . info ( '=== Pasting HTML Underlined Text ===' ) ;
2436 pasteContent ( '<p>This is <u>underlined</u> text</p>' , 'This is underlined text' ) ;
2537 cy . wait ( 500 ) ;
2638 EditorSelectors . slateEditor ( ) . find ( 'u' ) . should ( 'contain' , 'underlined' ) ;
2739 testLog . info ( '✓ HTML underlined text pasted successfully' ) ;
2840
41+ EditorSelectors . slateEditor ( ) . click ( ) . type ( '{selectall}{backspace}' ) ;
42+ waitForReactUpdate ( 200 ) ;
43+
2944 testLog . info ( '=== Pasting HTML Strikethrough Text ===' ) ;
3045 pasteContent ( '<p>This is <s>strikethrough</s> text</p>' , 'This is strikethrough text' ) ;
3146 cy . wait ( 500 ) ;
3247 EditorSelectors . slateEditor ( ) . find ( 's' ) . should ( 'contain' , 'strikethrough' ) ;
3348 testLog . info ( '✓ HTML strikethrough text pasted successfully' ) ;
49+ } ) ;
3450
51+ it ( 'should paste HTML special formatting (Code, Link, Mixed, Nested)' , ( ) => {
3552 testLog . info ( '=== Pasting HTML Inline Code ===' ) ;
3653 pasteContent ( '<p>Use the <code>console.log()</code> function</p>' , 'Use the console.log() function' ) ;
3754 cy . wait ( 500 ) ;
38- // Code is rendered as a span with specific classes in AppFlowy
3955 EditorSelectors . slateEditor ( ) . find ( 'span.bg-border-primary' ) . should ( 'contain' , 'console.log()' ) ;
4056 testLog . info ( '✓ HTML inline code pasted successfully' ) ;
4157
58+ EditorSelectors . slateEditor ( ) . click ( ) . type ( '{selectall}{backspace}' ) ;
59+ waitForReactUpdate ( 200 ) ;
60+
4261 testLog . info ( '=== Pasting HTML Mixed Formatting ===' ) ;
4362 pasteContent ( '<p>Text with <strong>bold</strong>, <em>italic</em>, and <u>underline</u></p>' , 'Text with bold, italic, and underline' ) ;
4463 cy . wait ( 500 ) ;
@@ -47,69 +66,93 @@ describe('Paste Formatting Tests', () => {
4766 EditorSelectors . slateEditor ( ) . find ( 'u' ) . should ( 'contain' , 'underline' ) ;
4867 testLog . info ( '✓ HTML mixed formatting pasted successfully' ) ;
4968
69+ EditorSelectors . slateEditor ( ) . click ( ) . type ( '{selectall}{backspace}' ) ;
70+ waitForReactUpdate ( 200 ) ;
71+
5072 testLog . info ( '=== Pasting HTML Link ===' ) ;
5173 pasteContent ( '<p>Visit <a href="https://appflowy.io">AppFlowy</a> website</p>' , 'Visit AppFlowy website' ) ;
5274 cy . wait ( 500 ) ;
53- // Links are rendered as spans with cursor-pointer and underline classes in AppFlowy
5475 EditorSelectors . slateEditor ( ) . find ( 'span.cursor-pointer.underline' ) . should ( 'contain' , 'AppFlowy' ) ;
5576 testLog . info ( '✓ HTML link pasted successfully' ) ;
5677
78+ EditorSelectors . slateEditor ( ) . click ( ) . type ( '{selectall}{backspace}' ) ;
79+ waitForReactUpdate ( 200 ) ;
80+
5781 testLog . info ( '=== Pasting HTML Nested Formatting ===' ) ;
5882 pasteContent ( '<p>Text with <strong>bold and <em>italic</em> nested</strong></p>' , 'Text with bold and italic nested' ) ;
5983 cy . wait ( 500 ) ;
6084 EditorSelectors . slateEditor ( ) . find ( 'strong' ) . should ( 'contain' , 'bold and' ) ;
6185 EditorSelectors . slateEditor ( ) . find ( 'strong' ) . find ( 'em' ) . should ( 'contain' , 'italic' ) ;
6286 testLog . info ( '✓ HTML nested formatting pasted successfully' ) ;
6387
88+ EditorSelectors . slateEditor ( ) . click ( ) . type ( '{selectall}{backspace}' ) ;
89+ waitForReactUpdate ( 200 ) ;
90+
6491 testLog . info ( '=== Pasting HTML Complex Nested Formatting ===' ) ;
6592 pasteContent ( '<p><strong><em><u>Bold, italic, and underlined</u></em></strong> text</p>' , 'Bold, italic, and underlined text' ) ;
6693 cy . wait ( 500 ) ;
67- // Check strict nesting: strong > em > u
6894 EditorSelectors . slateEditor ( )
6995 . find ( 'strong' )
7096 . find ( 'em' )
7197 . find ( 'u' )
7298 . should ( 'contain' , 'Bold, italic, and underlined' ) ;
7399 testLog . info ( '✓ HTML complex nested formatting pasted successfully' ) ;
100+ } ) ;
74101
75- // --- Markdown Inline Formatting ---
76-
102+ it ( 'should paste Markdown inline formatting (Bold, Italic, Strikethrough, Code)' , ( ) => {
77103 testLog . info ( '=== Pasting Markdown Bold Text (asterisk) ===' ) ;
78104 pasteContent ( '' , 'This is **bold** text' ) ;
79105 cy . wait ( 500 ) ;
80106 EditorSelectors . slateEditor ( ) . find ( 'strong' ) . should ( 'contain' , 'bold' ) ;
81107 testLog . info ( '✓ Markdown bold text (asterisk) pasted successfully' ) ;
82108
109+ EditorSelectors . slateEditor ( ) . click ( ) . type ( '{selectall}{backspace}' ) ;
110+ waitForReactUpdate ( 200 ) ;
111+
83112 testLog . info ( '=== Pasting Markdown Bold Text (underscore) ===' ) ;
84113 pasteContent ( '' , 'This is __bold__ text' ) ;
85114 cy . wait ( 500 ) ;
86115 EditorSelectors . slateEditor ( ) . find ( 'strong' ) . should ( 'contain' , 'bold' ) ;
87116 testLog . info ( '✓ Markdown bold text (underscore) pasted successfully' ) ;
88117
118+ EditorSelectors . slateEditor ( ) . click ( ) . type ( '{selectall}{backspace}' ) ;
119+ waitForReactUpdate ( 200 ) ;
120+
89121 testLog . info ( '=== Pasting Markdown Italic Text (asterisk) ===' ) ;
90122 pasteContent ( '' , 'This is *italic* text' ) ;
91123 cy . wait ( 500 ) ;
92124 EditorSelectors . slateEditor ( ) . find ( 'em' ) . should ( 'contain' , 'italic' ) ;
93125 testLog . info ( '✓ Markdown italic text (asterisk) pasted successfully' ) ;
94126
127+ EditorSelectors . slateEditor ( ) . click ( ) . type ( '{selectall}{backspace}' ) ;
128+ waitForReactUpdate ( 200 ) ;
129+
95130 testLog . info ( '=== Pasting Markdown Italic Text (underscore) ===' ) ;
96131 pasteContent ( '' , 'This is _italic_ text' ) ;
97132 cy . wait ( 500 ) ;
98133 EditorSelectors . slateEditor ( ) . find ( 'em' ) . should ( 'contain' , 'italic' ) ;
99134 testLog . info ( '✓ Markdown italic text (underscore) pasted successfully' ) ;
100135
136+ EditorSelectors . slateEditor ( ) . click ( ) . type ( '{selectall}{backspace}' ) ;
137+ waitForReactUpdate ( 200 ) ;
138+
101139 testLog . info ( '=== Pasting Markdown Strikethrough Text ===' ) ;
102140 pasteContent ( '' , 'This is ~~strikethrough~~ text' ) ;
103141 cy . wait ( 500 ) ;
104142 EditorSelectors . slateEditor ( ) . find ( 's' ) . should ( 'contain' , 'strikethrough' ) ;
105143 testLog . info ( '✓ Markdown strikethrough text pasted successfully' ) ;
106144
145+ EditorSelectors . slateEditor ( ) . click ( ) . type ( '{selectall}{backspace}' ) ;
146+ waitForReactUpdate ( 200 ) ;
147+
107148 testLog . info ( '=== Pasting Markdown Inline Code ===' ) ;
108149 pasteContent ( '' , 'Use the `console.log()` function' ) ;
109150 cy . wait ( 500 ) ;
110151 EditorSelectors . slateEditor ( ) . find ( 'span.bg-border-primary' ) . should ( 'contain' , 'console.log()' ) ;
111152 testLog . info ( '✓ Markdown inline code pasted successfully' ) ;
153+ } ) ;
112154
155+ it ( 'should paste Markdown complex/mixed formatting (Mixed, Link, Nested)' , ( ) => {
113156 testLog . info ( '=== Pasting Markdown Mixed Formatting ===' ) ;
114157 pasteContent ( '' , 'Text with **bold**, *italic*, ~~strikethrough~~, and `code`' ) ;
115158 cy . wait ( 500 ) ;
@@ -119,32 +162,47 @@ describe('Paste Formatting Tests', () => {
119162 EditorSelectors . slateEditor ( ) . find ( 'span.bg-border-primary' ) . should ( 'contain' , 'code' ) ;
120163 testLog . info ( '✓ Markdown mixed formatting pasted successfully' ) ;
121164
165+ EditorSelectors . slateEditor ( ) . click ( ) . type ( '{selectall}{backspace}' ) ;
166+ waitForReactUpdate ( 200 ) ;
167+
122168 testLog . info ( '=== Pasting Markdown Link ===' ) ;
123169 pasteContent ( '' , 'Visit [AppFlowy](https://appflowy.io) website' ) ;
124170 cy . wait ( 500 ) ;
125171 EditorSelectors . slateEditor ( ) . find ( 'span.cursor-pointer.underline' ) . should ( 'contain' , 'AppFlowy' ) ;
126172 testLog . info ( '✓ Markdown link pasted successfully' ) ;
127173
174+ EditorSelectors . slateEditor ( ) . click ( ) . type ( '{selectall}{backspace}' ) ;
175+ waitForReactUpdate ( 200 ) ;
176+
128177 testLog . info ( '=== Pasting Markdown Nested Formatting ===' ) ;
129178 pasteContent ( '' , 'Text with **bold and *italic* nested**' ) ;
130179 cy . wait ( 500 ) ;
131180 EditorSelectors . slateEditor ( ) . find ( 'strong' ) . should ( 'contain' , 'bold and' ) ;
132181 EditorSelectors . slateEditor ( ) . find ( 'strong' ) . find ( 'em' ) . should ( 'contain' , 'italic' ) ;
133182 testLog . info ( '✓ Markdown nested formatting pasted successfully' ) ;
134183
184+ EditorSelectors . slateEditor ( ) . click ( ) . type ( '{selectall}{backspace}' ) ;
185+ waitForReactUpdate ( 200 ) ;
186+
135187 testLog . info ( '=== Pasting Markdown Complex Nested Formatting ===' ) ;
136188 pasteContent ( '' , '***Bold and italic*** text' ) ;
137189 cy . wait ( 500 ) ;
138190 // In Markdown, ***text*** is usually bold AND italic.
139191 EditorSelectors . slateEditor ( ) . find ( 'strong' ) . find ( 'em' ) . should ( 'contain' , 'Bold and italic' ) ;
140192 testLog . info ( '✓ Markdown complex nested formatting pasted successfully' ) ;
141193
194+ EditorSelectors . slateEditor ( ) . click ( ) . type ( '{selectall}{backspace}' ) ;
195+ waitForReactUpdate ( 200 ) ;
196+
142197 testLog . info ( '=== Pasting Markdown Link with Formatting ===' ) ;
143198 pasteContent ( '' , 'Visit [**AppFlowy** website](https://appflowy.io) for more' ) ;
144199 cy . wait ( 500 ) ;
145200 EditorSelectors . slateEditor ( ) . find ( 'span.cursor-pointer.underline' ) . find ( 'strong' ) . should ( 'contain' , 'AppFlowy' ) ;
146201 testLog . info ( '✓ Markdown link with formatting pasted successfully' ) ;
147202
203+ EditorSelectors . slateEditor ( ) . click ( ) . type ( '{selectall}{backspace}' ) ;
204+ waitForReactUpdate ( 200 ) ;
205+
148206 testLog . info ( '=== Pasting Markdown Multiple Inline Code ===' ) ;
149207 pasteContent ( '' , 'Compare `const` vs `let` vs `var` in JavaScript' ) ;
150208 cy . wait ( 500 ) ;
@@ -154,4 +212,4 @@ describe('Paste Formatting Tests', () => {
154212 EditorSelectors . slateEditor ( ) . find ( 'span.bg-border-primary' ) . should ( 'contain' , 'var' ) ;
155213 testLog . info ( '✓ Markdown multiple inline code pasted successfully' ) ;
156214 } ) ;
157- } ) ;
215+ } ) ;
0 commit comments