1b5f52951ebcbd2c5249a71357e59a37c872cd7d
[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 // Ensure main content frame is fully loaded, otherwise there are load-race-conditions
34 $I->switchToIFrame('list_frame');
35 $I->waitForText('Web Content Management System');
36 $I->switchToIFrame();
37
38 $I->click('Redirects');
39 $I->switchToIFrame('list_frame');
40 $I->waitForElementNotVisible('div#nprogress');
41 $I->canSee('Redirect Management', 'h1');
42 }
43
44 /**
45 * @param Admin $I
46 */
47 public function createNewRecordIfNoneExist(Admin $I)
48 {
49 $I->amGoingTo('create a new redirects record while none are in the system, yet');
50 $I->canSee('No redirects found!');
51 $I->click('Create new redirect');
52 $I->waitForElementNotVisible('#t3js-ui-block');
53 $I->canSee('Create new Redirect on root level');
54
55 $I->fillField('//input[contains(@data-formengine-input-name, "data[sys_redirect]") and contains(@data-formengine-input-name, "[source_path]")]', '/my-path/');
56 $I->fillField('//input[contains(@data-formengine-input-name, "data[sys_redirect]") and contains(@data-formengine-input-name, "[target]")]', 1);
57
58 $saveButtonLink = '//*/button[@name="_savedok"][1]';
59 $I->waitForElement($saveButtonLink, 30);
60 $I->click($saveButtonLink);
61 $I->waitForElementNotVisible('#t3js-ui-block');
62
63 $I->click('div.module-docheader .btn.t3js-editform-close');
64
65 $I->waitForElementVisible('table.table-striped');
66 $I->canSee('Redirect Management', 'h1');
67 $I->canSeeNumberOfElements('table.table-striped > tbody > tr', 1);
68 }
69
70 /**
71 * @param Admin $I
72 */
73 public function canEditRecordFromListView(Admin $I)
74 {
75 $sourceHost = $I->grabTextFrom('table.table-striped > tbody > tr > td:nth-child(1)');
76 $sourcePath = $I->grabTextFrom('table.table-striped > tbody > tr > td:nth-child(2) > a');
77
78 $I->amGoingTo('test edit on source path');
79 $I->click('table.table-striped > tbody > tr > td:nth-child(2) > a');
80 $this->openAndCloseTheEditForm($I, $sourceHost . ', ' . $sourcePath);
81
82 $I->amGoingTo('test edit on edit button');
83 $I->click('table.table-striped > tbody > tr > td:nth-child(6) > div > a:nth-child(2)');
84 $this->openAndCloseTheEditForm($I, $sourceHost . ', ' . $sourcePath);
85 }
86
87 /**
88 * @param Admin $I
89 * @param string $name
90 */
91 private function openAndCloseTheEditForm(Admin $I, string $name): void
92 {
93 $I->waitForElementNotVisible('#t3js-ui-block');
94 $I->canSee('Edit Redirect "' . $name . '" on root level');
95
96 $I->click('div.module-docheader .btn.t3js-editform-close');
97 $I->waitForElementVisible('table.table-striped');
98 $I->canSee('Redirect Management', 'h1');
99 }
100 }