Commit f78c13ed authored by Christian Kuhn's avatar Christian Kuhn
Browse files

[TASK] Clean up AC tests

* Cest files declared final
* Prefer private over protected
* Remove some skipped tests
* Method comment cleanups

testing-framework raise:
> composer u typo3/testing-framework:dev-main

Change-Id: I046cdc5c5d31ec63d8e056b5b9f288fba78a0f08
Resolves: #99674
Releases: main
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/77534


Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Tested-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Reviewed-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
parent 71fc29fc
......@@ -8891,12 +8891,12 @@
"source": {
"type": "git",
"url": "https://github.com/TYPO3/testing-framework.git",
"reference": "59c0550367dd2c8b7f52e8561f97c786cf886b2c"
"reference": "c64e8f59b803b75fe1d62ae97f19e662aad5d268"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/TYPO3/testing-framework/zipball/59c0550367dd2c8b7f52e8561f97c786cf886b2c",
"reference": "59c0550367dd2c8b7f52e8561f97c786cf886b2c",
"url": "https://api.github.com/repos/TYPO3/testing-framework/zipball/c64e8f59b803b75fe1d62ae97f19e662aad5d268",
"reference": "c64e8f59b803b75fe1d62ae97f19e662aad5d268",
"shasum": ""
},
"require": {
......@@ -8955,7 +8955,7 @@
"issues": "https://github.com/TYPO3/testing-framework/issues",
"source": "https://github.com/TYPO3/testing-framework/tree/main"
},
"time": "2022-12-01T15:20:14+00:00"
"time": "2023-01-23T12:45:28+00:00"
}
],
"aliases": [],
......
......@@ -22,7 +22,7 @@ use TYPO3\CMS\Core\Tests\Acceptance\Support\ApplicationTester;
/**
* Tests concerning the compare view of BE user module
*/
class CompareUserCest
final class CompareUserCest
{
public function _before(ApplicationTester $I): void
{
......
......@@ -22,7 +22,7 @@ use TYPO3\CMS\Core\Tests\Acceptance\Support\ApplicationTester;
/**
* Tests concerning the listing of BeUser groups
*/
class ListGroupCest
final class ListGroupCest
{
public function _before(ApplicationTester $I): void
{
......
......@@ -22,7 +22,7 @@ use TYPO3\CMS\Core\Tests\Acceptance\Support\ApplicationTester;
/**
* List User tests
*/
class ListUserCest
final class ListUserCest
{
public function _before(ApplicationTester $I): void
{
......
......@@ -23,19 +23,8 @@ use TYPO3\CMS\Core\Tests\Acceptance\Support\ApplicationTester;
/**
* Tests the styleguide backend module can be loaded
*/
class CommandCest
final class CommandCest
{
protected string $typo3Cli = '../../../../bin/typo3 ';
/**
* @dataProvider commandTestDataProvider
*/
public function runCommand(ApplicationTester $I, Example $testData): void
{
$I->runShellCommand($this->typo3Cli . $testData['command'], false);
$I->seeResultCodeIs($testData['code']);
}
/**
* Test cli commands for their exit status
*
......@@ -43,7 +32,7 @@ class CommandCest
* due to missing configuration or unpredictable
* params.
*/
protected function commandTestDataProvider(): array
private function commandTestDataProvider(): array
{
return [
['command' => 'cache:flush', 'code' => 0],
......@@ -70,4 +59,13 @@ class CommandCest
['command' => 'upgrade:list', 'code' => 0],
];
}
/**
* @dataProvider commandTestDataProvider
*/
public function runCommand(ApplicationTester $I, Example $testData): void
{
$I->runShellCommand('../../../../bin/typo3 ' . $testData['command'], false);
$I->seeResultCodeIs($testData['code']);
}
}
......@@ -22,7 +22,7 @@ use TYPO3\CMS\Core\Tests\Acceptance\Support\ApplicationTester;
/**
* Configuration module provider tests
*/
class ConfigurationModuleProviderCest
final class ConfigurationModuleProviderCest
{
public function _before(ApplicationTester $I): void
{
......@@ -79,7 +79,7 @@ class ConfigurationModuleProviderCest
}
}
protected function dropDownPagesDataProvider(): array
private function dropDownPagesDataProvider(): array
{
return [
'$GLOBALS[\'TYPO3_CONF_VARS\'] (Global Configuration)',
......
......@@ -23,13 +23,13 @@ use TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\ModalDialog;
/**
* Tests concerning Reports Module
*/
class DashboardModuleCest
final class DashboardModuleCest
{
protected static string $defaultDashboardTitle = 'My Dashboard';
protected static string $customDashboardTitle = 'My Custom Dashboard';
protected static string $dashboardActiveSelector = '.dashboard-tab--active';
protected static string $widgetTitle = 'Type of backend users';
protected static string $widgetTitleSelector = '.widget-content-title';
private static string $defaultDashboardTitle = 'My Dashboard';
private static string $customDashboardTitle = 'My Custom Dashboard';
private static string $dashboardActiveSelector = '.dashboard-tab--active';
private static string $widgetTitle = 'Type of backend users';
private static string $widgetTitleSelector = '.widget-content-title';
public function _before(ApplicationTester $I): void
{
......
......@@ -26,9 +26,9 @@ use TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\ModalDialog;
/**
* Tests concerning Reports Module
*/
class DbCheckModuleCest
final class DbCheckModuleCest
{
protected static string $defaultDashboardTitle = 'My Dashboard';
private static string $defaultDashboardTitle = 'My Dashboard';
public function _before(ApplicationTester $I): void
{
......@@ -37,6 +37,40 @@ class DbCheckModuleCest
$I->switchToContentFrame();
}
private function recordStatisticsDataProvider(): array
{
return [
[
'name' => 'Total number of default language pages',
'count' => 84,
],
[
'name' => 'Total number of translated pages',
'count' => 132,
],
[
'name' => 'Marked-deleted pages',
'count' => 0,
],
[
'name' => 'Hidden pages',
'count' => 1,
],
[
'name' => 'Standard',
'count' => 1,
],
[
'name' => 'Backend User Section',
'count' => 0,
],
[
'name' => 'Link to External URL',
'count' => 0,
],
];
}
/**
* @dataProvider recordStatisticsDataProvider
*/
......@@ -94,44 +128,7 @@ class DbCheckModuleCest
$I->see('Index integrity was perfect!', '.callout-success');
}
/**
* @return array[]
*/
protected function recordStatisticsDataProvider(): array
{
return [
[
'name' => 'Total number of default language pages',
'count' => 84,
],
[
'name' => 'Total number of translated pages',
'count' => 132,
],
[
'name' => 'Marked-deleted pages',
'count' => 0,
],
[
'name' => 'Hidden pages',
'count' => 1,
],
[
'name' => 'Standard',
'count' => 1,
],
[
'name' => 'Backend User Section',
'count' => 0,
],
[
'name' => 'Link to External URL',
'count' => 0,
],
];
}
protected function goToPageAndSeeHeadline(ApplicationTester $I, string $select, string $headline): void
private function goToPageAndSeeHeadline(ApplicationTester $I, string $select, string $headline): void
{
$I->selectOption('select[name=DatabaseJumpMenu]', $select);
$I->see($headline, 'h1');
......@@ -139,10 +136,8 @@ class DbCheckModuleCest
/**
* Find count of table row by name
*
* @param string $fieldLabel
*/
protected function getCountByRowName(ApplicationTester $I, string $rowName, int $sibling = 1): RemoteWebElement
private function getCountByRowName(ApplicationTester $I, string $rowName, int $sibling = 1): RemoteWebElement
{
$I->comment('Get context for table row "' . $rowName . '"');
return $I->executeInSelenium(
......
......@@ -23,7 +23,7 @@ use TYPO3\CMS\Core\Tests\Acceptance\Support\ApplicationTester;
/**
* Tests for the "Get Extensions view" of the extension manager
*/
class GetExtensionsCest
final class GetExtensionsCest
{
public function _before(ApplicationTester $I): void
{
......
......@@ -22,7 +22,7 @@ use TYPO3\CMS\Core\Tests\Acceptance\Support\ApplicationTester;
/**
* Tests for the "Install list view" of the extension manager
*/
class InstalledExtensionsCest
final class InstalledExtensionsCest
{
public function _before(ApplicationTester $I): void
{
......
<?php
declare(strict_types=1);
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
namespace TYPO3\CMS\Core\Tests\Acceptance\Application\FileList;
use Facebook\WebDriver\Remote\RemoteWebDriver;
use Facebook\WebDriver\Remote\RemoteWebElement;
use TYPO3\CMS\Core\Tests\Acceptance\Support\ApplicationTester;
use TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\FileTree;
/**
* Abstract class for file operations
*/
abstract class AbstractFileCest
{
public function _before(ApplicationTester $I, FileTree $tree): void
{
$I->useExistingSession('admin');
$I->amOnPage('/typo3/module/file/list');
$I->switchToContentFrame();
}
/**
* @throws \Exception
*/
protected function uploadFile(ApplicationTester $I, string $name): void
{
$I->attachFile('input.upload-file-picker', 'Acceptance/Fixtures/Images/' . $name);
$I->waitForElementNotVisible('.upload-queue-item .upload-queue-progress');
}
protected function openActionDropdown(ApplicationTester $I, string $title): RemoteWebElement
{
$I->comment('Get open action dropdown "' . $title . '"');
return $I->executeInSelenium(
static function (RemoteWebDriver $webDriver) use ($title) {
return $webDriver->findElement(
\Facebook\WebDriver\WebDriverBy::xpath(
'//a[contains(text(),"' . $title . '")]/parent::node()/parent::node()//a[contains(@href, "#actions_") and contains(@data-bs-toggle, "dropdown")]'
)
);
}
);
}
}
......@@ -17,15 +17,25 @@ declare(strict_types=1);
namespace TYPO3\CMS\Core\Tests\Acceptance\Application\FileList;
use Facebook\WebDriver\Remote\RemoteWebDriver;
use Facebook\WebDriver\Remote\RemoteWebElement;
use TYPO3\CMS\Core\Tests\Acceptance\Support\ApplicationTester;
use TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\FileTree;
/**
* Cases concerning sys_file_metadata records
*/
class FileClipboardCest extends AbstractFileCest
final class FileClipboardCest
{
protected string $copyModeCopy = '#clipboard-copymode-copy';
protected string $copyModeMove = '#clipboard-copymode-move';
private string $copyModeCopy = '#clipboard-copymode-copy';
private string $copyModeMove = '#clipboard-copymode-move';
public function _before(ApplicationTester $I, FileTree $tree): void
{
$I->useExistingSession('admin');
$I->amOnPage('/typo3/module/file/list');
$I->switchToContentFrame();
}
public function seeSwitchModes(ApplicationTester $I): void
{
......@@ -82,4 +92,18 @@ class FileClipboardCest extends AbstractFileCest
$I->dontSee($file, '.clipboard-panel');
}
}
private function openActionDropdown(ApplicationTester $I, string $title): RemoteWebElement
{
$I->comment('Get open action dropdown "' . $title . '"');
return $I->executeInSelenium(
static function (RemoteWebDriver $webDriver) use ($title) {
return $webDriver->findElement(
\Facebook\WebDriver\WebDriverBy::xpath(
'//a[contains(text(),"' . $title . '")]/parent::node()/parent::node()//a[contains(@href, "#actions_") and contains(@data-bs-toggle, "dropdown")]'
)
);
}
);
}
}
......@@ -22,7 +22,7 @@ use TYPO3\CMS\Core\Tests\Acceptance\Support\ApplicationTester;
/**
* Cases concerning sys_file_metadata records
*/
class FileMetaDataCest
final class FileMetaDataCest
{
public function _before(ApplicationTester $I): void
{
......
......@@ -18,13 +18,21 @@ declare(strict_types=1);
namespace TYPO3\CMS\Core\Tests\Acceptance\Application\FileList;
use TYPO3\CMS\Core\Tests\Acceptance\Support\ApplicationTester;
use TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\FileTree;
use TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\ModalDialog;
/**
* Cases concerning sys_file_metadata records
*/
class FileOperationsCest extends AbstractFileCest
final class FileOperationsCest
{
public function _before(ApplicationTester $I, FileTree $tree): void
{
$I->useExistingSession('admin');
$I->amOnPage('/typo3/module/file/list');
$I->switchToContentFrame();
}
public function fileCrud(ApplicationTester $I, ModalDialog $modalDialog): void
{
$fileTextareaSelector = 'textarea[name="data[editfile][0][data]"]';
......@@ -66,9 +74,6 @@ class FileOperationsCest extends AbstractFileCest
$I->dontSee($fileName, '[data-multi-record-selection-element="true"]');
}
/**
* @throws \Exception
*/
public function seeUploadFile(ApplicationTester $I): void
{
$alertContainer = '#alert-container';
......@@ -85,4 +90,10 @@ class FileOperationsCest extends AbstractFileCest
$I->click('a[title="Reload"]');
$I->see($fileName, '[data-multi-record-selection-element="true"]');
}
private function uploadFile(ApplicationTester $I, string $name): void
{
$I->attachFile('input.upload-file-picker', 'Acceptance/Fixtures/Images/' . $name);
$I->waitForElementNotVisible('.upload-queue-item .upload-queue-progress');
}
}
<?php
declare(strict_types=1);
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
namespace TYPO3\CMS\Core\Tests\Acceptance\Application\FileList;
use PHPUnit\Framework\SkippedTestError;
use TYPO3\CMS\Core\Tests\Acceptance\Support\ApplicationTester;
use TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\FileTree;
use TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\ModalDialog;
class FileStorageTreeFilterCest
{
protected string $openPath = '#typo3-filestoragetree .nodes > .node:first-child .node-toggle';
protected string $filterInputFieldClearButton = '#typo3-filestoragetree .tree-toolbar span[data-identifier=actions-close]';
protected string $filterInputField = '#typo3-filestoragetree .tree-toolbar .search-input';
protected string $withinTree = '#typo3-filestoragetree .nodes';
protected string $newSubfolder = 'random_subfolder';
public function _before(ApplicationTester $I, FileTree $tree): void
{
// Remove folder in case it already exists, to make sure we have a clean state
@unlink(__DIR__ . '/../../../../../../typo3temp/var/tests/acceptance/fileadmin/random_subfolder');
$I->useExistingSession('admin');
$I->click('Filelist');
$I->waitForElement('svg .nodes .node');
// @todo extend testing-frameworks AbstractPageTree.php:openPath to make it usable with the file tree.
$I->click($this->openPath);
$I->waitForElement($this->withinTree . ' .node', 5);
}
public function filterTreeForFolder(ApplicationTester $I, ModalDialog $modalDialog): void
{
throw new SkippedTestError('codeception cannot handle web components and modals are based on said.');
$this->createNewFolder($I, $modalDialog);
$I->fillField($this->filterInputField, 'styleguide');
$this->timeoutForAjaxRequest($I);
$I->amGoingTo('prove filter reset button is visible upon input');
$I->cantSee($this->newSubfolder, $this->withinTree);
$I->canSee('styleguide', $this->withinTree);
$this->reloadTree($I);
$this->timeoutForAjaxRequest($I);
// filter must still apply after tree reload
$I->amGoingTo('prove the filter applies after tree reload');
$I->cantSee($this->newSubfolder, $this->withinTree);
$I->seeInField($this->filterInputField, 'styleguide');
}
/**
* @todo: Method protected! This means the test is disabled.
*/
protected function clearFilterReloadsTreeWithoutFilterApplied(ApplicationTester $I): void
{
$I->fillField($this->filterInputField, 'styleguide');
$this->timeoutForAjaxRequest($I);
$I->canSee('styleguide', $this->withinTree);
$I->cantSee($this->newSubfolder, $this->withinTree);
$I->click($this->filterInputFieldClearButton);
$this->timeoutForAjaxRequest($I);
$I->canSee('styleguide', $this->withinTree);
$I->canSee($this->newSubfolder, $this->withinTree);
}
protected function clearTreeFilters(ApplicationTester $I): void
{
$I->click($this->filterInputFieldClearButton);
$this->reloadTree($I);
$I->cantSeeElement($this->filterInputFieldClearButton);
}
protected function timeoutForAjaxRequest(ApplicationTester $I): void
{
$I->wait(0.5);
}
protected function createNewFolder(ApplicationTester $I, ModalDialog $modalDialog): void
{
// Create a new folder
$I->switchToContentFrame();
$addButtonLink = '.btn-toolbar [title="Create Folder"]';
$I->waitForElement($addButtonLink, 30);
$I->click($addButtonLink);
$modalDialog->canSeeDialog();
$I->fillField('[name="data[newfolder][0][data]"]', $this->newSubfolder);
$I->click('form[name="editform"] input[type="submit"]');
$I->wait(5);
$I->switchToMainFrame();
}
protected function reloadTree($I)
{
$I->click('#typo3-filestoragetree .svg-toolbar__menuitem');
$I->click('#typo3-filestoragetree .dropdown-item [identifier="actions-refresh"]');
}
}
......@@ -20,6 +20,7 @@ namespace TYPO3\CMS\Core\Tests\Acceptance\Application\FormEngine;
use Codeception\Example;
use Facebook\WebDriver\Remote\RemoteWebDriver;
use Facebook\WebDriver\Remote\RemoteWebElement;
use Facebook\WebDriver\WebDriverBy;
use Facebook\WebDriver\WebDriverKeys;
use TYPO3\CMS\Core\Tests\Acceptance\Support\ApplicationTester;
......@@ -30,8 +31,6 @@ abstract class AbstractElementsBasicCest
{
/**
* Method to run basic elements input field test details
*
* @throws \Exception
*/
protected function runInputFieldTest(ApplicationTester $I, Example $testData): void
{
......@@ -85,7 +84,7 @@ abstract class AbstractElementsBasicCest
*/
protected function getInputField(RemoteWebElement $formSection): RemoteWebElement
{
return $formSection->findElement(\Facebook\WebDriver\WebDriverBy::xpath('.//*/input[@data-formengine-input-name]'));
return $formSection->findElement(WebDriverBy::xpath('.//*/input[@data-formengine-input-name]'));
}
/**
......@@ -94,7 +93,7 @@ abstract class AbstractElementsBasicCest
protected function getHiddenField(RemoteWebElement $formSection, RemoteWebElement $inputField): RemoteWebElement
{
$hiddenFieldXPath = './/*/input[@name="' . $inputField->getAttribute('data-formengine-input-name') . '"]';
return $formSection->findElement(\Facebook\WebDriver\WebDriverBy::xpath($hiddenFieldXPath));
return $formSection->findElement(WebDriverBy::xpath($hiddenFieldXPath));
}