.../FunctionalJavascript/BigPipeRegressionTest.php | 56 +++++++++++++++++++--- .../Functional/Render/PlaceholderMessageTest.php | 8 ++-- 2 files changed, 54 insertions(+), 10 deletions(-) diff --git a/core/modules/big_pipe/tests/src/FunctionalJavascript/BigPipeRegressionTest.php b/core/modules/big_pipe/tests/src/FunctionalJavascript/BigPipeRegressionTest.php index ab28073..addda90 100644 --- a/core/modules/big_pipe/tests/src/FunctionalJavascript/BigPipeRegressionTest.php +++ b/core/modules/big_pipe/tests/src/FunctionalJavascript/BigPipeRegressionTest.php @@ -6,6 +6,7 @@ use Drupal\comment\Entity\Comment; use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; use Drupal\comment\Tests\CommentTestTrait; +use Drupal\Core\Url; use Drupal\editor\Entity\Editor; use Drupal\filter\Entity\FilterFormat; use Drupal\FunctionalJavascriptTests\JavascriptTestBase; @@ -27,13 +28,7 @@ class BigPipeRegressionTest extends JavascriptTestBase { * {@inheritdoc} */ public static $modules = [ - 'node', - 'comment', 'big_pipe', - 'history', - 'editor', - 'ckeditor', - 'filter', ]; /** @@ -53,6 +48,14 @@ public function setUp() { * @see https://www.drupal.org/node/2698811 */ public function testCommentForm_2698811() { + $this->assertTrue($this->container->get('module_installer')->install([ 'node', + 'comment', + 'history', + 'editor', + 'ckeditor', + 'filter', + ], TRUE), 'Installed modules.'); + // Ensure an `article` node type exists. $this->createContentType(['type' => 'article']); $this->addDefaultCommentField('node', 'article'); @@ -114,4 +117,45 @@ public function testCommentForm_2698811() { $this->assertJsCondition($javascript); } + /** + * Ensure BigPipe renders the "messages" placeholder last. + * + * @see https://www.drupal.org/node/2712935 + */ + public function testMessages_2712935() { + $this->assertTrue($this->container->get('module_installer')->install(['render_placeholder_message_test'], TRUE), 'Installed modules.'); + + $this->drupalLogin($this->drupalCreateUser()); + $messages_markup = '
assertSession(); + foreach ($test_routes as $route) { + // Verify that we start off with zero messages queued. + $this->drupalGet(Url::fromRoute('render_placeholder_message_test.queued')); + $assert->responseNotContains($messages_markup); + + // Verify the test case at this route behaves as expected. + $this->drupalGet(Url::fromRoute($route)); + $assert->elementContains('css', 'p.logged-message:nth-of-type(1)', 'Message: P1'); + $assert->elementContains('css', 'p.logged-message:nth-of-type(2)', 'Message: P2'); + $assert->responseContains($messages_markup); + $assert->elementExists('css', 'div[aria-label="Status message"] ul'); + $assert->elementContains('css', 'div[aria-label="Status message"] ul li:nth-of-type(1)', 'P1'); + $assert->elementContains('css', 'div[aria-label="Status message"] ul li:nth-of-type(2)', 'P2'); + + // Verify that we end with all messages printed, hence again zero queued. + $this->drupalGet(Url::fromRoute('render_placeholder_message_test.queued')); + $assert->responseNotContains($messages_markup); + } + } + } diff --git a/core/modules/system/tests/src/Functional/Render/PlaceholderMessageTest.php b/core/modules/system/tests/src/Functional/Render/PlaceholderMessageTest.php index 8ededd1..185ca49 100644 --- a/core/modules/system/tests/src/Functional/Render/PlaceholderMessageTest.php +++ b/core/modules/system/tests/src/Functional/Render/PlaceholderMessageTest.php @@ -23,7 +23,7 @@ class PlaceholderMessageTest extends BrowserTestBase { * Test rendering of message placeholder. */ public function testMessagePlaceholder() { - $messages_markup = '