‪TYPO3CMS  11.5
RecyclerModuleCest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
23 
25 {
28 
29  protected static string ‪$rootPageTitle = 'styleguide TCA demo';
30  protected static string ‪$treeNode = '#typo3-pagetree-tree .nodes .node';
31  protected static string ‪$dragNode = '#typo3-pagetree-toolbar .svg-toolbar__drag-node';
32  protected static string ‪$nodeEditInput = '.node-edit';
33  protected static string ‪$contentTitle = 'Dummy Recycler Content';
34  protected static string ‪$pageTitle = 'Dummy 1-styleguide TCA demo-new';
35 
40  {
41  $this->pageTree = ‪$pageTree;
42  $this->modalDialog = ‪$modalDialog;
43 
44  $I->useExistingSession('admin');
45  $I->click('List');
46  $I->waitForElement(static::$treeNode, 5);
47  $I->waitForElement(static::$dragNode, 5);
48  $this->pageTree->openPath([static::$rootPageTitle]);
49 
50  // Wait until DOM actually rendered everything
51  $I->waitForElement(static::$treeNode, 5);
52 
53  $this->pageTree->dragAndDropNewPage(static::$rootPageTitle, static::$dragNode, static::$nodeEditInput);
54  $newPage = $this->pageTree->getPageXPathByPageName(static::$pageTitle);
55  $I->click($newPage);
56  $I->switchToContentFrame();
57  $I->waitForElement('[title="Create new record"]');
58  $I->click('a[title="Create new record"]');
59  $I->click('//a[text()[normalize-space(.) = "Page Content"]]');
60  $I->fillField('//input[contains(@data-formengine-input-name, "data[tt_content]") and contains(@data-formengine-input-name, "[header]")]', static::$contentTitle);
61  $I->click('button[name="_savedok"]');
62  $I->click('a[title="Close"]');
63  }
64 
70  {
71  $this->‪deletePage($I);
72  $this->‪goToRecyclerModule($I);
73 
74  // Select depth infinite
75  $I->wait(1);
76  $I->selectOption('select[name="depth"]', 999);
77 
78  $I->amGoingTo('See if the deleted page its content appear in the recycler');
79  $I->waitForText(static::$pageTitle);
80  $I->waitForText(static::$contentTitle);
81 
82  $I->amGoingTo('Recover the page and its contents');
83  $I->click('tr[data-recordtitle="' . static::$pageTitle . '"] .t3js-multi-record-selection-check');
84  $I->click('button[data-multi-record-selection-action="massundo"]');
85  $this->modalDialog->canSeeDialog();
86  $I->click('#undo-recursive');
87  $this->modalDialog->clickButtonInDialog('Recover');
88 
89  $I->amGoingTo('See if page and content got restored');
90  $I->switchToMainFrame();
91  $I->click('List');
92  $newPage = $this->pageTree->getPageXPathByPageName(static::$pageTitle);
93  $I->click($newPage);
94  $I->switchToContentFrame();
95  $I->wait(1);
96  $I->waitForText(static::$contentTitle, 10, 'a[aria-label="Edit record"]');
97  }
98 
110  protected function ‪deleteAndWipeRecords(‪ApplicationTester $I): void
111  {
112  $this->‪deletePage($I);
113  $this->‪goToRecyclerModule($I);
114 
115  // Select depth infinite
116  $I->selectOption('select[name="depth"]', 999);
117 
118  $I->click('.t3js-multi-record-selection-check-actions-toggle');
119  $I->click('button[data-multi-record-selection-check-action="check-all"]');
120 
121  $I->click('button[data-multi-record-selection-action="massdelete"]');
122  $this->modalDialog->canSeeDialog();
123  $this->modalDialog->clickButtonInDialog('Delete');
124 
125  $I->waitForElementVisible('#alert-container');
126  $I->waitForText('2 records were deleted.', 10, '#alert-container');
127  $I->click('#alert-container .close');
128  $I->waitForElementNotVisible('#alert-container typo3-notification-message');
129  // Reload recycler to make sure the record are actually delete from DB
130  $I->switchToContentFrame();
131  $I->click('[data-action="reload"]');
132 
133  $I->cantSee(static::$contentTitle);
134  $I->cantSee(static::$pageTitle);
135  }
136 
140  private function ‪deletePage(‪ApplicationTester $I): void
141  {
142  $I->switchToMainFrame();
143  $I->click('List');
144  $page = $this->pageTree->getPageXPathByPageName(static::$pageTitle);
145  $I->click($page);
146 
147  $I->switchToContentFrame();
148  $I->click('a[title="Edit page properties"]');
149  $I->click('a[title="Delete"]');
150  $this->modalDialog->clickButtonInDialog('Yes, delete this record');
151  }
152 
157  private function ‪goToRecyclerModule(‪ApplicationTester $I): void
158  {
159  $I->switchToMainFrame();
160  $I->click('Recycler');
161  $I->waitForElement(static::$treeNode, 5);
162  $page = $this->pageTree->getPageXPathByPageName(static::$rootPageTitle);
163  $I->click($page);
164  $I->switchToContentFrame();
165  }
166 }
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Recycler\RecyclerModuleCest\$rootPageTitle
‪static string $rootPageTitle
Definition: RecyclerModuleCest.php:29
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Recycler\RecyclerModuleCest\deletePage
‪deletePage(ApplicationTester $I)
Definition: RecyclerModuleCest.php:140
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Recycler\RecyclerModuleCest\deleteAndRecoverRecords
‪deleteAndRecoverRecords(ApplicationTester $I)
Definition: RecyclerModuleCest.php:69
‪TYPO3\CMS\Core\Tests\Acceptance\Support\ApplicationTester
Definition: ApplicationTester.php:27
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Recycler
Definition: RecyclerModuleCest.php:18
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Recycler\RecyclerModuleCest\$nodeEditInput
‪static string $nodeEditInput
Definition: RecyclerModuleCest.php:32
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Recycler\RecyclerModuleCest\$pageTitle
‪static string $pageTitle
Definition: RecyclerModuleCest.php:34
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Recycler\RecyclerModuleCest\$treeNode
‪static string $treeNode
Definition: RecyclerModuleCest.php:30
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Recycler\RecyclerModuleCest\$modalDialog
‪ModalDialog $modalDialog
Definition: RecyclerModuleCest.php:27
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Recycler\RecyclerModuleCest\$pageTree
‪PageTree $pageTree
Definition: RecyclerModuleCest.php:26
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Recycler\RecyclerModuleCest\$contentTitle
‪static string $contentTitle
Definition: RecyclerModuleCest.php:33
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Recycler\RecyclerModuleCest\goToRecyclerModule
‪goToRecyclerModule(ApplicationTester $I)
Definition: RecyclerModuleCest.php:157
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Recycler\RecyclerModuleCest\$dragNode
‪static string $dragNode
Definition: RecyclerModuleCest.php:31
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\PageTree
Definition: PageTree.php:31
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Recycler\RecyclerModuleCest
Definition: RecyclerModuleCest.php:25
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Recycler\RecyclerModuleCest\deleteAndWipeRecords
‪deleteAndWipeRecords(ApplicationTester $I)
Definition: RecyclerModuleCest.php:110
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Recycler\RecyclerModuleCest\_before
‪_before(ApplicationTester $I, PageTree $pageTree, ModalDialog $modalDialog)
Definition: RecyclerModuleCest.php:39
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\ModalDialog
Definition: ModalDialog.php:27