‪TYPO3CMS  11.5
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 
20 use Codeception\Scenario;
23 
28 {
32  public function ‪fileCrud(‪ApplicationTester $I, ‪ModalDialog $modalDialog, Scenario $scenario): void
33  {
34  $fileTextareaSelector = 'textarea[name="data[editfile][0][data]"]';
35  $codeMirrorSelector = 'typo3-t3editor-codemirror[name="data[editfile][0][data]"]';
36  $isComposerMode = str_contains($scenario->current('env'), 'composer');
37 
38  $fileName = 'typo3-test.txt';
39  $flashMessageSelector = '.typo3-messages';
40 
41  // Create file
42  $I->amGoingTo('create a file with content');
43  $I->click('.module-docheader .btn[title="New"]');
44  $I->wait(0.2);
45  $I->see('New file or folder', 'h1');
46  $I->fillField('#newfile', $fileName);
47  $I->wait(0.2);
48  $I->click('Create file');
49  $I->see('File created:', $flashMessageSelector);
50  if ($isComposerMode) {
51  $I->waitForElementVisible($codeMirrorSelector);
52  $I->executeJS("document.querySelector('" . $codeMirrorSelector . "').setContent('Some Text')");
53  } else {
54  $I->fillField($fileTextareaSelector, 'Some Text');
55  }
56 
57  // Save file
58  $I->amGoingTo('save the file');
59  $I->click('.module-docheader button[name="_save"]');
60  if ($isComposerMode) {
61  $I->waitForElementVisible($codeMirrorSelector);
62  $I->executeJS("console.assert(document.querySelector('" . $codeMirrorSelector . "').getContent() === 'Some Text')");
63  } else {
64  $textareaValue = $I->grabValueFrom($fileTextareaSelector);
65  $I->assertEquals('Some Text', $textareaValue);
66  }
67  $I->see('File saved to', $flashMessageSelector);
68 
69  // Save file
70  $I->amGoingTo('close the file and return to the list view');
71  $I->click('.module-docheader .btn[title="Cancel"]');
72  $I->see($fileName, '.col-title');
73 
74  // Delete file
75  $I->amGoingTo('delete the file');
76  $I->click('a[data-identifier="1:/' . $fileName . '"]');
77  $modalDialog->‪canSeeDialog();
78  $modalDialog->‪clickButtonInDialog('Yes, delete this file');
79  $I->waitForElementNotVisible('a[data-identifier="1:/' . $fileName . '"]');
80  $I->switchToContentFrame();
81  $I->see('File deleted', $flashMessageSelector);
82  $I->dontSee($fileName, '.col-title');
83  }
84 
89  public function ‪seeUploadFile(‪ApplicationTester $I): void
90  {
91  $alertContainer = '#alert-container';
92  $fileName = 'blue_mountains.jpg';
93  $this->‪uploadFile($I, $fileName);
94 
95  $I->switchToMainFrame();
96  $I->waitForText($fileName, 10, $alertContainer);
97  $I->click('.close', $alertContainer);
98  $I->waitForText('Reload filelist', 10, $alertContainer);
99  $I->click('a[title="Dismiss"]', $alertContainer);
100  $I->switchToContentFrame();
101  $I->see($fileName, '.upload-queue-item');
102  $I->click('a[title="Reload"]');
103  $I->see($fileName, '.responsive-title');
104  }
105 }
‪TYPO3\CMS\Core\Tests\Acceptance\Application\FileList\FileOperationsCest\fileCrud
‪fileCrud(ApplicationTester $I, ModalDialog $modalDialog, Scenario $scenario)
Definition: FileOperationsCest.php:32
‪TYPO3\CMS\Core\Tests\Acceptance\Application\FileList\FileOperationsCest
Definition: FileOperationsCest.php:28
‪TYPO3\CMS\Core\Tests\Acceptance\Support\ApplicationTester
Definition: ApplicationTester.php:27
‪TYPO3\CMS\Core\Tests\Acceptance\Application\FileList
Definition: AbstractFileCest.php:18
‪TYPO3\CMS\Core\Tests\Acceptance\Application\FileList\AbstractFileCest\uploadFile
‪uploadFile(ApplicationTester $I, string $name)
Definition: AbstractFileCest.php:45
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\ModalDialog\canSeeDialog
‪canSeeDialog()
Definition: ModalDialog.php:73
‪TYPO3\CMS\Core\Tests\Acceptance\Application\FileList\FileOperationsCest\seeUploadFile
‪seeUploadFile(ApplicationTester $I)
Definition: FileOperationsCest.php:89
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\ModalDialog\clickButtonInDialog
‪clickButtonInDialog(string $buttonLinkLocator)
Definition: ModalDialog.php:62
‪TYPO3\CMS\Core\Tests\Acceptance\Application\FileList\AbstractFileCest
Definition: AbstractFileCest.php:29
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\ModalDialog
Definition: ModalDialog.php:27