Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
304
Merge Requests
304
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
e46168f2
Commit
e46168f2
authored
May 24, 2019
by
catch
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#3056536
by alexpott, tedbow: LayoutBuilderDisableInteractionsTest randomly fails
parent
a84d05f2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
13 deletions
+30
-13
core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php
...tionalJavascript/LayoutBuilderDisableInteractionsTest.php
+30
-13
No files found.
core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php
View file @
e46168f2
...
@@ -3,12 +3,12 @@
...
@@ -3,12 +3,12 @@
namespace
Drupal\Tests\layout_builder\FunctionalJavascript
;
namespace
Drupal\Tests\layout_builder\FunctionalJavascript
;
use
Behat\Mink\Element\NodeElement
;
use
Behat\Mink\Element\NodeElement
;
use
Behat\Mink\Exception\ElementHtmlException
;
use
Drupal\block_content
\
Entity\BlockContent
;
use
Drupal\block_content
\
Entity\BlockContent
;
use
Drupal\block_content
\
Entity\BlockContentType
;
use
Drupal\block_content
\
Entity\BlockContentType
;
use
Drupal\Component\Render\FormattableMarkup
;
use
Drupal\Component\Render\FormattableMarkup
;
use
Drupal\FunctionalJavascriptTests\WebDriverTestBase
;
use
Drupal\FunctionalJavascriptTests\WebDriverTestBase
;
use
Drupal\Tests\contextual\FunctionalJavascript\ContextualLinkClickTrait
;
use
Drupal\Tests\contextual\FunctionalJavascript\ContextualLinkClickTrait
;
use
WebDriver\Exception\UnknownError
;
/**
/**
* Tests the Layout Builder disables interactions of rendered blocks.
* Tests the Layout Builder disables interactions of rendered blocks.
...
@@ -73,7 +73,7 @@ protected function setUp() {
...
@@ -73,7 +73,7 @@ protected function setUp() {
'info'
=>
'Block with iframe'
,
'info'
=>
'Block with iframe'
,
'body'
=>
[
'body'
=>
[
// Add iframe that should be non-interactive in Layout Builder preview.
// Add iframe that should be non-interactive in Layout Builder preview.
'value'
=>
'<iframe id="iframe-that-should-be-disabled" width="
560" height="315
" src="https://www.youtube.com/embed/gODZzSOelss" frameborder="0"></iframe>'
,
'value'
=>
'<iframe id="iframe-that-should-be-disabled" width="
1" height="1
" src="https://www.youtube.com/embed/gODZzSOelss" frameborder="0"></iframe>'
,
'format'
=>
'full_html'
,
'format'
=>
'full_html'
,
],
],
])
->
save
();
])
->
save
();
...
@@ -83,6 +83,10 @@ protected function setUp() {
...
@@ -83,6 +83,10 @@ protected function setUp() {
* Tests that forms and links are disabled in the Layout Builder preview.
* Tests that forms and links are disabled in the Layout Builder preview.
*/
*/
public
function
testFormsLinksDisabled
()
{
public
function
testFormsLinksDisabled
()
{
// Resize window due to bug in Chromedriver when clicking on overlays over
// iFrames.
// @see https://bugs.chromium.org/p/chromedriver/issues/detail?id=2758
$this
->
getSession
()
->
resizeWindow
(
1200
,
1200
);
$assert_session
=
$this
->
assertSession
();
$assert_session
=
$this
->
assertSession
();
$page
=
$this
->
getSession
()
->
getPage
();
$page
=
$this
->
getSession
()
->
getPage
();
...
@@ -170,7 +174,7 @@ protected function assertElementUnclickable(NodeElement $element) {
...
@@ -170,7 +174,7 @@ protected function assertElementUnclickable(NodeElement $element) {
$tag_name
=
$element
->
getTagName
();
$tag_name
=
$element
->
getTagName
();
$this
->
fail
(
new
FormattableMarkup
(
"@tag_name was clickable when it shouldn't have been"
,
[
'@tag_name'
=>
$tag_name
]));
$this
->
fail
(
new
FormattableMarkup
(
"@tag_name was clickable when it shouldn't have been"
,
[
'@tag_name'
=>
$tag_name
]));
}
}
catch
(
UnknownError
$e
)
{
catch
(
\
Exception
$e
)
{
$this
->
assertContains
(
'is not clickable at point'
,
$e
->
getMessage
());
$this
->
assertContains
(
'is not clickable at point'
,
$e
->
getMessage
());
}
}
}
}
...
@@ -202,7 +206,7 @@ protected function assertContextualLinksClickable() {
...
@@ -202,7 +206,7 @@ protected function assertContextualLinksClickable() {
$this
->
clickContextualLink
(
'.block-field-blocknodebundle-with-section-fieldbody [data-contextual-id^="layout_builder_block"]'
,
'Configure'
);
$this
->
clickContextualLink
(
'.block-field-blocknodebundle-with-section-fieldbody [data-contextual-id^="layout_builder_block"]'
,
'Configure'
);
$this
->
assertNotEmpty
(
$assert_session
->
waitForElementVisible
(
'css'
,
'.ui-dialog-titlebar [title="Close"]'
));
$this
->
assertNotEmpty
(
$assert_session
->
waitForElementVisible
(
'css'
,
'.ui-dialog-titlebar [title="Close"]'
));
$page
->
pressButton
(
'Close'
);
$page
->
pressButton
(
'Close'
);
$this
->
assertNoElementAfterWait
(
'#drupal-off-canvas'
);
$this
->
assertNoElementAfterWait
(
'
css'
,
'
#drupal-off-canvas'
);
// Run the steps a second time after closing dialog, which reverses the
// Run the steps a second time after closing dialog, which reverses the
// order that behaviors.layoutBuilderDisableInteractiveElements and
// order that behaviors.layoutBuilderDisableInteractiveElements and
...
@@ -210,7 +214,7 @@ protected function assertContextualLinksClickable() {
...
@@ -210,7 +214,7 @@ protected function assertContextualLinksClickable() {
$this
->
clickContextualLink
(
'.block-field-blocknodebundle-with-section-fieldbody [data-contextual-id^="layout_builder_block"]'
,
'Configure'
);
$this
->
clickContextualLink
(
'.block-field-blocknodebundle-with-section-fieldbody [data-contextual-id^="layout_builder_block"]'
,
'Configure'
);
$this
->
assertNotEmpty
(
$assert_session
->
waitForElementVisible
(
'css'
,
'#drupal-off-canvas'
));
$this
->
assertNotEmpty
(
$assert_session
->
waitForElementVisible
(
'css'
,
'#drupal-off-canvas'
));
$page
->
pressButton
(
'Close'
);
$page
->
pressButton
(
'Close'
);
$this
->
assertNoElementAfterWait
(
'#drupal-off-canvas'
);
$this
->
assertNoElementAfterWait
(
'
css'
,
'
#drupal-off-canvas'
);
$this
->
assertContextualLinkRetainsMouseup
();
$this
->
assertContextualLinkRetainsMouseup
();
}
}
...
@@ -300,20 +304,33 @@ protected function movePointerTo($selector) {
...
@@ -300,20 +304,33 @@ protected function movePointerTo($selector) {
}
}
/**
/**
*
Waits for an element to be removed from the page
.
*
Asserts that no matching element exists on the page after a wait
.
*
*
* @param string $selector
* @param string $selector_type
* CSS selector.
* The element selector type (CSS, XPath).
* @param string|array $selector
* The element selector.
* @param int $timeout
* @param int $timeout
* (optional) Timeout in milliseconds, defaults to 10000.
* (optional) Timeout in milliseconds, defaults to 10000.
* @param string $message
* @param string $message
* (optional)
Custom message to display with the assertion
.
* (optional)
The exception message
.
*
*
* @todo: Remove after https://www.drupal.org/project/drupal/issues/2892440
* @throws \Behat\Mink\Exception\ElementHtmlException
* When an element still exists on the page.
*/
*/
public
function
assertNoElementAfterWait
(
$selector
,
$timeout
=
10000
,
$message
=
''
)
{
public
function
assertNoElementAfterWait
(
$selector_type
,
$selector
,
$timeout
=
10000
,
$message
=
'Element exists on the page.'
)
{
$condition
=
"(typeof jQuery !== 'undefined' && jQuery('
$selector
').length === 0)"
;
$start
=
microtime
(
TRUE
);
$this
->
assertJsCondition
(
$condition
,
$timeout
,
$message
);
$end
=
$start
+
(
$timeout
/
1000
);
$page
=
$this
->
getSession
()
->
getPage
();
do
{
$node
=
$page
->
find
(
$selector_type
,
$selector
);
if
(
empty
(
$node
))
{
return
;
}
usleep
(
100000
);
}
while
(
microtime
(
TRUE
)
<
$end
);
throw
new
ElementHtmlException
(
$message
,
$this
->
session
->
getDriver
(),
$node
);
}
}
}
}
catch
@catch
mentioned in commit
93c269ac
·
May 24, 2019
mentioned in commit
93c269ac
mentioned in commit 93c269ace861f9099ebbe6681f824709aea14c3e
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment