Issue #2650910 by drpal, Anishnirmal, markdorison, Tom Robert, psend, yannickoo, rachel_norfolk, Wim Leers, droplet: Contextual links button is always rendered even when no links are available (with warm client-side cache)
parent
956497377e
commit
488a6b142a
|
@ -163,7 +163,7 @@
|
|||
// Update all contextual links placeholders whose HTML is cached.
|
||||
var uncachedIDs = _.filter(ids, function initIfCached(contextualID) {
|
||||
var html = storage.getItem('Drupal.contextual.' + contextualID);
|
||||
if (html !== null) {
|
||||
if (html && html.length) {
|
||||
// Initialize after the current execution cycle, to make the AJAX
|
||||
// request for retrieving the uncached contextual links as soon as
|
||||
// possible, but also to ensure that other Drupal behaviors have had
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\contextual\FunctionalJavascript;
|
||||
|
||||
use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
|
||||
use Drupal\user\Entity\Role;
|
||||
|
||||
/**
|
||||
* Tests the UI for correct contextual links.
|
||||
*
|
||||
* @group contextual
|
||||
*/
|
||||
class ContextualLinksTest extends JavascriptTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['block', 'contextual'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->placeBlock('system_branding_block', ['id' => 'branding']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the visibility of contextual links.
|
||||
*/
|
||||
public function testContextualLinksVisibility() {
|
||||
$this->drupalLogin($this->drupalCreateUser([
|
||||
'access contextual links'
|
||||
]));
|
||||
|
||||
$this->drupalGet('user');
|
||||
$contextualLinks = $this->assertSession()->waitForElement('css', '.contextual button');
|
||||
$this->assertEmpty($contextualLinks);
|
||||
|
||||
// Ensure visibility remains correct after cached paged load.
|
||||
$this->drupalGet('user');
|
||||
$contextualLinks = $this->assertSession()->waitForElement('css', '.contextual button');
|
||||
$this->assertEmpty($contextualLinks);
|
||||
|
||||
// Grant permissions to use contextual links on blocks.
|
||||
$this->grantPermissions(Role::load(Role::AUTHENTICATED_ID), [
|
||||
'access contextual links',
|
||||
'administer blocks',
|
||||
]);
|
||||
|
||||
$this->drupalGet('user');
|
||||
$contextualLinks = $this->assertSession()->waitForElement('css', '.contextual button');
|
||||
$this->assertNotEmpty($contextualLinks);
|
||||
|
||||
// Ensure visibility remains correct after cached paged load.
|
||||
$this->drupalGet('user');
|
||||
$contextualLinks = $this->assertSession()->waitForElement('css', '.contextual button');
|
||||
$this->assertNotEmpty($contextualLinks);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue