‪TYPO3CMS  11.5
UsersCest.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 
20 use Codeception\Scenario;
23 
28 {
29  protected string ‪$inPageTree = '#typo3-pagetree-treeContainer .nodes';
30  protected string ‪$inModuleHeader = '.module-docheader';
31  protected string ‪$inModuleTabs = '#ImportExportController .nav-tabs';
32  protected string ‪$inModuleTabsBody = '#ImportExportController .tab-content';
33 
34  protected string ‪$buttonUser = '#typo3-cms-backend-backend-toolbaritems-usertoolbaritem';
35  protected string ‪$buttonLogout = '#typo3-cms-backend-backend-toolbaritems-usertoolbaritem button.btn.btn-danger';
36  protected string ‪$contextMenuMore = '#contentMenu0 li.list-group-item-submenu';
37  protected string ‪$contextMenuExport = '#contentMenu1 li.list-group-item[data-callback-action=exportT3d]';
38  protected string ‪$contextMenuImport = '#contentMenu1 li.list-group-item[data-callback-action=importT3d]';
39  protected string ‪$buttonViewPage = 'span[data-identifier="actions-view-page"]';
40  protected string ‪$tabUpload = 'a[href="#import-upload"]';
41  protected string ‪$checkboxForceAllUids = 'input#checkForce_all_UIDS';
42 
46  public function ‪_before(‪ApplicationTester $I): void
47  {
48  $I->useExistingSession('admin');
49  $I->click('List');
50  $I->waitForElement('svg .nodes .node');
51  }
52 
56  public function ‪doNotShowImportAndExportInContextMenuForNonAdminUser(‪ApplicationTester $I, ‪PageTree $pageTree, Scenario $scenario): void
57  {
58  $selectedPageTitle = 'Root';
59  $selectedPageIcon = '//*[text()=\'' . $selectedPageTitle . '\']/../*[contains(@class, \'node-icon-container\')]';
60 
61  $this->setPageAccess($I, $pageTree, [$selectedPageTitle], 1);
62  $this->setModAccess($I, 1, ['web_list' => true]);
63  $isComposerMode = str_contains($scenario->current('env'), 'composer');
64  $userId = $isComposerMode ? 3 : 2;
65  $this->setUserTsConfig($I, $scenario, $userId, '');
66  $I->useExistingSession('editor');
67 
68  $I->click($selectedPageIcon);
69  $this->selectInContextMenu($I, [$this->contextMenuMore]);
70  $I->waitForElementVisible('#contentMenu1', 5);
71  $I->dontSeeElement($this->contextMenuExport);
72  $I->dontSeeElement($this->contextMenuImport);
73 
74  $I->useExistingSession('admin');
75  }
76 
80  public function showImportExportInContextMenuForNonAdminUserIfFlagSet(ApplicationTester $I, Scenario $scenario): void
81  {
82  $selectedPageTitle = 'Root';
83  $selectedPageIcon = '//*[text()=\'' . $selectedPageTitle . '\']/../*[contains(@class, \'node-icon-container\')]';
84 
85  $isComposerMode = str_contains($scenario->current('env'), 'composer');
86  $userId = $isComposerMode ? 3 : 2;
87  $this->setUserTsConfig($I, $scenario, $userId, "options.impexp.enableImportForNonAdminUser = 1\noptions.impexp.enableExportForNonAdminUser = 1");
88  $I->useExistingSession('editor');
89 
90  $I->click($selectedPageIcon);
91  $this->selectInContextMenu($I, [$this->contextMenuMore]);
92  $I->waitForElementVisible('#contentMenu1', 5);
93  $I->seeElement($this->contextMenuImport);
94  $I->seeElement($this->contextMenuExport);
95 
96  $I->useExistingSession('admin');
97  }
98 
102  public function hideImportCheckboxForceAllUidsForNonAdmin(ApplicationTester $I): void
103  {
104  $selectedPageTitle = 'Root';
105  $selectedPageIcon = '//*[text()=\'' . $selectedPageTitle . '\']/../*[contains(@class, \'node-icon-container\')]';
106  $importPageSectionTitle = 'Select file to import';
107 
108  $I->click($selectedPageIcon);
109  $this->selectInContextMenu($I, [$this->contextMenuMore, $this->contextMenuImport]);
110  $I->switchToContentFrame();
111  $I->seeElement($this->checkboxForceAllUids);
112 
113  $I->useExistingSession('editor');
114 
115  $I->click($selectedPageIcon);
116  $this->selectInContextMenu($I, [$this->contextMenuMore, $this->contextMenuImport]);
117  $I->switchToContentFrame();
118  $I->waitForText($importPageSectionTitle);
119  $I->dontSeeElement($this->checkboxForceAllUids);
120 
121  $I->useExistingSession('admin');
122  }
123 
127  public function hideUploadTabAndImportPathIfNoImportFolderAvailable(ApplicationTester $I, PageTree $pageTree, Scenario $scenario): void
128  {
129  $selectedPageTitle = 'Root';
130  $selectedPageIcon = '//*[text()=\'' . $selectedPageTitle . '\']/../*[contains(@class, \'node-icon-container\')]';
131  $importPageSectionTitle = 'Select file to import';
132 
133  $I->click($selectedPageIcon);
134  $this->selectInContextMenu($I, [$this->contextMenuMore, $this->contextMenuImport]);
135  $I->switchToContentFrame();
136  $I->see('From path:', $this->inModuleTabsBody);
137  $I->seeElement($this->inModuleTabs . ' ' . $this->tabUpload);
138 
139  $I->useExistingSession('editor');
140 
141  $I->click($selectedPageIcon);
142  $this->selectInContextMenu($I, [$this->contextMenuMore, $this->contextMenuImport]);
143  $I->switchToContentFrame();
144  $I->waitForText($importPageSectionTitle);
145  $I->dontSee('From path:', $this->inModuleTabsBody);
146  $I->dontSeeElement($this->inModuleTabs . ' ' . $this->tabUpload);
147 
148  $I->useExistingSession('admin');
149 
150  $this->setPageAccess($I, $pageTree, ['Root'], 0);
151  $this->setModAccess($I, 1, ['web_list' => false]);
152  $isComposerMode = str_contains($scenario->current('env'), 'composer');
153  $userId = $isComposerMode ? 3 : 2;
154  $this->setUserTsConfig($I, $scenario, $userId, '');
155  }
156 
160  public function checkVisualElements(ApplicationTester $I, PageTree $pageTree, Scenario $scenario): void
161  {
162  $selectedPageTitle = 'Root';
163  $selectedPageIcon = '//*[text()=\'' . $selectedPageTitle . '\']/../*[contains(@class, \'node-icon-container\')]';
164  $importPageSectionTitle = 'Select file to import';
165 
166  $I->click($this->inPageTree . ' #identifier-0_0 .node-icon-container');
167  $this->selectInContextMenu($I, [$this->contextMenuMore, $this->contextMenuImport]);
168  $I->switchToContentFrame();
169  $I->waitForText($importPageSectionTitle);
170  $I->dontSeeElement($this->inModuleHeader . ' ' . $this->buttonViewPage);
171 
172  $I->switchToMainFrame();
173 
174  $I->click('List');
175  $I->click($selectedPageIcon);
176  $this->selectInContextMenu($I, [$this->contextMenuMore, $this->contextMenuImport]);
177  $I->switchToContentFrame();
178  $I->seeElement($this->inModuleHeader . ' ' . $this->buttonViewPage);
179 
180  $this->setPageAccess($I, $pageTree, ['Root'], 1);
181  $this->setModAccess($I, 1, ['web_list' => true]);
182  $isComposerMode = str_contains($scenario->current('env'), 'composer');
183  $userId = $isComposerMode ? 3 : 2;
184  $this->setUserTsConfig($I, $scenario, $userId, 'options.impexp.enableImportForNonAdminUser = 1');
185  $I->useExistingSession('editor');
186 
187  $I->click($selectedPageIcon);
188  $this->selectInContextMenu($I, [$this->contextMenuMore, $this->contextMenuImport]);
189  $I->switchToContentFrame();
190  $I->seeElement($this->inModuleHeader . ' ' . $this->buttonViewPage);
191 
192  $I->useExistingSession('admin');
193 
194  $this->setPageAccess($I, $pageTree, ['Root'], 0);
195  $this->setModAccess($I, 1, ['web_list' => false]);
196  $isComposerMode = str_contains($scenario->current('env'), 'composer');
197  $userId = $isComposerMode ? 3 : 2;
198  $this->setUserTsConfig($I, $scenario, $userId, '');
199  }
200 }
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp\UsersCest\$buttonLogout
‪string $buttonLogout
Definition: UsersCest.php:35
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp\UsersCest\$contextMenuMore
‪string $contextMenuMore
Definition: UsersCest.php:36
‪TYPO3\CMS\Core\Tests\Acceptance\Support\ApplicationTester
Definition: ApplicationTester.php:27
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp\UsersCest\$inModuleTabs
‪string $inModuleTabs
Definition: UsersCest.php:31
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp\UsersCest\$inModuleHeader
‪string $inModuleHeader
Definition: UsersCest.php:30
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp\UsersCest\$checkboxForceAllUids
‪string $checkboxForceAllUids
Definition: UsersCest.php:41
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp\UsersCest\doNotShowImportAndExportInContextMenuForNonAdminUser
‪doNotShowImportAndExportInContextMenuForNonAdminUser(ApplicationTester $I, PageTree $pageTree, Scenario $scenario)
Definition: UsersCest.php:56
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp\UsersCest\$buttonUser
‪string $buttonUser
Definition: UsersCest.php:34
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp\UsersCest
Definition: UsersCest.php:28
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp\UsersCest\$buttonViewPage
‪string $buttonViewPage
Definition: UsersCest.php:39
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp\UsersCest\$tabUpload
‪string $tabUpload
Definition: UsersCest.php:40
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp
Definition: AbstractCest.php:18
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp\UsersCest\$contextMenuImport
‪string $contextMenuImport
Definition: UsersCest.php:38
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp\UsersCest\$inPageTree
‪string $inPageTree
Definition: UsersCest.php:29
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp\AbstractCest
Definition: AbstractCest.php:28
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp\UsersCest\$contextMenuExport
‪string $contextMenuExport
Definition: UsersCest.php:37
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp\UsersCest\_before
‪_before(ApplicationTester $I)
Definition: UsersCest.php:46
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\PageTree
Definition: PageTree.php:31
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp\UsersCest\$inModuleTabsBody
‪string $inModuleTabsBody
Definition: UsersCest.php:32