‪TYPO3CMS  11.5
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 
24 
29 {
34  protected array ‪$testFilesToDelete = [];
35 
36  protected string ‪$inPageTree = '#typo3-pagetree-treeContainer .nodes';
37  protected string ‪$inModuleHeader = '.module-docheader';
38  protected string ‪$inModuleTabs = '#ImportExportController .nav-tabs';
39  protected string ‪$inModuleTabsBody = '#ImportExportController .tab-content';
40  protected string ‪$inModulePreview = '#ImportExportController > div:last-child';
41  protected string ‪$inTabConfiguration = '#export-configuration';
42  protected string ‪$inFlashMessages = '.typo3-messages';
43 
44  public function ‪_before(‪ApplicationTester $I): void
45  {
46  $I->useExistingSession('admin');
47  $I->click('List');
48  $I->waitForElement('#typo3-pagetree-tree .nodes .node');
49  }
50 
51  public function ‪_after(‪ApplicationTester $I): void
52  {
53  $I->amGoingTo('clean up created files');
54 
55  foreach ($this->testFilesToDelete as $filePath) {
56  unlink($filePath);
57  $I->dontSeeFileFound($filePath);
58  }
59  $this->testFilesToDelete = [];
60  }
61 
63  {
64  $pageTree->‪openPath(['styleguide TCA demo']);
65 
66  $selectedPageTitle = 'elements t3editor';
67  $selectedPageIcon = '//*[text()=\'' . $selectedPageTitle . '\']/../*[contains(@class, \'node-icon-container\')]';
68  $buttonUpdate = '.btn[value=Update]';
69 
70  $I->click($selectedPageIcon);
71  $this->selectInContextMenu($I, [$this->contextMenuMore, $this->contextMenuExport]);
72  $I->switchToContentFrame();
73  $I->waitForText($selectedPageTitle);
74  $I->waitForElementNotVisible('#nprogress');
75  $I->see($selectedPageTitle, $this->inModuleHeader);
76 
77  $I->click($buttonUpdate, $this->inTabConfiguration);
78  $this->waitForAjaxRequestToFinish($I);
79  $I->see($selectedPageTitle, $this->inModuleHeader);
80  }
81 
82  public function exportTableDisplaysTitleOfRootPageInModuleHeader(ApplicationTester $I, PageTree $pageTree): void
83  {
84  $rootPageTitle = 'New TYPO3 site';
85  $tablePageTitle = 'elements t3editor';
86  $tableTitle = 'Form engine elements - t3editor';
87  $listModuleHeader = '.module-docheader';
88  $listModuleBtnExport = 'a[title="Export"]';
89  $buttonUpdate = '.btn[value=Update]';
90 
91  $pageTree->openPath(['styleguide TCA demo', $tablePageTitle]);
92  $I->switchToContentFrame();
93  // List module single table mode
94  $I->waitForText($tableTitle);
95  $I->waitForElementNotVisible('#nprogress');
96  $I->click($tableTitle);
97 
98  $I->waitForElementVisible($listModuleHeader . ' ' . $listModuleBtnExport, 5);
99  $I->click($listModuleBtnExport, $listModuleHeader);
100  $I->waitForElementVisible($this->inTabConfiguration, 5);
101  $I->see($rootPageTitle, $this->inModuleHeader);
102  $I->dontSee($tablePageTitle, $this->inModuleHeader);
103 
104  $I->click($buttonUpdate, $this->inTabConfiguration);
105  $this->waitForAjaxRequestToFinish($I);
106  $I->see($rootPageTitle, $this->inModuleHeader);
107  $I->dontSee($tablePageTitle, $this->inModuleHeader);
108  }
109 
110  public function exportRecordDisplaysTitleOfRootPageInModuleHeader(ApplicationTester $I, PageTree $pageTree): void
111  {
112  $rootPageTitle = 'New TYPO3 site';
113  $recordPageTitle = 'elements t3editor';
114  $recordTable = '#recordlist-tx_styleguide_elements_t3editor';
115  $recordIcon = 'tr:first-child a.t3js-contextmenutrigger';
116  $buttonUpdate = '.btn[value=Update]';
117 
118  $pageTree->openPath(['styleguide TCA demo', $recordPageTitle]);
119  $I->switchToContentFrame();
120  // List module single table mode
121  $I->waitForText($recordPageTitle);
122  $I->waitForElementNotVisible('#nprogress');
123  $I->click($recordIcon, $recordTable);
124  $this->selectInContextMenu($I, [$this->contextMenuMore, $this->contextMenuExport]);
125  $I->waitForElementVisible($this->inTabConfiguration, 5);
126  $I->see($rootPageTitle, $this->inModuleHeader);
127  $I->dontSee($recordPageTitle, $this->inModuleHeader);
128 
129  $I->click($buttonUpdate, $this->inTabConfiguration);
130  $this->waitForAjaxRequestToFinish($I);
131  $I->see($rootPageTitle, $this->inModuleHeader);
132  $I->dontSee($recordPageTitle, $this->inModuleHeader);
133  }
134 
135  public function saveAndDeletePresetSucceeds(ApplicationTester $I, ModalDialog $modalDialog, PageTree $pageTree): void
136  {
137  $pageTitle = 'staticdata';
138  $exportPageTitle = 'Export pagetree configuration';
139  $pageIcon = '//*[text()=\'' . $pageTitle . '\']/../*[contains(@class, \'node-icon-container\')]';
140  $tabExport = 'a[href="#export-filepreset"]';
141  $contentExport = '#export-filepreset';
142  $presetTitle = 'My First Preset';
143  $inputPresetTitle = 'input[name="tx_impexp[preset][title]"]';
144  $buttonSavePreset = 'button[name="preset[save]"]';
145  $buttonDeletePreset = 'button[name="preset[delete]"]';
146  $selectPreset = 'select[name="preset[select]"]';
147 
148  $pageTree->openPath(['styleguide TCA demo']);
149 
150  $I->click($pageIcon);
151  $this->selectInContextMenu($I, [$this->contextMenuMore, $this->contextMenuExport]);
152  $I->switchToContentFrame();
153  $I->waitForText($exportPageTitle);
154  $I->waitForElementNotVisible('#nprogress');
155 
156  $I->click($tabExport, $this->inModuleTabs);
157  $I->waitForElementVisible($contentExport, 5);
158  $I->fillField($this->inModuleTabsBody . ' ' . $inputPresetTitle, $presetTitle);
159  $I->click($buttonSavePreset, $this->inModuleTabsBody);
160 
161  // don't use $modalDialog->clickButtonInDialog due to too low timeout
162  $modalDialog->canSeeDialog();
163  $I->click('OK', ModalDialog::$openedModalButtonContainerSelector);
164  $I->waitForElementNotVisible(ModalDialog::$openedModalSelector, 30);
165  $this->waitForAjaxRequestToFinish($I);
166 
167  $I->switchToContentFrame();
168  $I->canSeeElement($this->inFlashMessages . ' .alert.alert-info');
169  $I->canSee(sprintf('New preset "%s" is created', $presetTitle), $this->inFlashMessages . ' .alert.alert-info .alert-message');
170 
171  $I->click($tabExport, $this->inModuleTabs);
172  $I->waitForElementVisible($contentExport, 5);
173  $I->selectOption($this->inModuleTabsBody . ' ' . $selectPreset, $presetTitle);
174  $I->click($buttonDeletePreset, $this->inModuleTabsBody);
175 
176  // don't use $modalDialog->clickButtonInDialog due to too low timeout
177  $modalDialog->canSeeDialog();
178  $I->click('OK', ModalDialog::$openedModalButtonContainerSelector);
179  $I->waitForElementNotVisible(ModalDialog::$openedModalSelector, 30);
180  $this->waitForAjaxRequestToFinish($I);
181 
182  $I->switchToContentFrame();
183  $I->canSeeElement($this->inFlashMessages . ' .alert.alert-info');
184  $flashMessage = $I->grabTextFrom($this->inFlashMessages . ' .alert.alert-info .alert-message');
185  $I->assertMatchesRegularExpression('/Preset #[0-9]+ deleted!/', $flashMessage);
186  }
187 
188  public function exportPageAndRecordsFromPageTree(ApplicationTester $I, PageTree $pageTree): void
189  {
190  $I->wantToTest('exporting a page with records.');
191 
192  $pageTitle = 'staticdata';
193  $exportPageTitle = 'Export pagetree configuration';
194  $pageIcon = '//*[text()=\'' . $pageTitle . '\']/../*[contains(@class, \'node-icon-container\')]';
195  $tabExport = 'a[href="#export-filepreset"]';
196  $contentExport = '#export-filepreset';
197  $buttonSaveToFile = 'tx_impexp[save_export]';
198 
199  $pageTree->openPath(['styleguide TCA demo']);
200 
201  $I->click($pageIcon);
202  $this->selectInContextMenu($I, [$this->contextMenuMore, $this->contextMenuExport]);
203  $I->switchToContentFrame();
204  $I->waitForText($exportPageTitle);
205  $I->waitForElementNotVisible('#nprogress');
206 
207  $I->cantSee('No tree exported - only tables on the page.', $this->inModuleTabsBody);
208  $I->see('Inside pagetree', $this->inModulePreview);
209  $I->dontSee('Outside pagetree', $this->inModulePreview);
210  $I->click($tabExport, $this->inModuleTabs);
211  $I->waitForElementVisible($contentExport, 5);
212  $I->click($buttonSaveToFile, $this->inModuleTabsBody);
213  $I->wait(1);
214  $I->canSeeElement($this->inFlashMessages . ' .alert.alert-success');
215  $I->canSee('SAVED FILE', $this->inFlashMessages . ' .alert.alert-success .alert-title');
216  $flashMessage = $I->grabTextFrom($this->inFlashMessages . ' .alert.alert-success .alert-message');
217  $I->assertMatchesRegularExpression('/Saved in ["][^"]+["], bytes/', $flashMessage);
218  // TODO: find out how to clean this up, as it is impossible to determine the absolute file path from an url
219  // preg_match('/[^"]+"([^"]+)"[^"]+/', $flashMessage, $flashMessageParts);
220  // $saveFilePath = Environment::getProjectPath() . '/' . $flashMessageParts[1];
221  // $this->testFilesToDelete[] = $saveFilePath;
222  }
223 
224  public function exportTable(ApplicationTester $I): void
225  {
226  $I->wantToTest('exporting a table of records.');
227 
228  $rootPage = '#identifier-0_0 .node-name';
229  $rootPageTitle = 'New TYPO3 site';
230  $sysLanguageTableTitle = 'Website Language';
231  $listModuleHeader = '.module-docheader';
232  $listModuleBtnExport = 'a[title="Export"]';
233  $tabExport = 'a[href="#export-filepreset"]';
234  $contentExport = '#export-filepreset';
235  $buttonSaveToFile = 'tx_impexp[save_export]';
236 
237  $I->canSeeElement($rootPage);
238  $I->click($rootPage);
239  $I->switchToContentFrame();
240  $I->waitForText($rootPageTitle);
241  $I->waitForElementNotVisible('#nprogress');
242 
243  $I->click($sysLanguageTableTitle);
244  $I->waitForElementVisible($listModuleHeader . ' ' . $listModuleBtnExport, 5);
245  $I->click($listModuleBtnExport, $listModuleHeader);
246 
247  $I->waitForElementVisible($tabExport, 5);
248  $I->canSee('No tree exported - only tables on the page.', $this->inModuleTabsBody);
249  $I->canSee('Export tables from pages', $this->inModuleTabsBody);
250  $I->dontSee('Inside pagetree', $this->inModulePreview);
251  $I->see('Outside pagetree', $this->inModulePreview);
252  $I->click($tabExport, $this->inModuleTabs);
253  $I->waitForElementVisible($contentExport, 5);
254  $I->click($buttonSaveToFile, $this->inModuleTabsBody);
255  $I->wait(1);
256  $I->canSeeElement($this->inFlashMessages . ' .alert.alert-success');
257  $I->canSee('SAVED FILE', $this->inFlashMessages . ' .alert.alert-success .alert-title');
258  $flashMessage = $I->grabTextFrom($this->inFlashMessages . ' .alert.alert-success .alert-message');
259  $I->assertMatchesRegularExpression('/Saved in ["][^"]+["], bytes/', $flashMessage);
260  // TODO: find out how to clean this up, as it is impossible to determine the absolute file path from an url
261  // preg_match('/[^"]+"([^"]+)"[^"]+/', $flashMessage, $flashMessageParts);
262  // $saveFilePath = Environment::getProjectPath() . '/' . $flashMessageParts[1];
263  // $this->testFilesToDelete[] = $saveFilePath;
264  }
265 
266  public function exportRecord(ApplicationTester $I): void
267  {
268  $I->wantToTest('exporting a single record.');
269 
270  $rootPage = '#identifier-0_0 .node-name';
271  $rootPageTitle = 'New TYPO3 site';
272  $sysLanguageTable = '#recordlist-sys_language';
273  $sysLanguageIcon = 'tr:first-child a.t3js-contextmenutrigger';
274  $tabExport = 'a[href="#export-filepreset"]';
275  $contentExport = '#export-filepreset';
276  $buttonSaveToFile = 'tx_impexp[save_export]';
277 
278  // select root page in list module
279  $I->canSeeElement($rootPage);
280  $I->click($rootPage);
281  $I->switchToContentFrame();
282  $I->waitForElementNotVisible('#nprogress');
283  $I->waitForText($rootPageTitle);
284  $I->click($sysLanguageIcon, $sysLanguageTable);
285  $this->selectInContextMenu($I, [$this->contextMenuMore, $this->contextMenuExport]);
286 
287  $I->waitForElementVisible($tabExport, 5);
288  $I->canSee('No tree exported - only tables on the page.', $this->inModuleTabsBody);
289  $I->canSee('Export single record', $this->inModuleTabsBody);
290  $I->dontSee('Inside pagetree', $this->inModulePreview);
291  $I->see('Outside pagetree', $this->inModulePreview);
292  $I->click($tabExport, $this->inModuleTabs);
293  $I->waitForElementVisible($contentExport, 5);
294  $I->click($buttonSaveToFile, $this->inModuleTabsBody);
295  $I->wait(1);
296  $I->canSeeElement($this->inFlashMessages . ' .alert.alert-success');
297  $I->canSee('SAVED FILE', $this->inFlashMessages . ' .alert.alert-success .alert-title');
298  $flashMessage = $I->grabTextFrom($this->inFlashMessages . ' .alert.alert-success .alert-message');
299  $I->assertMatchesRegularExpression('/Saved in ["][^"]+["], bytes/', $flashMessage);
300  // TODO: find out how to clean this up, as it is impossible to determine the absolute file path from an url
301  // preg_match('/[^"]+"([^"]+)"[^"]+/', $flashMessage, $flashMessageParts);
302  // $saveFilePath = Environment::getProjectPath() . '/' . $flashMessageParts[1];
303  // $this->testFilesToDelete[] = $saveFilePath;
304  }
305 }
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp\ExportCest\exportPageAndRecordsDisplaysTitleOfSelectedPageInModuleHeader
‪exportPageAndRecordsDisplaysTitleOfSelectedPageInModuleHeader(ApplicationTester $I, PageTree $pageTree)
Definition: ExportCest.php:62
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp\ExportCest\$testFilesToDelete
‪array $testFilesToDelete
Definition: ExportCest.php:34
‪TYPO3\CMS\Core\Tests\Acceptance\Support\ApplicationTester
Definition: ApplicationTester.php:27
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp\ExportCest\$inModuleTabsBody
‪string $inModuleTabsBody
Definition: ExportCest.php:39
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp\ExportCest\$inFlashMessages
‪string $inFlashMessages
Definition: ExportCest.php:42
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\PageTree\openPath
‪openPath(array $path)
Definition: PageTree.php:76
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp\ExportCest\_before
‪_before(ApplicationTester $I)
Definition: ExportCest.php:44
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp\ExportCest\$inPageTree
‪string $inPageTree
Definition: ExportCest.php:36
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp\ExportCest\$inModuleTabs
‪string $inModuleTabs
Definition: ExportCest.php:38
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp\ExportCest\$inTabConfiguration
‪string $inTabConfiguration
Definition: ExportCest.php:41
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp
Definition: AbstractCest.php:18
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:43
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp\AbstractCest
Definition: AbstractCest.php:28
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp\ExportCest
Definition: ExportCest.php:29
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\PageTree
Definition: PageTree.php:31
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp\ExportCest\$inModulePreview
‪string $inModulePreview
Definition: ExportCest.php:40
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp\ExportCest\$inModuleHeader
‪string $inModuleHeader
Definition: ExportCest.php:37
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\ModalDialog
Definition: ModalDialog.php:27
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp\ExportCest\_after
‪_after(ApplicationTester $I)
Definition: ExportCest.php:51