1
+ import { ApproxStructure , Assertions , UiFinder } from '@ephox/agar' ;
1
2
import { describe , it } from '@ephox/bedrock-client' ;
2
3
import { Css , Scroll } from '@ephox/sugar' ;
3
4
import { TinyAssertions , TinyDom , TinyHooks , TinySelections , TinyUiActions } from '@ephox/wrap-mcagar' ;
@@ -16,6 +17,8 @@ describe('browser.tinymce.plugins.searchreplace.SearchReplaceDialogTest', () =>
16
17
base_url : '/project/tinymce/js/tinymce' ,
17
18
} , [ Plugin ] ) ;
18
19
20
+ const findInputSelector = Utils . getFindInputSelector ( ) ;
21
+
19
22
const assertFound = ( editor : Editor , count : number ) => TinyAssertions . assertContentPresence ( editor , {
20
23
'.mce-match-marker' : count
21
24
} ) ;
@@ -29,7 +32,7 @@ describe('browser.tinymce.plugins.searchreplace.SearchReplaceDialogTest', () =>
29
32
const editor = hook . editor ( ) ;
30
33
editor . setContent ( '<p>fish fish fish</p>' ) ;
31
34
await Utils . pOpenDialog ( editor ) ;
32
- await Utils . pAssertFieldValue ( editor , 'input.tox-textfield[placeholder="Find"]' , '' ) ;
35
+ await Utils . pAssertFieldValue ( editor , findInputSelector , '' ) ;
33
36
TinyUiActions . closeDialog ( editor ) ;
34
37
} ) ;
35
38
@@ -38,7 +41,7 @@ describe('browser.tinymce.plugins.searchreplace.SearchReplaceDialogTest', () =>
38
41
editor . setContent ( '<p>fish fish fish</p>' ) ;
39
42
TinySelections . setSelection ( editor , [ 0 , 0 ] , 5 , [ 0 , 0 ] , 9 ) ;
40
43
await Utils . pOpenDialog ( editor ) ;
41
- await Utils . pAssertFieldValue ( editor , 'input.tox-textfield[placeholder="Find"]' , 'fish' ) ;
44
+ await Utils . pAssertFieldValue ( editor , findInputSelector , 'fish' ) ;
42
45
findAndAssertFound ( editor , 3 ) ;
43
46
TinyUiActions . closeDialog ( editor ) ;
44
47
} ) ;
@@ -48,7 +51,7 @@ describe('browser.tinymce.plugins.searchreplace.SearchReplaceDialogTest', () =>
48
51
editor . setContent ( '<p>fish Fish fish</p>' ) ;
49
52
TinySelections . setSelection ( editor , [ 0 , 0 ] , 5 , [ 0 , 0 ] , 9 ) ;
50
53
await Utils . pOpenDialog ( editor ) ;
51
- await Utils . pAssertFieldValue ( editor , 'input.tox-textfield[placeholder="Find"]' , 'Fish' ) ;
54
+ await Utils . pAssertFieldValue ( editor , findInputSelector , 'Fish' ) ;
52
55
await Utils . pSelectPreference ( editor , 'Match case' ) ;
53
56
findAndAssertFound ( editor , 1 ) ;
54
57
await Utils . pSelectPreference ( editor , 'Match case' ) ;
@@ -60,7 +63,7 @@ describe('browser.tinymce.plugins.searchreplace.SearchReplaceDialogTest', () =>
60
63
editor . setContent ( '<p>ttt TTT ttt ttttt</p>' ) ;
61
64
TinySelections . setSelection ( editor , [ 0 , 0 ] , 0 , [ 0 , 0 ] , 3 ) ;
62
65
await Utils . pOpenDialog ( editor ) ;
63
- await Utils . pAssertFieldValue ( editor , 'input.tox-textfield[placeholder="Find"]' , 'ttt' ) ;
66
+ await Utils . pAssertFieldValue ( editor , findInputSelector , 'ttt' ) ;
64
67
await Utils . pSelectPreference ( editor , 'Find whole words only' ) ;
65
68
findAndAssertFound ( editor , 3 ) ;
66
69
await Utils . pSelectPreference ( editor , 'Find whole words only' ) ;
@@ -72,8 +75,8 @@ describe('browser.tinymce.plugins.searchreplace.SearchReplaceDialogTest', () =>
72
75
editor . setContent ( '<p>ttt TTT ttt ttttt</p>' ) ;
73
76
TinySelections . setSelection ( editor , [ 0 , 0 ] , 0 , [ 0 , 0 ] , 7 ) ;
74
77
await Utils . pOpenDialog ( editor ) ;
75
- await Utils . pAssertFieldValue ( editor , 'input.tox-textfield[placeholder="Find"]' , 'ttt TTT' ) ;
76
- await Utils . pSetFieldValue ( editor , 'input.tox-textfield[placeholder="Find"]' , 'ttt' ) ;
78
+ await Utils . pAssertFieldValue ( editor , findInputSelector , 'ttt TTT' ) ;
79
+ await Utils . pSetFieldValue ( editor , findInputSelector , 'ttt' ) ;
77
80
await Utils . pSelectPreference ( editor , 'Find in selection' ) ;
78
81
findAndAssertFound ( editor , 2 ) ;
79
82
TinyAssertions . assertSelection ( editor , [ 0 ] , 0 , [ 0 ] , 4 ) ;
@@ -86,7 +89,7 @@ describe('browser.tinymce.plugins.searchreplace.SearchReplaceDialogTest', () =>
86
89
editor . setContent ( '<p>fish fish Fish fishy</p>' ) ;
87
90
TinySelections . setSelection ( editor , [ 0 , 0 ] , 5 , [ 0 , 0 ] , 9 ) ;
88
91
await Utils . pOpenDialog ( editor ) ;
89
- await Utils . pAssertFieldValue ( editor , 'input.tox-textfield[placeholder="Find"]' , 'fish' ) ;
92
+ await Utils . pAssertFieldValue ( editor , findInputSelector , 'fish' ) ;
90
93
findAndAssertFound ( editor , 4 ) ;
91
94
await Utils . pSelectPreference ( editor , 'Match case' ) ;
92
95
assertFound ( editor , 0 ) ;
@@ -101,7 +104,7 @@ describe('browser.tinymce.plugins.searchreplace.SearchReplaceDialogTest', () =>
101
104
const editor = hook . editor ( ) ;
102
105
editor . setContent ( '<p>fish fish fish</p>' ) ;
103
106
await Utils . pOpenDialogWithKeyboard ( editor ) ;
104
- await Utils . pAssertFieldValue ( editor , 'input.tox-textfield[placeholder="Find"]' , '' ) ;
107
+ await Utils . pAssertFieldValue ( editor , findInputSelector , '' ) ;
105
108
TinyUiActions . closeDialog ( editor ) ;
106
109
} ) ;
107
110
@@ -110,7 +113,7 @@ describe('browser.tinymce.plugins.searchreplace.SearchReplaceDialogTest', () =>
110
113
editor . setContent ( '<p>fish fish fish</p>' ) ;
111
114
TinySelections . setSelection ( editor , [ 0 , 0 ] , 5 , [ 0 , 0 ] , 9 ) ;
112
115
await Utils . pOpenDialogWithKeyboard ( editor ) ;
113
- await Utils . pAssertFieldValue ( editor , 'input.tox-textfield[placeholder="Find"]' , 'fish' ) ;
116
+ await Utils . pAssertFieldValue ( editor , findInputSelector , 'fish' ) ;
114
117
findAndAssertFound ( editor , 3 ) ;
115
118
TinyUiActions . closeDialog ( editor ) ;
116
119
} ) ;
@@ -130,7 +133,7 @@ describe('browser.tinymce.plugins.searchreplace.SearchReplaceDialogTest', () =>
130
133
const editor = hook . editor ( ) ;
131
134
editor . setContent ( '<p>tiny tiny tiny tiny</p>' ) ;
132
135
await Utils . pOpenDialog ( editor ) ;
133
- await Utils . pSetFieldValue ( editor , 'input.tox-textfield[placeholder="Find"]' , 'tiny' ) ;
136
+ await Utils . pSetFieldValue ( editor , findInputSelector , 'tiny' ) ;
134
137
findAndAssertFound ( editor , 4 ) ;
135
138
await Utils . pSelectPreference ( editor , 'Find in selection' ) ;
136
139
assertFound ( editor , 0 ) ;
@@ -141,4 +144,87 @@ describe('browser.tinymce.plugins.searchreplace.SearchReplaceDialogTest', () =>
141
144
assert . isFalse ( await Utils . pAssertAlertInDialog ( editor ) ) ;
142
145
TinyUiActions . closeDialog ( editor ) ;
143
146
} ) ;
147
+
148
+ it ( 'TINY-10871: Find label should point to the correct input through for attribute' , async ( ) => {
149
+ const editor = hook . editor ( ) ;
150
+ editor . setContent ( '' ) ;
151
+ const dialog = await Utils . pOpenDialog ( editor ) ;
152
+
153
+ Assertions . assertStructure ( 'Check dialog form content syructure' ,
154
+ ApproxStructure . build ( ( s , str , arr ) => s . element ( 'div' , {
155
+ classes : [ arr . has ( 'tox-form' ) ] ,
156
+ children : [
157
+ s . element ( 'div' , {
158
+ classes : [ arr . has ( 'tox-form__group' ) ] ,
159
+ children : [
160
+ s . element ( 'label' , {
161
+ attrs : {
162
+ for : str . startsWith ( 'form-field' )
163
+ } ,
164
+ children : [
165
+ s . text ( str . is ( 'Find' ) )
166
+ ]
167
+ } ) ,
168
+ s . element ( 'div' , {
169
+ classes : [ arr . has ( 'tox-bar' ) ] ,
170
+ children : [
171
+ s . element ( 'div' , {
172
+ classes : [ arr . has ( 'tox-form__group' ) ] ,
173
+ children : [
174
+ s . element ( 'input' , {
175
+ attrs : {
176
+ id : str . startsWith ( 'form-field' )
177
+ }
178
+ } )
179
+ ]
180
+ } ) ,
181
+ s . element ( 'div' , {
182
+ classes : [ arr . has ( 'tox-form__group' ) ] ,
183
+ children : [
184
+ s . element ( 'button' , {
185
+ attrs : {
186
+ 'aria-label' : str . is ( 'Previous' )
187
+ }
188
+ } )
189
+ ]
190
+ } ) ,
191
+ s . element ( 'div' , {
192
+ classes : [ arr . has ( 'tox-form__group' ) ] ,
193
+ children : [
194
+ s . element ( 'button' , {
195
+ attrs : {
196
+ 'aria-label' : str . is ( 'Next' )
197
+ }
198
+ } )
199
+ ]
200
+ } )
201
+ ]
202
+ } )
203
+ ]
204
+ } ) ,
205
+ s . element ( 'div' , {
206
+ classes : [ arr . has ( 'tox-form__group' ) ] ,
207
+ children : [
208
+ s . element ( 'label' , {
209
+ attrs : {
210
+ for : str . startsWith ( 'form-field' )
211
+ } ,
212
+ children : [
213
+ s . text ( str . is ( 'Replace with' ) )
214
+ ]
215
+ } ) ,
216
+ s . element ( 'input' , {
217
+ attrs : {
218
+ id : str . startsWith ( 'form-field' )
219
+ }
220
+ } )
221
+ ]
222
+ } )
223
+ ]
224
+ } ) ) ,
225
+ UiFinder . findIn ( dialog , '.tox-dialog__body-content .tox-form' ) . getOrDie ( )
226
+ ) ;
227
+
228
+ TinyUiActions . closeDialog ( editor ) ;
229
+ } ) ;
144
230
} ) ;
0 commit comments