diff --git a/core/modules/file/tests/src/FunctionalJavascript/ClientValidationTest.php b/core/modules/file/tests/src/FunctionalJavascript/ClientValidationTest.php new file mode 100644 index 0000000..b4f5593 --- /dev/null +++ b/core/modules/file/tests/src/FunctionalJavascript/ClientValidationTest.php @@ -0,0 +1,48 @@ +drupalCreateUser([ + 'create article content', + 'administer site configuration', + ]); + $this->drupalLogin($admin_user); + + $this->drupalGet('node/add/article'); + $page = $this->getSession()->getPage(); + + // Test uploading a file with a file extension not allowed. + // Try to upload a file with an unallowed extension + + // @TODO http://phantomjs.org/api/webpage/method/upload-file.html + // page.uploadFile('input[name=image]', '/path/to/some/photo.jpg'); + + // Verify that the error message is there. + $error_selector = '.file-upload-js-error'; + $assert = $this->assertSession(); + $assert->elementExists('css', $error_selector); + $assert->elementContains('css', $error_selector, 'The selected file robots.txt cannot be uploaded. Only files with the following extensions are allowed: png, gif, jpg, jpeg.'); + // Verify that there is only one error message on the page. + $condition = "(jQuery('$error_selector').length == 1)"; + $assert->assertJsCondition($condition); + } + +}