From 761267415f3fecc4da1cd136cc828f5f572c84eb Mon Sep 17 00:00:00 2001 From: Mike Decker Date: Tue, 16 Jul 2024 13:01:43 -0700 Subject: [PATCH] D8CORE-7422 Write test for basic page list paragraph display sorts --- .../sync/views.view.stanford_basic_pages.yml | 107 ++++++++++-------- .../acceptance/Paragraphs/ListsCest.php | 55 ++++++++- 2 files changed, 115 insertions(+), 47 deletions(-) diff --git a/config/sync/views.view.stanford_basic_pages.yml b/config/sync/views.view.stanford_basic_pages.yml index 4ce162029..b9d761cf3 100644 --- a/config/sync/views.view.stanford_basic_pages.yml +++ b/config/sync/views.view.stanford_basic_pages.yml @@ -752,48 +752,9 @@ display: - 'config:field.storage.node.su_page_description' - 'config:field.storage.node.su_page_image' - 'config:field.storage.paragraph.su_banner_image' - viewfield_block_1: - id: viewfield_block_1 - display_title: 'Card Grid, Creation Date Sort (desc)' - display_plugin: viewfield_block - position: 2 - display_options: - display_extenders: { } - display_description: '' - style: - type: html_list - options: - row_class: '' - default_row_class: 1 - uses_fields: 0 - type: ul - wrapper_class: '' - class: 'su-list-unstyled grid-container-3' - defaults: - style: false - row: false - arguments: true - row: - type: 'entity:node' - options: - relationship: none - view_mode: stanford_h3_card - block_category: 'Basic Page Type Lists (Views)' - cache_metadata: - max-age: -1 - contexts: - - 'languages:language_content' - - 'languages:language_interface' - - url - - 'user.node_grants:view' - - user.permissions - tags: - - 'config:field.storage.node.su_page_description' - - 'config:field.storage.node.su_page_image' - - 'config:field.storage.paragraph.su_banner_image' - viewfield_block_1_graphql: - id: viewfield_block_1_graphql - display_title: 'GraphQL: Card Grid' + basic_page_types_graphql_alphabetical: + id: basic_page_types_graphql_alphabetical + display_title: 'GraphQL: Alphabetical Title' display_plugin: graphql position: 99 display_options: @@ -819,6 +780,22 @@ display: offset: true offset_label: offset quantity: 9 + sorts: + title: + id: title + table: node_field_revision + field: title + relationship: none + group_type: group + admin_label: '' + entity_type: node + entity_field: title + plugin_id: standard + order: ASC + expose: + label: '' + field_identifier: '' + exposed: false arguments: term_node_taxonomy_name_depth: id: term_node_taxonomy_name_depth @@ -868,10 +845,11 @@ display: defaults: style: false row: false + sorts: false arguments: false display_description: '' display_extenders: { } - graphql_query_name: stanfordBasicPagesCards + graphql_query_name: stanfordBasicPagesAlpha cache_metadata: max-age: -1 contexts: @@ -885,8 +863,8 @@ display: - 'config:field.storage.node.su_page_description' - 'config:field.storage.node.su_page_image' - 'config:field.storage.paragraph.su_banner_image' - viewfield_block_2: - id: viewfield_block_2 + card_grid_alpha: + id: card_grid_alpha display_title: 'Card Grid, Alphabetical Title Sort (asc)' display_plugin: viewfield_block position: 2 @@ -941,3 +919,42 @@ display: - 'config:field.storage.node.su_page_description' - 'config:field.storage.node.su_page_image' - 'config:field.storage.paragraph.su_banner_image' + viewfield_block_1: + id: viewfield_block_1 + display_title: 'Card Grid, Creation Date Sort (desc)' + display_plugin: viewfield_block + position: 2 + display_options: + display_extenders: { } + display_description: '' + style: + type: html_list + options: + row_class: '' + default_row_class: 1 + uses_fields: 0 + type: ul + wrapper_class: '' + class: 'su-list-unstyled grid-container-3' + defaults: + style: false + row: false + arguments: true + row: + type: 'entity:node' + options: + relationship: none + view_mode: stanford_h3_card + block_category: 'Basic Page Type Lists (Views)' + cache_metadata: + max-age: -1 + contexts: + - 'languages:language_content' + - 'languages:language_interface' + - url + - 'user.node_grants:view' + - user.permissions + tags: + - 'config:field.storage.node.su_page_description' + - 'config:field.storage.node.su_page_image' + - 'config:field.storage.paragraph.su_banner_image' diff --git a/tests/codeception/acceptance/Paragraphs/ListsCest.php b/tests/codeception/acceptance/Paragraphs/ListsCest.php index 3579cc37a..ce78b6492 100644 --- a/tests/codeception/acceptance/Paragraphs/ListsCest.php +++ b/tests/codeception/acceptance/Paragraphs/ListsCest.php @@ -753,6 +753,8 @@ public function testListParagraphPeopleFiltersTypeFilter(AcceptanceTester $I) { /** * Test basic page types list view. + * + * @group D8CORE-7422 */ public function testListParagraphBasicPageTypesFilter(AcceptanceTester $I) { $I->logInWithRole('site_manager'); @@ -761,8 +763,15 @@ public function testListParagraphBasicPageTypesFilter(AcceptanceTester $I) { $basic_page_entity = $I->createEntity([ 'type' => 'stanford_page', - 'title' => $this->faker->text(15), + 'title' => 'B' . $this->faker->text(15), + 'su_basic_page_type' => $type_term->id(), + ]); + + $second_basic_page_entity = $I->createEntity([ + 'type' => 'stanford_page', + 'title' => 'A' . $this->faker->text(15), 'su_basic_page_type' => $type_term->id(), + 'created' => time() - 120, ]); $I->amOnPage("/node/{$basic_page_entity->id()}/edit"); @@ -777,20 +786,62 @@ public function testListParagraphBasicPageTypesFilter(AcceptanceTester $I) { $I->amOnPage($node->toUrl()->toString()); $I->canSee($basic_page_entity->label(), 'h3'); + $I->canSee($second_basic_page_entity->label(), 'h3'); + + $headings = $I->grabMultiple('.ptype-stanford-lists h3'); + $headings = array_map('trim', $headings); + $I->assertEquals($basic_page_entity->label(), $headings[0], $basic_page_entity->label() . ' should be first.'); + $I->assertEquals($second_basic_page_entity->label(), $headings[1], $second_basic_page_entity->label() . ' should be second.'); + $I->cantSee($type_term->label()); $layout_changed_page = $I->createEntity([ 'type' => 'stanford_page', - 'title' => $this->faker->text(15), + 'title' => 'Z' . $this->faker->text(15), 'su_basic_page_type' => $type_term->id(), 'su_page_description' => $this->faker->text, 'layout_selection' => 'stanford_basic_page_full', + 'created' => time() - 1000, ]); $I->amOnPage($layout_changed_page->toUrl('edit-form')->toString()); $I->click('Save'); $I->amOnPage($node->toUrl()->toString()); $I->canSee($layout_changed_page->label(), 'h3'); $I->canSee($layout_changed_page->get('su_page_description')->getString()); + + $node = $this->getNodeWithList($I, [ + 'target_id' => 'stanford_basic_pages', + 'display_id' => 'viewfield_block_1', + 'items_to_display' => 100, + 'arguments' => 'Basic-Page-Test-Term', + ]); + + $I->amOnPage($node->toUrl()->toString()); + $I->canSee($basic_page_entity->label(), 'h3'); + $I->canSee($second_basic_page_entity->label(), 'h3'); + + $headings = $I->grabMultiple('.ptype-stanford-lists h3'); + $headings = array_map('trim', $headings); + + $I->assertEquals($basic_page_entity->label(), $headings[0], $basic_page_entity->label() . ' should be first.'); + $I->assertEquals($second_basic_page_entity->label(), $headings[1], $second_basic_page_entity->label() . ' should be second.'); + + $node = $this->getNodeWithList($I, [ + 'target_id' => 'stanford_basic_pages', + 'display_id' => 'card_grid_alpha', + 'items_to_display' => 100, + 'arguments' => 'Basic-Page-Test-Term', + ]); + + $I->amOnPage($node->toUrl()->toString()); + $I->canSee($basic_page_entity->label(), 'h3'); + $I->canSee($second_basic_page_entity->label(), 'h3'); + + $headings = $I->grabMultiple('.ptype-stanford-lists h3'); + $headings = array_map('trim', $headings); + + $I->assertEquals($second_basic_page_entity->label(), $headings[0], $second_basic_page_entity->label() . ' should be first.'); + $I->assertEquals($basic_page_entity->label(), $headings[1], $basic_page_entity->label() . ' should be second.'); } /**