‪TYPO3CMS  ‪main
FileOperationsCest.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 
28 {
29  public function ‪_before(‪ApplicationTester $I, ‪FileTree $tree): void
30  {
31  $I->useExistingSession('admin');
32  $I->amOnPage('/typo3/module/file/list');
33  $I->switchToContentFrame();
34  }
35 
36  public function ‪fileCrud(‪ApplicationTester $I, ‪ModalDialog $modalDialog): void
37  {
38  $codeMirrorSelector = 'typo3-t3editor-codemirror[name="data[editfile][0][data]"]';
39  $fileName = 'typo3-test.txt';
40  $flashMessageSelector = '.typo3-messages';
41 
42  // Create file
43  $I->amGoingTo('create a file with content');
44  $I->click('.module-docheader .btn[title="Create File"]');
45  $I->wait(0.2);
46  $I->see('Create File', 'h1');
47  $I->fillField('#newfile', $fileName);
48  $I->wait(0.2);
49  $I->click('Create file');
50  $I->see('File created:', $flashMessageSelector);
51  $I->waitForElementVisible($codeMirrorSelector);
52  $I->executeJS("document.querySelector('" . $codeMirrorSelector . "').setContent('Some Text')");
53 
54  // Save file
55  $I->amGoingTo('save the file');
56  $I->click('.module-docheader button[name="_save"]');
57  $I->waitForElementVisible($codeMirrorSelector);
58  $I->executeJS("console.assert(document.querySelector('" . $codeMirrorSelector . "').getContent() === 'Some Text')");
59  $I->see('File saved to', $flashMessageSelector);
60 
61  // Save file
62  $I->amGoingTo('close the file and return to the list view');
63  $I->click('.module-docheader .btn[title="Cancel"]');
64  $I->see($fileName, '[data-multi-record-selection-element="true"]');
65 
66  // Delete file
67  $I->amGoingTo('delete the file');
68  $I->clickWithRightButton('[data-filelist-identifier="1:/' . $fileName . '"] [data-filelist-action="primary"]');
69  $I->click('[data-title="Delete"]');
70  $modalDialog->‪canSeeDialog();
71  $modalDialog->‪clickButtonInDialog('Yes, delete this file');
72  $I->waitForElementNotVisible('[data-filelist-identifier="1:/' . $fileName . '"]');
73  $I->switchToContentFrame();
74  $I->see('File deleted', $flashMessageSelector);
75  $I->dontSee($fileName, '[data-multi-record-selection-element="true"]');
76  }
77 
78  public function ‪seeUploadFile(‪ApplicationTester $I): void
79  {
80  $alertContainer = '#alert-container';
81  $fileName = 'blue_mountains.jpg';
82  $this->‪uploadFile($I, $fileName);
83 
84  $I->switchToMainFrame();
85  $I->waitForText($fileName, 12, $alertContainer);
86  $I->click('.close', $alertContainer);
87  $I->waitForText('Reload filelist', 15, $alertContainer);
88  $I->click('a[title="Dismiss"]', $alertContainer);
89  $I->switchToContentFrame();
90  $I->see($fileName, '.upload-queue-item');
91  $I->click('a[title="Reload"]');
92  $I->see($fileName, '[data-multi-record-selection-element="true"]');
93  }
94 
95  private function ‪uploadFile(‪ApplicationTester $I, string $name): void
96  {
97  $I->attachFile('input.upload-file-picker', 'Acceptance/Fixtures/Images/' . $name);
98  $I->waitForElementNotVisible('.upload-queue-item .upload-queue-progress');
99  }
100 }
‪TYPO3\CMS\Core\Tests\Acceptance\Application\FileList\FileOperationsCest\uploadFile
‪uploadFile(ApplicationTester $I, string $name)
Definition: FileOperationsCest.php:95
‪TYPO3\CMS\Core\Tests\Acceptance\Application\FileList\FileOperationsCest\fileCrud
‪fileCrud(ApplicationTester $I, ModalDialog $modalDialog)
Definition: FileOperationsCest.php:36
‪TYPO3\CMS\Core\Tests\Acceptance\Application\FileList\FileOperationsCest
Definition: FileOperationsCest.php:28
‪TYPO3\CMS\Core\Tests\Acceptance\Support\ApplicationTester
Definition: ApplicationTester.php:28
‪TYPO3\CMS\Core\Tests\Acceptance\Application\FileList
Definition: FileClipboardCest.php:18
‪TYPO3\CMS\Core\Tests\Acceptance\Application\FileList\FileOperationsCest\_before
‪_before(ApplicationTester $I, FileTree $tree)
Definition: FileOperationsCest.php:29
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\FileTree
Definition: FileTree.php:23
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\ModalDialog\canSeeDialog
‪canSeeDialog()
Definition: ModalDialog.php:68
‪TYPO3\CMS\Core\Tests\Acceptance\Application\FileList\FileOperationsCest\seeUploadFile
‪seeUploadFile(ApplicationTester $I)
Definition: FileOperationsCest.php:78
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\ModalDialog\clickButtonInDialog
‪clickButtonInDialog(string $buttonLinkLocator)
Definition: ModalDialog.php:57
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\ModalDialog
Definition: ModalDialog.php:24