[TASK] Stabilize acceptance tests
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Acceptance / Backend / Redirect / RedirectModuleCest.php
1 <?php
2 declare(strict_types = 1);
3
4 namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\Redirect;
5
6 /*
7 * This file is part of the TYPO3 CMS project.
8 *
9 * It is free software; you can redistribute it and/or modify it under
10 * the terms of the GNU General Public License, either version 2
11 * of the License, or any later version.
12 *
13 * For the full copyright and license information, please read the
14 * LICENSE.txt file that was distributed with this source code.
15 *
16 * The TYPO3 project - inspiring people to share!
17 */
18
19 use TYPO3\TestingFramework\Core\Acceptance\Step\Backend\Admin;
20
21 /**
22 * Tests concerning Redirects Module
23 */
24 class RedirectModuleCest
25 {
26
27 /**
28 * @param Admin $I
29 */
30 public function _before(Admin $I)
31 {
32 $I->useExistingSession();
33
34 $I->click('Redirects');
35 $I->switchToContentFrame();
36 $I->canSee('Redirect Management', 'h1');
37 }
38
39 /**
40 * @param Admin $I
41 */
42 public function createNewRecordIfNoneExist(Admin $I)
43 {
44 $I->amGoingTo('create a new redirects record while none are in the system, yet');
45 $I->canSee('No redirects found!');
46 $I->click('Create new redirect');
47 $I->waitForElementNotVisible('#t3js-ui-block');
48 $I->canSee('Create new Redirect on root level');
49
50 $I->fillField('//input[contains(@data-formengine-input-name, "data[sys_redirect]") and contains(@data-formengine-input-name, "[source_path]")]', '/my-path/');
51 $I->fillField('//input[contains(@data-formengine-input-name, "data[sys_redirect]") and contains(@data-formengine-input-name, "[target]")]', 1);
52
53 $saveButtonLink = '//*/button[@name="_savedok"][1]';
54 $I->waitForElement($saveButtonLink, 30);
55 $I->click($saveButtonLink);
56 $I->waitForElementNotVisible('#t3js-ui-block');
57
58 $I->click('div.module-docheader .btn.t3js-editform-close');
59
60 $I->waitForElementVisible('table.table-striped');
61 $I->canSee('Redirect Management', 'h1');
62 $I->canSeeNumberOfElements('table.table-striped > tbody > tr', 1);
63 }
64
65 /**
66 * @param Admin $I
67 */
68 public function canEditRecordFromListView(Admin $I)
69 {
70 $sourceHost = $I->grabTextFrom('table.table-striped > tbody > tr > td:nth-child(1)');
71 $sourcePath = $I->grabTextFrom('table.table-striped > tbody > tr > td:nth-child(2) > a');
72
73 $I->amGoingTo('test edit on source path');
74 $I->click('table.table-striped > tbody > tr > td:nth-child(2) > a');
75 $this->openAndCloseTheEditForm($I, $sourceHost . ', ' . $sourcePath);
76
77 $I->amGoingTo('test edit on edit button');
78 $I->click('table.table-striped > tbody > tr > td:nth-child(6) > div > a:nth-child(2)');
79 $this->openAndCloseTheEditForm($I, $sourceHost . ', ' . $sourcePath);
80 }
81
82 /**
83 * @param Admin $I
84 * @param string $name
85 */
86 private function openAndCloseTheEditForm(Admin $I, string $name): void
87 {
88 $I->waitForElementNotVisible('#t3js-ui-block');
89 $I->canSee('Edit Redirect "' . $name . '" on root level');
90
91 $I->click('div.module-docheader .btn.t3js-editform-close');
92 $I->waitForElementVisible('table.table-striped');
93 $I->canSee('Redirect Management', 'h1');
94 }
95 }