Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
966dca16
Commit
966dca16
authored
7 years ago
by
Lauri Timmanee
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#2917218
by vaplas: Test to prevent regression between quickedit and ckeditor
parent
8b236d91
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!7452
Issue #1797438. HTML5 validation is preventing form submit and not fully...
,
!789
Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/modules/quickedit/tests/src/FunctionalJavascript/FieldTest.php
+113
-0
113 additions, 0 deletions
...es/quickedit/tests/src/FunctionalJavascript/FieldTest.php
with
113 additions
and
0 deletions
core/modules/quickedit/tests/src/FunctionalJavascript/FieldTest.php
0 → 100644
+
113
−
0
View file @
966dca16
<?php
namespace
Drupal\Tests\quickedit\FunctionalJavascript
;
use
Drupal\editor\Entity\Editor
;
use
Drupal\filter\Entity\FilterFormat
;
use
Drupal\FunctionalJavascriptTests\JavascriptTestBase
;
use
Drupal\node\Entity\Node
;
use
Drupal\node\Entity\NodeType
;
use
Drupal\Tests\contextual\FunctionalJavascript\ContextualLinkClickTrait
;
/**
* Tests quickedit.
*
* @group quickedit
*/
class
FieldTest
extends
JavascriptTestBase
{
use
ContextualLinkClickTrait
;
/**
* {@inheritdoc}
*/
public
static
$modules
=
[
'node'
,
'ckeditor'
,
'contextual'
,
'quickedit'
,
];
/**
* {@inheritdoc}
*/
protected
function
setUp
()
{
parent
::
setUp
();
// Create a text format and associate CKEditor.
$filtered_html_format
=
FilterFormat
::
create
([
'format'
=>
'filtered_html'
,
'name'
=>
'Filtered HTML'
,
'weight'
=>
0
,
]);
$filtered_html_format
->
save
();
Editor
::
create
([
'format'
=>
'filtered_html'
,
'editor'
=>
'ckeditor'
,
])
->
save
();
// Create note type with body field.
$node_type
=
NodeType
::
create
([
'type'
=>
'page'
,
'name'
=>
'Page'
]);
$node_type
->
save
();
node_add_body_field
(
$node_type
);
$account
=
$this
->
drupalCreateUser
([
'access content'
,
'administer nodes'
,
'edit any page content'
,
'use text format filtered_html'
,
'access contextual links'
,
'access in-place editing'
,
]);
$this
->
drupalLogin
(
$account
);
}
/**
* Tests that quickeditor works correctly for field with CKEditor.
*/
public
function
testFieldWithCkeditor
()
{
$body_value
=
'<p>Sapere aude</p>'
;
$node
=
Node
::
create
([
'type'
=>
'page'
,
'title'
=>
'Page node'
,
'body'
=>
[[
'value'
=>
$body_value
,
'format'
=>
'filtered_html'
]],
]);
$node
->
save
();
$page
=
$this
->
getSession
()
->
getPage
();
$assert
=
$this
->
assertSession
();
$this
->
drupalGet
(
'node/'
.
$node
->
id
());
// Wait "Quick edit" button for node.
$this
->
assertSession
()
->
waitForElement
(
'css'
,
'[data-quickedit-entity-id="node/'
.
$node
->
id
()
.
'"] .contextual .quickedit'
);
// Click by "Quick edit".
$this
->
clickContextualLink
(
'[data-quickedit-entity-id="node/'
.
$node
->
id
()
.
'"]'
,
'Quick edit'
);
// Switch to body field.
$page
->
find
(
'css'
,
'[data-quickedit-field-id="node/'
.
$node
->
id
()
.
'/body/en/full"]'
)
->
click
();
// Wait and click by "Blockquote" button from editor for body field.
$this
->
assertSession
()
->
waitForElementVisible
(
'css'
,
'.cke_button.cke_button__blockquote'
)
->
click
();
// Wait and click by "Save" button after body field was changed.
$this
->
assertSession
()
->
waitForElementVisible
(
'css'
,
'.quickedit-toolgroup.ops [type="submit"][aria-hidden="false"]'
)
->
click
();
// Wait until the save occurs and the editor UI disappears.
$this
->
waitForNoElement
(
'.cke_button.cke_button__blockquote'
);
// Ensure that the changes take effect.
$assert
->
responseMatches
(
"|<blockquote>\s*
$body_value
\s*</blockquote>|"
);
}
/**
* Waits for an element to be removed from the page.
*
* @param string $selector
* CSS selector.
* @param int $timeout
* (optional) Timeout in milliseconds, defaults to 10000.
*/
protected
function
waitForNoElement
(
$selector
,
$timeout
=
10000
)
{
$condition
=
"(typeof jQuery !== 'undefined' && jQuery('
$selector
').length === 0)"
;
$this
->
assertJsCondition
(
$condition
,
$timeout
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment