diff --git a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_pager_full.yml b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_pager_full.yml index 68dae03..61cf077 100644 --- a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_pager_full.yml +++ b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_pager_full.yml @@ -26,6 +26,30 @@ display: items_per_page: 5 offset: 0 type: full + header: + area_text_custom: + id: area_text_custom + table: views + field: area_text_custom + relationship: none + group_type: group + admin_label: '' + empty: true + content: 'Test header text' + tokenize: false + plugin_id: text_custom + footer: + area_text_custom: + id: area_text_custom + table: views + field: area_text_custom + relationship: none + group_type: group + admin_label: '' + empty: true + content: 'Test footer text' + tokenize: false + plugin_id: text_custom style: type: default row: diff --git a/core/modules/views_ui/src/Tests/PreviewTest.php b/core/modules/views_ui/src/Tests/PreviewTest.php index ff10213..78f21f3 100644 --- a/core/modules/views_ui/src/Tests/PreviewTest.php +++ b/core/modules/views_ui/src/Tests/PreviewTest.php @@ -41,8 +41,6 @@ public function testPreviewContextual() { // Test that area text and exposed filters are present and rendered. $this->assertFieldByName('id', NULL, 'ID exposed filter field found.'); - $this->assertText('Test header text', 'Rendered header text found'); - $this->assertText('Test footer text', 'Rendered footer text found.'); $this->assertText('Test empty text', 'Rendered empty text found.'); } @@ -72,8 +70,6 @@ function testPreviewUI() { // Test that area text and exposed filters are present and rendered. $this->assertFieldByName('id', NULL, 'ID exposed filter field found.'); - $this->assertText('Test header text', 'Rendered header text found'); - $this->assertText('Test footer text', 'Rendered footer text found.'); $this->assertText('Test empty text', 'Rendered empty text found.'); // Test feed preview. @@ -93,6 +89,35 @@ function testPreviewUI() { } /** + * Header and footer texts should only be shown when there is content. + */ + public function testHeaderFooterText() { + // Create content type. + $this->drupalCreateContentType(['type' => 'page']); + + // Header and footer texts should not be shown. + $this->getPreviewAJAX('test_pager_full', 'default', 0); + $this->assertResponse(200); + + $this->drupalPostForm(NULL, $edit = [], t('Update preview')); + $this->assertResponse(200); + + $this->assertNoText('Test header text', 'Rendered header text found.'); + $this->assertNoText('Test footer text', 'Rendered footer text found.'); + + // Create a node. + $this->drupalCreateNode(); + + // Header and footer texts should be shown. + $this->getPreviewAJAX('test_pager_full', 'default', 1); + $this->assertResponse(200); + $this->drupalPostForm(NULL, $edit = [], t('Update preview')); + $this->assertResponse(200); + $this->assertText('Test header text', 'Rendered header text found.'); + $this->assertText('Test footer text', 'Rendered footer text found.'); + } + + /** * Tests the taxonomy term preview AJAX. * * This tests a specific regression in the taxonomy term view preview.