[BUGFIX] Acceptance tests fails due to viewport changes
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Acceptance / Backend / Formhandler / ElementsBasicCest.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\Formhandler;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Core\Tests\Acceptance\Step\Backend\Admin;
18 use TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\Formhandler;
19 use TYPO3\CMS\Core\Tests\Acceptance\Support\Page\PageTree;
20
21 /**
22 * Tests for basic element fields
23 */
24 class ElementsBasicCest
25 {
26 /**
27 * Selector of the record container in the listview
28 * @var string
29 */
30 protected static $listViewRecordSelector = '#recordlist-tx_styleguide_elements_basic';
31
32 public function _before(Admin $I, PageTree $pageTree)
33 {
34 $I->useExistingSession();
35 // Ensure main content frame is fully loaded, otherwise there are load-race-conditions
36 $I->switchToIFrame('contentIframe');
37 $I->waitForText('Web Content Management System');
38 $I->switchToIFrame();
39
40 $I->click('List');
41 $pageTree->openPath(['styleguide TCA demo', 'elements basic']);
42 $I->switchToIFrame('contentIframe');
43 }
44
45 /**
46 * @param Admin $I
47 * @param Formhandler $formhandler
48 */
49 public function checkThatBrowserSideValidationsWorkAndSaveRecord(Admin $I, Formhandler $formhandler)
50 {
51 $editRecordLinkCssPath = self::$listViewRecordSelector . ' a[data-original-title="Edit record"]';
52 $I->waitForElement($editRecordLinkCssPath, 30);
53 $I->click($editRecordLinkCssPath);
54 $I->waitForText('Edit Form', 3, 'h1');
55
56 $fieldTests = [
57 'input_1' => [
58 'tests' => [
59 [
60 'This is a demo text with 2 numbers #!',
61 'This is a demo text with 2 numbers #!',
62 ],
63 ],
64 'cleared' => [
65 ''
66 ]
67 ],
68 'input_2, size=10' => [
69 'tests' => [
70 [
71 'This is a demo text with 2 numbers #!',
72 'This is a demo text with 2 numbers #!',
73 ],
74 ],
75 'cleared' => [
76 ''
77 ]
78 ],
79 'input_3 max=4' => [
80 'tests' => [
81 [
82 'Kasper',
83 'Kasp',
84 ],
85 ],
86 'cleared' => [
87 ''
88 ]
89 ],
90 'input_4 eval=alpha' => [
91 'tests' => [
92 [
93 'Kasper = TYPO3',
94 'KasperTYPO',
95 ],
96 [
97 'Non-latin characters: ŠĐŽĆČ',
98 'Nonlatincharacters',
99 ],
100 ],
101 'cleared' => [
102 ''
103 ]
104 ],
105 'input_5 eval=alphanum' => [
106 'tests' => [
107 [
108 'Kasper = TYPO3',
109 'KasperTYPO3',
110 ],
111 ],
112 'cleared' => [
113 ''
114 ]
115 ],
116 'input_6 eval=date' => [
117 'tests' => [
118 [
119 '29-01-2016',
120 '29-01-2016',
121 '1454025600',
122 ],
123 [
124 '13-13-2016',
125 '13-01-2017',
126 '1484265600',
127 ],
128 [
129 '29-02-2016',
130 '29-02-2016',
131 '1456704000',
132 false,
133 'Check valid leap year input'
134 ],
135 [
136 '29-02-2015',
137 '01-03-2015',
138 '1425168000',
139 false,
140 'Check invalid leap year transformation'
141 ],
142 ],
143 'cleared' => [
144 '0'
145 ]
146 ],
147 'input_36 dbType=date eval=date' => [
148 'tests' => [
149 [
150 '29-01-2016',
151 '29-01-2016',
152 '1454025600',
153 ],
154 [
155 '13-13-2016',
156 '13-01-2017',
157 '1484265600',
158 ],
159 [
160 '29-02-2016',
161 '29-02-2016',
162 '1456704000',
163 false,
164 'Check valid leap year input'
165 ],
166 [
167 '29-02-2015',
168 '01-03-2015',
169 '1425168000',
170 false,
171 'Check invalid leap year transformation'
172 ],
173 ],
174 'cleared' => [
175 '0'
176 ]
177 ],
178 'input_7 eval=datetime' => [
179 'tests' => [
180 [
181 '05:23 29-01-2016',
182 '05:23 29-01-2016',
183 '1454044980',
184 ],
185 [
186 '05:23 13-13-2016',
187 '05:23 13-01-2017',
188 '1484284980',
189 ],
190 [
191 '05:23 29-02-2016',
192 '05:23 29-02-2016',
193 '1456723380',
194 false,
195 'Check valid leap year input'
196 ],
197 [
198 '05:23 29-02-2015',
199 '05:23 01-03-2015',
200 '1425187380',
201 false,
202 'Check invalid leap year transformation'
203 ],
204 ],
205 'cleared' => [
206 '0'
207 ]
208 ],
209 'input_37 dbType=datetime eval=datetime' => [
210 'tests' => [
211 [
212 '05:23 29-01-2016',
213 '05:23 29-01-2016',
214 '1454044980',
215 ],
216 [
217 '05:23 13-13-2016',
218 '05:23 13-01-2017',
219 '1484284980',
220 ],
221 [
222 '05:23 29-02-2016',
223 '05:23 29-02-2016',
224 '1456723380',
225 false,
226 'Check valid leap year input'
227 ],
228 [
229 '05:23 29-02-2015',
230 '05:23 01-03-2015',
231 '1425187380',
232 false,
233 'Check invalid leap year transformation'
234 ],
235 ],
236 'cleared' => [
237 '0'
238 ]
239 ],
240 'input_8 eval=double2' => [
241 'tests' => [
242 [
243 '12.335',
244 '12.34',
245 '12.34',
246 ],
247 [
248 '12,335',
249 '12.34',
250 '12.34',
251 ],
252 [
253 '1.1',
254 '1.10',
255 '1.10',
256 ],
257 [
258 'TYPO3',
259 '3.00',
260 '3.00',
261 ],
262 [
263 '3TYPO',
264 '3.00',
265 '3.00',
266 ],
267 ],
268 // @todo: add support for null values to the core
269 'cleared' => [
270 '0.00',
271 '0.00',
272 ]
273 ],
274 'input_9 eval=int' => [
275 'tests' => [
276 [
277 '12.335',
278 '12',
279 '12',
280 ],
281 [
282 '12,9',
283 '12',
284 '12',
285 ],
286 [
287 'TYPO3',
288 '0',
289 '0',
290 ],
291 [
292 '3TYPO',
293 '3',
294 '3',
295 ],
296 ],
297 // @todo: add support for null values to the core
298 'cleared' => [
299 '0',
300 '0',
301 ]
302 ],
303 'input_10 eval=is_in, is_in=abc123' => [
304 'tests' => [
305 [
306 'abcd1234',
307 'abc123',
308 ],
309 [
310 'Kasper TYPO3',
311 'a3',
312 ],
313 ],
314 'cleared' => [
315 '',
316 ]
317 ],
318 'input_11 eval=lower' => [
319 'tests' => [
320 [
321 'Kasper TYPO3!',
322 'kasper typo3!',
323 ],
324 ],
325 'cleared' => [
326 '',
327 ]
328 ],
329 'input_12 eval=md5' => [
330 'tests' => [
331 [
332 'Kasper TYPO3!',
333 '748469dd64911af8df8f9a3dcb2c9378',
334 '748469dd64911af8df8f9a3dcb2c9378',
335 ],
336 [
337 ' Kasper TYPO3! ',
338 '792a085606250c47d6ebb8c98804d5b0',
339 '792a085606250c47d6ebb8c98804d5b0',
340 false,
341 'Check that whitespaces are not trimmed.'
342 ],
343 ],
344 'cleared' => [
345 // @todo: add support for null values to the core
346 // cleared value currently keeps the previous value on save
347 '792a085606250c47d6ebb8c98804d5b0',
348 '792a085606250c47d6ebb8c98804d5b0'
349 ]
350
351 ],
352 'input_13 eval=nospace' => [
353 'tests' => [
354 [
355 ' Kasper TYPO3! ',
356 'KasperTYPO3!',
357 ],
358 ],
359 'cleared' => [
360 '',
361 ]
362 ],
363 // @todo define test
364 //'input_14 eval=null' => [
365 //],
366 'input_15 eval=num' => [
367 'tests' => [
368 [
369 '12.335',
370 '12335',
371 ],
372 [
373 '12,9',
374 '129',
375 ],
376 [
377 'TYPO3',
378 '3',
379 ],
380 [
381 '3TYPO',
382 '3',
383 ],
384 ],
385 'cleared' => [
386 '',
387 ]
388 ],
389 'input_16 eval=password' => [
390 'tests' => [
391 [
392 'Kasper',
393 '********',
394 'Kasper',
395 ],
396 ],
397 'cleared' => [
398 '',
399 ]
400 ],
401 'input_17 eval=time' => [
402 'tests' => [
403 [
404 '13:30',
405 '13:30',
406 '48600',
407 ],
408 [
409 '123',
410 '12:03',
411 '43380',
412 ],
413 [
414 '12345',
415 '12:34',
416 '45240',
417 ],
418 [
419 '12:04+5',
420 '12:09',
421 '43740',
422 ],
423 [
424 '12:09-3',
425 '12:06',
426 '43560',
427 ]
428 ],
429 'cleared' => [
430 '0',
431 '00:00',
432 ]
433 ],
434 'input_18 eval=timesec' => [
435 'tests' => [
436 [
437 '13:30:00',
438 '13:30:00',
439 '48600',
440 ],
441 [
442 '12345',
443 '12:34:05',
444 '45245',
445 ],
446 [
447 // @todo is that the expected behavior?
448 '12:04:04+5',
449 '12:09:04',
450 '43744',
451 ],
452 ],
453 'cleared' => [
454 '0',
455 '00:00:00',
456 ]
457 ],
458 'input_19 eval=trim' => [
459 'tests' => [
460 [
461 ' Kasper ',
462 'Kasper',
463 ],
464 [
465 ' Kasper TYPO3 ',
466 'Kasper TYPO3',
467 ],
468 ],
469 'cleared' => [
470 '',
471 ]
472 ],
473 // @todo Check why this test is currently broken
474 //'input_20 eval with user function' => [
475 // [
476 // 'Kasper',
477 // 'KasperJSfoo',
478 // ]
479 //],
480 'input_23 eval=upper' => [
481 'tests' => [
482 [
483 'Kasper TYPO3!',
484 'KASPER TYPO3!',
485 ],
486 ],
487 'cleared' => [
488 '',
489 ]
490 ],
491 'input_24 eval=year' => [
492 'tests' => [
493
494 [
495 '2016',
496 '2016',
497 '2016',
498 ],
499 [
500 '12',
501 '2012',
502 '2012',
503 ],
504 [
505 'Kasper',
506 date('Y'),
507 date('Y'),
508 false,
509 'Invalid character is converted to current year'
510 ],
511 ],
512 'cleared' => [
513 '0',
514 '0',
515 ]
516 ],
517 'input_25 eval=int, default=0, range lower=-2, range upper=2' => [
518 'tests' => [
519 [
520 'Kasper TYPO3',
521 '0',
522 '0',
523 ],
524 [
525 '2',
526 '2',
527 '2'
528 ],
529 [
530 '-1',
531 '-1',
532 '-1',
533 ],
534 [
535 '-3',
536 '-3',
537 '-3',
538 true,
539 'Expecting a modal with error on trying to save.'
540 ],
541 [
542 '3',
543 '-3',
544 '-3',
545 true,
546 'Expecting a modal with error on trying to save.'
547 ],
548 ],
549 'cleared' => [
550 '0',
551 '0'
552 ]
553 ],
554 ];
555
556 foreach ($fieldTests as $fieldLabel => $testData) {
557 $formhandler->fillSeeSaveAndClearInputField(
558 $fieldLabel,
559 $testData
560 );
561 }
562 }
563 }