From 58c44e3885d232354a9104bfa47f974d5425afbe Mon Sep 17 00:00:00 2001 From: Anja Leichsenring <aleichsenring@ab-softlab.de> Date: Thu, 26 Mar 2020 20:55:25 +0100 Subject: [PATCH] [TASK] Bring back datetime related acceptance tests for FormEngine The test have been disabled due to flakiness, let's give them another chance to prove themselves valuable. Resolves: #79730 Releases: master, 9.5 Change-Id: I8f0f64971438effb4b8baa62819d44c2920742de Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/63937 Tested-by: TYPO3com <noreply@typo3.com> Tested-by: Benni Mack <benni@typo3.org> Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de> Reviewed-by: Benni Mack <benni@typo3.org> Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de> --- .../FormEngine/AbstractElementsBasicCest.php | 38 ++- .../FormEngine/ElementsBasicInputDateCest.php | 231 ++++++++---------- 2 files changed, 138 insertions(+), 131 deletions(-) diff --git a/typo3/sysext/core/Tests/Acceptance/Backend/FormEngine/AbstractElementsBasicCest.php b/typo3/sysext/core/Tests/Acceptance/Backend/FormEngine/AbstractElementsBasicCest.php index b689d3d49081..bbae6d78f5c6 100644 --- a/typo3/sysext/core/Tests/Acceptance/Backend/FormEngine/AbstractElementsBasicCest.php +++ b/typo3/sysext/core/Tests/Acceptance/Backend/FormEngine/AbstractElementsBasicCest.php @@ -16,6 +16,7 @@ namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\FormEngine; */ use Codeception\Example; +use Facebook\WebDriver\Exception\UnknownErrorException; use Facebook\WebDriver\Remote\RemoteWebDriver; use Facebook\WebDriver\Remote\RemoteWebElement; use Facebook\WebDriver\WebDriverKeys; @@ -31,6 +32,7 @@ abstract class AbstractElementsBasicCest * * @param BackendTester $I * @param Example $testData + * @throws \Exception */ protected function runInputFieldTest(BackendTester $I, Example $testData) { @@ -52,8 +54,8 @@ abstract class AbstractElementsBasicCest $I->fillField($inputField, $testData['inputValue']); // Change focus to trigger validation $inputField->sendKeys(WebDriverKeys::TAB); - // Click on the div so that any opened popup (potentially from the field below) is closed - $formSection->click(); + // Press ESC so that any opened popup (potentially from the field below) is closed + $inputField->sendKeys(WebDriverKeys::ESCAPE); $I->waitForElementNotVisible('#t3js-ui-block'); $I->comment('Test value of visible and hidden field'); @@ -123,4 +125,36 @@ abstract class AbstractElementsBasicCest } ); } + + /** + * @param BackendTester $I + * @param string $tabTitle the tab you want to click. If necessary, several attempts are made + * @param string $referenceField one field that is available to receive a click. Will be used to scroll up from there. + */ + protected function ensureTopOfFrameIsUsedAndClickTab(BackendTester $I, string $tabTitle, string $referenceField) + { + try { + $I->click($tabTitle); + } catch (UnknownErrorException $exception) { + // this is fired if the element can't be clicked, because for example another element overlays it. + $this->scrollToTopOfFrame($I, $tabTitle, $referenceField); + } + } + + protected function scrollToTopOfFrame(BackendTester $I, string $tabTitle, string $referenceField) + { + $formSection = $this->getFormSectionByFieldLabel($I, $referenceField); + $field = $this->getInputField($formSection); + $maxPageUp = 10; + do { + $doItAgain = false; + $maxPageUp--; + try { + $field->sendKeys(WebDriverKeys::PAGE_UP); + $I->click($tabTitle); + } catch (UnknownErrorException $exception) { + $doItAgain = true; + } + } while ($doItAgain === true && $maxPageUp > 0); + } } diff --git a/typo3/sysext/core/Tests/Acceptance/Backend/FormEngine/ElementsBasicInputDateCest.php b/typo3/sysext/core/Tests/Acceptance/Backend/FormEngine/ElementsBasicInputDateCest.php index 6cd081601ac5..fecafbca5720 100644 --- a/typo3/sysext/core/Tests/Acceptance/Backend/FormEngine/ElementsBasicInputDateCest.php +++ b/typo3/sysext/core/Tests/Acceptance/Backend/FormEngine/ElementsBasicInputDateCest.php @@ -29,6 +29,7 @@ class ElementsBasicInputDateCest extends AbstractElementsBasicCest * * @param BackendTester $I * @param PageTree $pageTree + * @throws \Exception */ public function _before(BackendTester $I, PageTree $pageTree) { @@ -43,7 +44,11 @@ class ElementsBasicInputDateCest extends AbstractElementsBasicCest $editRecordLinkCssPath = '#recordlist-tx_styleguide_elements_basic a[data-original-title="Edit record"]'; $I->click($editRecordLinkCssPath); $I->waitForElementNotVisible('#t3js-ui-block'); + $I->waitForText('Edit Form', 3, 'h1'); + // scroll up all the way to get a clean shot to the tab panel + $this->ensureTopOfFrameIsUsedAndClickTab($I, 'inputDateTime', 'input_23'); + $I->click('inputDateTime'); $I->waitForText('inputDateTime', 3); } @@ -55,40 +60,36 @@ class ElementsBasicInputDateCest extends AbstractElementsBasicCest { return [ [ - // @todo: breaks with too small browser size - 'label' => 'inputdatetime_2 dbType=date eval=date', + 'label' => 'inputdatetime_2', 'inputValue' => '29-01-2016', 'expectedValue' => '29-01-2016', 'expectedInternalValue' => '2016-01-29T00:00:00Z', 'expectedValueAfterSave' => '2016-01-29T00:00:00+00:00', - 'comment' => '', + 'comment' => 'inputdatetime_2 dbType=date eval=date simple input', ], [ - // @todo: breaks with too small browser size - 'label' => 'inputdatetime_2 dbType=date eval=date', + 'label' => 'inputdatetime_2', 'inputValue' => '13-13-2016', 'expectedValue' => '13-01-2017', 'expectedInternalValue' => '2017-01-13T00:00:00Z', 'expectedValueAfterSave' => '2017-01-13T00:00:00+00:00', - 'comment' => '', + 'comment' => 'inputdatetime_2 dbType=date eval=date month transformation', ], [ - // @todo: breaks with too small browser size - 'label' => 'inputdatetime_2 dbType=date eval=date', + 'label' => 'inputdatetime_2', 'inputValue' => '29-02-2016', 'expectedValue' => '29-02-2016', 'expectedInternalValue' => '2016-02-29T00:00:00Z', 'expectedValueAfterSave' => '2016-02-29T00:00:00+00:00', - 'comment' => 'Check valid leap year input', + 'comment' => 'inputdatetime_2 dbType=date eval=date Check valid leap year input', ], [ - // @todo: breaks with too small browser size - 'label' => 'inputdatetime_2 dbType=date eval=date', + 'label' => 'inputdatetime_2', 'inputValue' => '29-02-2015', 'expectedValue' => '01-03-2015', 'expectedInternalValue' => '2015-03-01T00:00:00Z', 'expectedValueAfterSave' => '2015-03-01T00:00:00+00:00', - 'comment' => 'Check invalid leap year transformation', + 'comment' => 'inputdatetime_2 dbType=date eval=date Check invalid leap year transformation', ], ]; } @@ -97,12 +98,12 @@ class ElementsBasicInputDateCest extends AbstractElementsBasicCest * @dataProvider dbTypeDateEvalDateDataProvider * @param BackendTester $I * @param Example $testData - * @todo fix these unstable tests + * @throws \Exception + */ public function dbTypeDateEvalDate(BackendTester $I, Example $testData) { $this->runInputFieldTest($I, $testData); } - */ /** * dbType date eval datetime data provider @@ -111,40 +112,36 @@ class ElementsBasicInputDateCest extends AbstractElementsBasicCest { return [ [ - // @todo: breaks with too small browser size - 'label' => 'inputdatetime_3 eval=datetime', + 'label' => 'inputdatetime_3', 'inputValue' => '05:23 29-01-2016', 'expectedValue' => '05:23 29-01-2016', 'expectedInternalValue' => '2016-01-29T05:23:00Z', 'expectedValueAfterSave' => '2016-01-29T05:23:00+00:00', - 'comment' => '', + 'comment' => 'inputdatetime_3 eval=datetime simple input', ], [ - // @todo: breaks with too small browser size - 'label' => 'inputdatetime_3 eval=datetime', + 'label' => 'inputdatetime_3', 'inputValue' => '05:23 13-13-2016', 'expectedValue' => '05:23 13-01-2017', 'expectedInternalValue' => '2017-01-13T05:23:00Z', 'expectedValueAfterSave' => '2017-01-13T05:23:00+00:00', - 'comment' => '', + 'comment' => 'inputdatetime_3 eval=datetime month transformation', ], [ - // @todo: breaks with too small browser size - 'label' => 'inputdatetime_3 eval=datetime', + 'label' => 'inputdatetime_3', 'inputValue' => '05:23 29-02-2016', 'expectedValue' => '05:23 29-02-2016', 'expectedInternalValue' => '2016-02-29T05:23:00Z', 'expectedValueAfterSave' => '2016-02-29T05:23:00+00:00', - 'comment' => 'Check valid leap year input', + 'comment' => 'inputdatetime_3 eval=datetime Check valid leap year input', ], [ - // @todo: breaks with too small browser size - 'label' => 'inputdatetime_3 eval=datetime', + 'label' => 'inputdatetime_3', 'inputValue' => '05:23 29-02-2015', 'expectedValue' => '05:23 01-03-2015', 'expectedInternalValue' => '2015-03-01T05:23:00Z', 'expectedValueAfterSave' => '2015-03-01T05:23:00+00:00', - 'comment' => 'Check invalid leap year transformation', + 'comment' => 'inputdatetime_3 eval=datetime Check invalid leap year transformation', ], ]; } @@ -153,12 +150,12 @@ class ElementsBasicInputDateCest extends AbstractElementsBasicCest * @dataProvider dbTypeDateEvalDatetimeDataProvider * @param BackendTester $I * @param Example $testData - * @todo fix these unstable tests + * @throws \Exception + */ public function dbTypeDateEvalDatetime(BackendTester $I, Example $testData) { $this->runInputFieldTest($I, $testData); } - */ /** * db type date eval time data provider @@ -167,49 +164,44 @@ class ElementsBasicInputDateCest extends AbstractElementsBasicCest { return [ [ - // @todo: breaks with too small browser size 'label' => 'inputdatetime_5', 'inputValue' => '13:30', 'expectedValue' => '13:30', 'expectedInternalValue' => '1970-01-01T13:30:00Z', 'expectedValueAfterSave' => '1970-01-01T13:30:00+00:00', - 'comment' => '', + 'comment' => 'inputdatetime_5 eval=time time input', ], [ - // @todo: breaks with too small browser size 'label' => 'inputdatetime_5', 'inputValue' => '123', 'expectedValue' => '12:03', 'expectedInternalValue' => '1970-01-01T12:03:00Z', 'expectedValueAfterSave' => '1970-01-01T12:03:00+00:00', - 'comment' => '', + 'comment' => 'inputdatetime_5 eval=time seconds input', ], [ - // @todo: breaks with too small browser size 'label' => 'inputdatetime_5', 'inputValue' => '12345', 'expectedValue' => '12:34', 'expectedInternalValue' => '1970-01-01T12:34:00Z', 'expectedValueAfterSave' => '1970-01-01T12:34:00+00:00', - 'comment' => '', + 'comment' => 'inputdatetime_5 eval=time overflow', ], [ - // @todo: breaks with too small browser size 'label' => 'inputdatetime_5', 'inputValue' => '12:04+5', 'expectedValue' => '12:09', 'expectedInternalValue' => '1970-01-01T12:09:00Z', 'expectedValueAfterSave' => '1970-01-01T12:09:00+00:00', - 'comment' => '', + 'comment' => 'inputdatetime_5 eval=time addition calculation', ], [ - // @todo: breaks with too small browser size 'label' => 'inputdatetime_5', 'inputValue' => '12:09-3', 'expectedValue' => '12:06', 'expectedInternalValue' => '1970-01-01T12:06:00Z', 'expectedValueAfterSave' => '1970-01-01T12:06:00+00:00', - 'comment' => '', + 'comment' => 'inputdatetime_5 eval=time subtraction calculation', ], ]; } @@ -218,106 +210,87 @@ class ElementsBasicInputDateCest extends AbstractElementsBasicCest * @dataProvider dbTypeDateEvalTimeDataProvider * @param BackendTester $I * @param Example $testData - * @todo fix these unstable tests + * @throws \Exception + */ public function dbTypeDateEvalTime(BackendTester $I, Example $testData) { $this->runInputFieldTest($I, $testData); } - */ /** - * @param BackendTester $I + * db type date eval time data provider */ - /* - public function checkThatValidationWorks_EvalDateTime_DbTypeDateTime(AcceptanceTester $I) + protected function dbTypeDateEvalTimeDataProvider_DbTypeDateTime() { - // @todo fix these unstable tests - $dataSets = [ - 'input_37 dbType=datetime eval=datetime' => [ - [ - 'inputValue' => '05:23 29-01-2016', - 'expectedValue' => '05:23 29-01-2016', - 'expectedInternalValue' => '2016-01-29T05:23:00Z', - 'expectedValueAfterSave' => '2016-01-29T05:23:00+00:00', - 'comment' => '', - ], - [ - 'inputValue' => '05:23 13-13-2016', - 'expectedValue' => '05:23 13-01-2017', - 'expectedInternalValue' => '2017-01-13T05:23:00Z', - 'expectedValueAfterSave' => '2017-01-13T05:23:00+00:00', - 'comment' => '', - ], - [ - 'inputValue' => '05:23 29-02-2016', - 'expectedValue' => '05:23 29-02-2016', - 'expectedInternalValue' => '2016-02-29T05:23:00Z', - 'expectedValueAfterSave' => '2016-02-29T05:23:00+00:00', - 'comment' => 'Check valid leap year input', - ], - [ - 'inputValue' => '05:23 29-02-2015', - 'expectedValue' => '05:23 01-03-2015', - 'expectedInternalValue' => '2015-03-01T05:23:00Z', - 'expectedValueAfterSave' => '2015-03-01T05:23:00+00:00', - 'comment' => 'Check invalid leap year transformation', - ], - ], - 'input_18 eval=timesec' => [ - [ - 'inputValue' => '13:30:00', - 'expectedValue' => '13:30:00', - 'expectedInternalValue' => '13:30:00', - 'expectedValueAfterSave' => (new \DateTime('13:30:00'))->getTimestamp(), - 'comment' => '', - ], - [ - 'inputValue' => '12345', - 'expectedValue' => '12:34:05', - 'expectedInternalValue' => '12:34:05', - 'expectedValueAfterSave' => (new \DateTime('12:34:05'))->getTimestamp(), - 'comment' => '', - ], - [ - 'inputValue' => '12:04:04+5', - 'expectedValue' => '12:09:04', - 'expectedInternalValue' => '12:09:04', - 'expectedValueAfterSave' => (new \DateTime('12:09:04'))->getTimestamp(), - 'comment' => '', - ], - ], - 'input_6 eval=date' => [ - [ - 'inputValue' => '29-01-2016', - 'expectedValue' => '29-01-2016', - 'expectedInternalValue' => '2016-01-29T00:00:00Z', - 'expectedValueAfterSave' => '2016-01-29T00:00:00+00:00', - 'comment' => '', - ], - [ - 'inputValue' => '13-13-2016', - 'expectedValue' => '13-01-2017', - 'expectedInternalValue' => '2017-01-13T00:00:00Z', - 'expectedValueAfterSave' => '2017-01-13T00:00:00+00:00', - 'comment' => '', - ], - [ - 'inputValue' => '29-02-2016', - 'expectedValue' => '29-02-2016', - 'expectedInternalValue' => '2016-02-29T00:00:00Z', - 'expectedValueAfterSave' => '2016-02-29T00:00:00+00:00', - 'comment' => 'Check valid leap year input', - ], - [ - 'inputValue' => '29-02-2015', - 'expectedValue' => '01-03-2015', - 'expectedInternalValue' => '2015-03-01T00:00:00Z', - 'expectedValueAfterSave' => '2015-03-01T00:00:00+00:00', - 'comment' => 'Check invalid leap year transformation', - ], - ], + return [ + + [ + 'label' => 'inputdatetime_4', + 'inputValue' => '05:23 29-01-2016', + 'expectedValue' => '05:23 29-01-2016', + 'expectedInternalValue' => '2016-01-29T05:23:00Z', + 'expectedValueAfterSave' => '2016-01-29T05:23:00+00:00', + 'comment' => 'inputdatetime_4 dbType=datetime eval=datetime no transformation', + ], + [ + 'label' => 'inputdatetime_4', + 'inputValue' => '05:23 13-13-2016', + 'expectedValue' => '05:23 13-01-2017', + 'expectedInternalValue' => '2017-01-13T05:23:00Z', + 'expectedValueAfterSave' => '2017-01-13T05:23:00+00:00', + 'comment' => 'inputdatetime_4 dbType=datetime eval=datetime next month', + ], + [ + 'label' => 'inputdatetime_4', + 'inputValue' => '05:23 29-02-2016', + 'expectedValue' => '05:23 29-02-2016', + 'expectedInternalValue' => '2016-02-29T05:23:00Z', + 'expectedValueAfterSave' => '2016-02-29T05:23:00+00:00', + 'comment' => 'inputdatetime_4 dbType=datetime eval=datetime Check valid leap year input', + ], + [ + 'label' => 'inputdatetime_4', + 'inputValue' => '05:23 29-02-2015', + 'expectedValue' => '05:23 01-03-2015', + 'expectedInternalValue' => '2015-03-01T05:23:00Z', + 'expectedValueAfterSave' => '2015-03-01T05:23:00+00:00', + 'comment' => 'inputdatetime_4 dbType=datetime eval=datetime Check invalid leap year transformation', + ], + [ + 'label' => 'inputdatetime_6', + 'inputValue' => '13:30:00', + 'expectedValue' => '13:30:00', + 'expectedInternalValue' => '1970-01-01T13:30:00Z', + 'expectedValueAfterSave' => '1970-01-01T13:30:00+00:00', + 'comment' => 'inputdatetime_6 eval=timesec as time', + ], + [ + 'label' => 'inputdatetime_6', + 'inputValue' => '12345', + 'expectedValue' => '12:34:05', + 'expectedInternalValue' => '1970-01-01T12:34:05Z', + 'expectedValueAfterSave' => '1970-01-01T12:34:05+00:00', + 'comment' => 'inputdatetime_6 eval=timesec as timestamp', + ], + [ + 'label' => 'inputdatetime_6', + 'inputValue' => '12:04:04+5', + 'expectedValue' => '12:09:04', + 'expectedInternalValue' => '1970-01-01T12:09:04Z', + 'expectedValueAfterSave' => '1970-01-01T12:09:04+00:00', + 'comment' => 'inputdatetime_6 eval=timesec additon input', + ], ]; - $this->runTests($I, $dataSets); } + + /** + * @dataProvider dbTypeDateEvalTimeDataProvider_DbTypeDateTime + * @param BackendTester $I + * @param Example $testData + * @throws \Exception */ + public function checkThatValidationWorks_EvalDateTime_DbTypeDateTime(BackendTester $I, Example $testData) + { + $this->runInputFieldTest($I, $testData); + } } -- GitLab