‪TYPO3CMS  ‪main
ExportCest.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 
27 final class ‪ExportCest extends ‪AbstractCest
28 {
29  private string ‪$contextMenuExport = '[data-callback-action=exportT3d]';
30  private string ‪$contextMenuMore = 'li.context-menu-item-submenu';
31  private string ‪$inModuleHeader = '.module-docheader';
32  private string ‪$inModuleTabs = '#ImportExportController .nav-tabs';
33  private string ‪$inModuleTabsBody = '#ImportExportController .tab-content';
34  private string ‪$inTabConfiguration = '#export-configuration';
35  private string ‪$inFlashMessages = '.typo3-messages';
36 
37  public function ‪_before(‪ApplicationTester $I): void
38  {
39  $I->useExistingSession('admin');
40  $I->click('List');
41  }
42 
44  {
45  $pageTree->‪openPath(['styleguide TCA demo']);
46 
47  $selectedPageTitle = 'elements t3editor';
48  $selectedPageIcon = '//*[text()=\'' . $selectedPageTitle . '\']/../../*[contains(@class, \'node-icon\')]';
49 
50  $I->click($selectedPageIcon);
51  $this->selectInContextMenu($I, [$this->contextMenuMore, $this->contextMenuExport]);
52  $I->switchToContentFrame();
53  $I->waitForText($selectedPageTitle);
54  $I->waitForElementNotVisible('#nprogress');
55  $I->see($selectedPageTitle, $this->inModuleHeader);
56 
57  $I->click('Update', $this->inTabConfiguration);
58  $this->timeoutForAjaxRequest($I);
59  $I->see($selectedPageTitle, $this->inModuleHeader);
60  }
61 
62  public function exportTableDisplaysTitleOfRootPageInModuleHeader(ApplicationTester $I, PageTree $pageTree): void
63  {
64  $rootPageTitle = 'New TYPO3 site';
65  $tablePageTitle = 'elements t3editor';
66  $tableTitle = 'Form engine elements - t3editor';
67  $listModuleHeader = '.module-docheader';
68  $listModuleBtnExport = 'a[title="Export"]';
69 
70  $pageTree->openPath(['styleguide TCA demo', $tablePageTitle]);
71  $I->switchToContentFrame();
72  // List module single table mode
73  $I->waitForText($tableTitle);
74  $I->waitForElementNotVisible('#nprogress');
75  $I->click($tableTitle);
76 
77  $I->waitForElementVisible($listModuleHeader . ' ' . $listModuleBtnExport, 5);
78  $I->click($listModuleBtnExport, $listModuleHeader);
79  $I->waitForElementVisible($this->inTabConfiguration, 5);
80  $I->see($rootPageTitle, $this->inModuleHeader);
81  $I->dontSee($tablePageTitle, $this->inModuleHeader);
82 
83  $I->click('Update', $this->inTabConfiguration);
84  $this->timeoutForAjaxRequest($I);
85  $I->see($rootPageTitle, $this->inModuleHeader);
86  $I->dontSee($tablePageTitle, $this->inModuleHeader);
87  }
88 
89  public function exportRecordDisplaysTitleOfRootPageInModuleHeader(ApplicationTester $I, PageTree $pageTree): void
90  {
91  $rootPageTitle = 'New TYPO3 site';
92  $recordPageTitle = 'elements t3editor';
93  $recordTable = '#recordlist-tx_styleguide_elements_t3editor';
94  $recordIcon = 'tr:first-child button[data-contextmenu-trigger]';
95 
96  $pageTree->openPath(['styleguide TCA demo', $recordPageTitle]);
97  $I->switchToContentFrame();
98  // List module single table mode
99  $I->waitForText($recordPageTitle);
100  $I->waitForElementNotVisible('#nprogress');
101  $I->click($recordIcon, $recordTable);
102  $this->selectInContextMenu($I, [$this->contextMenuMore, $this->contextMenuExport]);
103  $I->waitForElementVisible($this->inTabConfiguration, 5);
104  $I->see($rootPageTitle, $this->inModuleHeader);
105  $I->dontSee($recordPageTitle, $this->inModuleHeader);
106 
107  $I->click('Update', $this->inTabConfiguration);
108  $this->timeoutForAjaxRequest($I);
109  $I->see($rootPageTitle, $this->inModuleHeader);
110  $I->dontSee($recordPageTitle, $this->inModuleHeader);
111  }
112 
113  public function saveAndDeletePresetSucceeds(ApplicationTester $I, ModalDialog $modalDialog, PageTree $pageTree): void
114  {
115  $pageTitle = 'staticdata';
116  $exportPageTitle = 'Export pagetree configuration';
117  $pageIcon = '//*[text()=\'' . $pageTitle . '\']/../../*[contains(@class, \'node-icon\')]';
118  $tabExport = 'a[href="#export-filepreset"]';
119  $contentExport = '#export-filepreset';
120  $presetTitle = 'My First Preset';
121  $inputPresetTitle = 'input[name="tx_impexp[preset][title]"]';
122  $buttonSavePreset = 'button[name="preset[save]"]';
123  $buttonDeletePreset = 'button[name="preset[delete]"]';
124  $selectPreset = 'select[name="preset[select]"]';
125 
126  $pageTree->openPath(['styleguide TCA demo']);
127 
128  $I->click($pageIcon);
129  $this->selectInContextMenu($I, [$this->contextMenuMore, $this->contextMenuExport]);
130  $I->switchToContentFrame();
131  $I->waitForText($exportPageTitle);
132  $I->waitForElementNotVisible('#nprogress');
133 
134  $I->click($tabExport, $this->inModuleTabs);
135  $I->waitForElementVisible($contentExport, 5);
136  $I->fillField($this->inModuleTabsBody . ' ' . $inputPresetTitle, $presetTitle);
137  $I->click($buttonSavePreset, $this->inModuleTabsBody);
138 
139  // don't use $modalDialog->clickButtonInDialog due to too low timeout
140  $modalDialog->canSeeDialog();
141  $I->click('OK', ModalDialog::$openedModalButtonContainerSelector);
142  $I->waitForElementNotVisible(ModalDialog::$openedModalSelector, 30);
143  $this->timeoutForAjaxRequest($I);
144 
145  $I->switchToContentFrame();
146  $I->canSeeElement($this->inFlashMessages . ' .alert.alert-info');
147  $I->canSee(sprintf('New preset "%s" is created', $presetTitle), $this->inFlashMessages . ' .alert.alert-info .alert-message');
148 
149  $I->click($tabExport, $this->inModuleTabs);
150  $I->waitForElementVisible($contentExport, 5);
151  $I->selectOption($this->inModuleTabsBody . ' ' . $selectPreset, $presetTitle);
152  $I->click($buttonDeletePreset, $this->inModuleTabsBody);
153 
154  // don't use $modalDialog->clickButtonInDialog due to too low timeout
155  $modalDialog->canSeeDialog();
156  $I->click('OK', ModalDialog::$openedModalButtonContainerSelector);
157  $I->waitForElementNotVisible(ModalDialog::$openedModalSelector, 30);
158  $this->timeoutForAjaxRequest($I);
159 
160  $I->switchToContentFrame();
161  $I->canSeeElement($this->inFlashMessages . ' .alert.alert-info');
162  $flashMessage = $I->grabTextFrom($this->inFlashMessages . ' .alert.alert-info .alert-message');
163  $I->assertMatchesRegularExpression('/Preset #[0-9]+ deleted!/', $flashMessage);
164  }
165 
166  public function exportPageAndRecordsFromPageTree(ApplicationTester $I, PageTree $pageTree): void
167  {
168  $pageTitle = 'staticdata';
169  $exportPageTitle = 'Export pagetree configuration';
170  $pageIcon = '//*[text()=\'' . $pageTitle . '\']/../../*[contains(@class, \'node-icon\')]';
171  $tabExport = 'a[href="#export-filepreset"]';
172  $contentExport = '#export-filepreset';
173  $buttonSaveToFile = 'tx_impexp[save_export]';
174 
175  $pageTree->openPath(['styleguide TCA demo']);
176 
177  $I->click($pageIcon);
178  $this->selectInContextMenu($I, [$this->contextMenuMore, $this->contextMenuExport]);
179  $I->switchToContentFrame();
180  $I->waitForText($exportPageTitle);
181  $I->waitForElementNotVisible('#nprogress');
182 
183  $I->cantSee('No tree exported - only tables on the page.', $this->inModuleTabsBody);
184  $I->see('Inside pagetree');
185  $I->dontSee('Outside pagetree');
186  $I->click($tabExport, $this->inModuleTabs);
187  $I->waitForElementVisible($contentExport, 5);
188  $I->click($buttonSaveToFile, $this->inModuleTabsBody);
189  $I->wait(1);
190  $I->canSeeElement($this->inFlashMessages . ' .alert.alert-success');
191  $I->canSee('SAVED FILE', $this->inFlashMessages . ' .alert.alert-success .alert-title');
192  $flashMessage = $I->grabTextFrom($this->inFlashMessages . ' .alert.alert-success .alert-message');
193  $I->assertMatchesRegularExpression('/Saved in ["][^"]+["], bytes/', $flashMessage);
194  }
195 
196  public function exportTable(ApplicationTester $I): void
197  {
198  $rootPage = '#typo3-pagetree-treeContainer [role="treeitem"][data-id="0"] .node-contentlabel';
199  $rootPageTitle = 'New TYPO3 site';
200  $beUsergroupTableTitle = 'Backend usergroup';
201  $listModuleHeader = '.module-docheader';
202  $listModuleBtnExport = 'a[title="Export"]';
203  $tabExport = 'a[href="#export-filepreset"]';
204  $contentExport = '#export-filepreset';
205  $buttonSaveToFile = 'tx_impexp[save_export]';
206 
207  $I->canSeeElement($rootPage);
208  $I->click($rootPage);
209  $I->switchToContentFrame();
210  $I->waitForText($rootPageTitle);
211  $I->waitForElementNotVisible('#nprogress');
212 
213  $I->click($beUsergroupTableTitle);
214  $I->waitForElementVisible($listModuleHeader . ' ' . $listModuleBtnExport, 5);
215  $I->click($listModuleBtnExport, $listModuleHeader);
216 
217  $I->waitForElementVisible($tabExport, 5);
218  $I->canSee('No tree exported - only tables on the page.', $this->inModuleTabsBody);
219  $I->canSee('Export tables from pages', $this->inModuleTabsBody);
220  $I->dontSee('Inside pagetree');
221  $I->see('Outside pagetree');
222  $I->click($tabExport, $this->inModuleTabs);
223  $I->waitForElementVisible($contentExport, 5);
224  $I->click($buttonSaveToFile, $this->inModuleTabsBody);
225  $I->wait(1);
226  $I->canSeeElement($this->inFlashMessages . ' .alert.alert-success');
227  $I->canSee('SAVED FILE', $this->inFlashMessages . ' .alert.alert-success .alert-title');
228  $flashMessage = $I->grabTextFrom($this->inFlashMessages . ' .alert.alert-success .alert-message');
229  $I->assertMatchesRegularExpression('/Saved in ["][^"]+["], bytes/', $flashMessage);
230  }
231 
232  public function exportRecord(ApplicationTester $I): void
233  {
234  $rootPage = '#typo3-pagetree-treeContainer [role="treeitem"][data-id="0"] .node-contentlabel';
235  $rootPageTitle = 'New TYPO3 site';
236  $sysLanguageTable = '#recordlist-be_groups';
237  $sysLanguageIcon = 'tr:first-child button[data-contextmenu-trigger]';
238  $tabExport = 'a[href="#export-filepreset"]';
239  $contentExport = '#export-filepreset';
240  $buttonSaveToFile = 'tx_impexp[save_export]';
241 
242  // select root page in list module
243  $I->canSeeElement($rootPage);
244  $I->click($rootPage);
245  $I->switchToContentFrame();
246  $I->waitForElementNotVisible('#nprogress');
247  $I->waitForText($rootPageTitle);
248  $I->click($sysLanguageIcon, $sysLanguageTable);
249  $this->selectInContextMenu($I, [$this->contextMenuMore, $this->contextMenuExport]);
250 
251  $I->waitForElementVisible($tabExport, 5);
252  $I->canSee('No tree exported - only tables on the page.', $this->inModuleTabsBody);
253  $I->canSee('Export single record', $this->inModuleTabsBody);
254  $I->dontSee('Inside pagetree');
255  $I->see('Outside pagetree');
256  $I->click($tabExport, $this->inModuleTabs);
257  $I->waitForElementVisible($contentExport, 5);
258  $I->click($buttonSaveToFile, $this->inModuleTabsBody);
259  $I->wait(1);
260  $I->canSeeElement($this->inFlashMessages . ' .alert.alert-success');
261  $I->canSee('SAVED FILE', $this->inFlashMessages . ' .alert.alert-success .alert-title');
262  $flashMessage = $I->grabTextFrom($this->inFlashMessages . ' .alert.alert-success .alert-message');
263  $I->assertMatchesRegularExpression('/Saved in ["][^"]+["], bytes/', $flashMessage);
264  }
265 }
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp\ExportCest\exportPageAndRecordsDisplaysTitleOfSelectedPageInModuleHeader
‪exportPageAndRecordsDisplaysTitleOfSelectedPageInModuleHeader(ApplicationTester $I, PageTree $pageTree)
Definition: ExportCest.php:43
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp\ExportCest\$contextMenuMore
‪string $contextMenuMore
Definition: ExportCest.php:30
‪TYPO3\CMS\Core\Tests\Acceptance\Support\ApplicationTester
Definition: ApplicationTester.php:28
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp\ExportCest\$inModuleTabsBody
‪string $inModuleTabsBody
Definition: ExportCest.php:33
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp\ExportCest\$inFlashMessages
‪string $inFlashMessages
Definition: ExportCest.php:35
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp\ExportCest\$contextMenuExport
‪string $contextMenuExport
Definition: ExportCest.php:29
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\AbstractTree\openPath
‪openPath(array $path)
Definition: AbstractTree.php:55
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp\ExportCest\_before
‪_before(ApplicationTester $I)
Definition: ExportCest.php:37
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp\ExportCest\$inModuleTabs
‪string $inModuleTabs
Definition: ExportCest.php:32
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp\ExportCest\$inTabConfiguration
‪string $inTabConfiguration
Definition: ExportCest.php:34
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp
Definition: AbstractCest.php:18
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp\AbstractCest
Definition: AbstractCest.php:26
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp\ExportCest
Definition: ExportCest.php:28
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\PageTree
Definition: PageTree.php:26
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp\ExportCest\$inModuleHeader
‪string $inModuleHeader
Definition: ExportCest.php:31
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\ModalDialog
Definition: ModalDialog.php:24