Commit 1bf5a17b authored by Nikola Stojiljkovic's avatar Nikola Stojiljkovic Committed by Christian Kuhn
Browse files

[TASK] Tweak of the Formhandler acceptance tests

Includes:
* Added testing of persistence
* Added tests for datetime fields
* Prevent random timeouts from affecting the test results
* Added displaying of modal with error message instead of an alert
  on trying to save a form with validation errors

The tests are stable using Selenium with Firefox. Using phantomjs gives
erratic results due to "QIODevice::write (QTcpSocket): device not open"
bug which randomly pops up.

Resolves: #76122
Releases: master
Change-Id: Ia0c06fc4dbd83e2373d33bb07c48559894fc3ec5
Reviewed-on: https://review.typo3.org/48068


Reviewed-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent 24b61262
......@@ -131,13 +131,15 @@ define(['jquery', 'TYPO3/CMS/Backend/FormEngine'], function ($, FormEngine) {
$humanReadableField.val(value);
}
}
$humanReadableField.data('main-field', fieldName);
$humanReadableField.data('config', config);
$humanReadableField.on('change', function() {
FormEngineValidation.updateInputField($(this).attr('data-formengine-input-name'));
});
$humanReadableField.on('keyup', FormEngineValidation.validate);
// add the attribute so that acceptance tests can know when the field initialization has completed
$humanReadableField.attr('data-formengine-input-initialized', 'true');
};
/**
......
......@@ -226,7 +226,24 @@ var TBE_EDITOR = {
if (OK || sendAlert==-1) {
return true;
} else {
if (sendAlert) alert(TBE_EDITOR.labels.fieldsMissing);
if (sendAlert) {
var t = (opener != null && typeof opener.top.TYPO3 !== 'undefined' ? opener.top : top);
t.TYPO3.Modal.confirm(
t.TYPO3.lang['alert'] || 'Alert',
TBE_EDITOR.labels.fieldsMissing,
t.TYPO3.Severity.error,
[
{
text: t.TYPO3.lang['button.ok'] || 'OK',
active: true,
btnClass: 'btn-default',
name: 'ok'
}
]
).on('button.clicked', function(e) {
t.TYPO3.Modal.dismiss();
});
}
return false;
}
},
......
......@@ -44,217 +44,427 @@ class ElementsBasicCest
*/
public function checkThatBrowserSideValidationsWorkAndSaveRecord(Admin $I, Formhandler $formhandler)
{
$I->click(self::$listViewRecordSelector . ' a[data-original-title="Edit record"]');
$editRecordLinkCssPath = self::$listViewRecordSelector . ' a[data-original-title="Edit record"]';
$I->waitForElement($editRecordLinkCssPath, 30);
$I->click($editRecordLinkCssPath);
$I->waitForText('Edit Form', 3, 'h1');
$fieldTests = [
'input_1' => [
[
'This is a demo text with 2 numbers #!',
'This is a demo text with 2 numbers #!',
],
'tests' => [
[
'This is a demo text with 2 numbers #!',
'This is a demo text with 2 numbers #!',
],
],
'cleared' => [
''
]
],
'input_2, size=10' => [
[
'This is a demo text with 2 numbers #!',
'This is a demo text with 2 numbers #!',
],
'tests' => [
[
'This is a demo text with 2 numbers #!',
'This is a demo text with 2 numbers #!',
],
],
'cleared' => [
''
]
],
'input_3 max=4' => [
[
'Kasper',
'Kasp',
],
'tests' => [
[
'Kasper',
'Kasp',
],
],
'cleared' => [
''
]
],
'input_4 eval=alpha' => [
[
'Kasper = TYPO3',
'KasperTYPO',
],
'tests' => [
[
'Kasper = TYPO3',
'KasperTYPO',
],
[
'Non-latin characters: ŠĐŽĆČ',
'Nonlatincharacters',
],
],
'cleared' => [
''
]
],
'input_5 eval=alphanum' => [
[
'Kasper = TYPO3',
'KasperTYPO3',
],
'tests' => [
[
'Kasper = TYPO3',
'KasperTYPO3',
],
],
'cleared' => [
''
]
],
'input_6 eval=date' => [
[
'29-01-2016',
'29-01-2016',
'1454025600',
],
[
'13-13-2016',
'13-01-2017',
'1484265600',
],
'check valid leap year input' => [
'29-02-2016',
'29-02-2016',
'1456704000',
],
'check invalid leap year transformation' => [
'29-02-2015',
'01-03-2015',
'1425168000',
],
'tests' => [
[
'29-01-2016',
'29-01-2016',
'1454025600',
],
[
'13-13-2016',
'13-01-2017',
'1484265600',
],
[
'29-02-2016',
'29-02-2016',
'1456704000',
false,
'Check valid leap year input'
],
[
'29-02-2015',
'01-03-2015',
'1425168000',
false,
'Check invalid leap year transformation'
],
],
'cleared' => [
'0'
]
],
'input_36 dbType=date eval=date' => [
'tests' => [
[
'29-01-2016',
'29-01-2016',
'1454025600',
],
[
'13-13-2016',
'13-01-2017',
'1484265600',
],
[
'29-02-2016',
'29-02-2016',
'1456704000',
false,
'Check valid leap year input'
],
[
'29-02-2015',
'01-03-2015',
'1425168000',
false,
'Check invalid leap year transformation'
],
],
'cleared' => [
'0'
]
],
'input_7 eval=datetime' => [
'tests' => [
[
'05:23 29-01-2016',
'05:23 29-01-2016',
'1454044980',
],
[
'05:23 13-13-2016',
'05:23 13-01-2017',
'1484284980',
],
[
'05:23 29-02-2016',
'05:23 29-02-2016',
'1456723380',
false,
'Check valid leap year input'
],
[
'05:23 29-02-2015',
'05:23 01-03-2015',
'1425187380',
false,
'Check invalid leap year transformation'
],
],
'cleared' => [
'0'
]
],
'input_37 dbType=datetime eval=datetime' => [
'tests' => [
[
'05:23 29-01-2016',
'05:23 29-01-2016',
'1454044980',
],
[
'05:23 13-13-2016',
'05:23 13-01-2017',
'1484284980',
],
[
'05:23 29-02-2016',
'05:23 29-02-2016',
'1456723380',
false,
'Check valid leap year input'
],
[
'05:23 29-02-2015',
'05:23 01-03-2015',
'1425187380',
false,
'Check invalid leap year transformation'
],
],
'cleared' => [
'0'
]
],
'input_8 eval=double2' => [
[
'12.335',
'12.34',
],
[
'12,335',
'12.34',
],
[
'1.1',
'1.10',
],
[
'TYPO3',
'3.00',
],
[
'3TYPO',
'3.00',
],
'tests' => [
[
'12.335',
'12.34',
'12.34',
],
[
'12,335',
'12.34',
'12.34',
],
[
'1.1',
'1.10',
'1.10',
],
[
'TYPO3',
'3.00',
'3.00',
],
[
'3TYPO',
'3.00',
'3.00',
],
],
// @todo: add support for null values to the core
'cleared' => [
'0.00',
'0.00',
]
],
'input_9 eval=int' => [
[
'12.335',
'12',
],
[
'12,9',
'12',
],
[
'TYPO3',
'tests' => [
[
'12.335',
'12',
'12',
],
[
'12,9',
'12',
'12',
],
[
'TYPO3',
'0',
'0',
],
[
'3TYPO',
'3',
'3',
],
],
// @todo: add support for null values to the core
'cleared' => [
'0',
],
[
'3TYPO',
'3',
],
'0',
]
],
'input_10 eval=is_in, is_in=abc123' => [
[
'abcd1234',
'abc123',
],
[
'Kasper TYPO3',
'a3',
],
'tests' => [
[
'abcd1234',
'abc123',
],
[
'Kasper TYPO3',
'a3',
],
],
'cleared' => [
'',
]
],
'input_11 eval=lower' => [
[
'Kasper TYPO3!',
'kasper typo3!',
],
'tests' => [
[
'Kasper TYPO3!',
'kasper typo3!',
],
],
'cleared' => [
'',
]
],
'input_12 eval=md5' => [
[
'Kasper TYPO3!',
'748469dd64911af8df8f9a3dcb2c9378',
],
'check that whitespace is not trimmed' => [
'Kasper TYPO3! ',
'265e09df9b9b08ab1f946510f510d3ef',
],
'tests' => [
[
'Kasper TYPO3!',
'748469dd64911af8df8f9a3dcb2c9378',
'748469dd64911af8df8f9a3dcb2c9378',
],
[
' Kasper TYPO3! ',
'792a085606250c47d6ebb8c98804d5b0',
'792a085606250c47d6ebb8c98804d5b0',
false,
'Check that whitespaces are not trimmed.'
],
],
'cleared' => [
// @todo: add support for null values to the core
// cleared value currently keeps the previous value on save
'792a085606250c47d6ebb8c98804d5b0',
'792a085606250c47d6ebb8c98804d5b0'
]
],
'input_13 eval=nospace' => [
[
' Kasper TYPO3! ',
'KasperTYPO3!',
],
'tests' => [
[
' Kasper TYPO3! ',
'KasperTYPO3!',
],
],
'cleared' => [
'',
]
],
// @todo define test
//'input_14 eval=null' => [
//],
'input_15 eval=num' => [
[
'12.335',
'12335',
],
[
'12,9',
'129',
],
[
'TYPO3',
'3',
],
[
'3TYPO',
'3',
],
'tests' => [
[
'12.335',
'12335',
],
[
'12,9',
'129',
],
[
'TYPO3',
'3',
],
[
'3TYPO',
'3',
],
],
'cleared' => [
'',
]
],
'input_16 eval=password' => [
[
'Kasper',
'********',
'Kasper',
],
'tests' => [
[
'Kasper',
'********',
'Kasper',
],
],
'cleared' => [
'',
]
],
'input_17 eval=time' => [
[
'13:30',
'13:30',
'48600',
],
[
'123',
'12:03',
'43380',
],
[
'12345',
'12:34',
'45240',
],
[
'12:04+5',
'12:09',
'43740',
],
[
'12:09-3',
'12:06',
'43560',
'tests' => [
[
'13:30',
'13:30',
'48600',
],
[
'123',
'12:03',
'43380',
],
[
'12345',
'12:34',
'45240',
],
[
'12:04+5',
'12:09',
'43740',
],
[
'12:09-3',
'12:06',
'43560',
]
],
'cleared' => [
'0',
'00:00',
]
],
'input_18 eval=timesec' => [
[
'13:30:00',
'13:30:00',
'48600',
],
[
'12345',
'12:34:05',
'45245',
],
[
// @todo is that the expected behavior?
'12:04:04+5',