From 8b6daba90a86cdad4dee48d50c5cbe42f34710df Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Thu, 3 Jul 2025 12:56:06 +0800 Subject: [PATCH 1/4] Broadcasts: Add option to order title and date --- .../class-convertkit-block-broadcasts.php | 14 +++++++++++++ resources/frontend/css/broadcasts.css | 20 +++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/includes/blocks/class-convertkit-block-broadcasts.php b/includes/blocks/class-convertkit-block-broadcasts.php index f441f0d12..d75b2e326 100644 --- a/includes/blocks/class-convertkit-block-broadcasts.php +++ b/includes/blocks/class-convertkit-block-broadcasts.php @@ -185,6 +185,10 @@ public function get_attributes() { 'type' => 'boolean', 'default' => $this->get_default_value( 'display_grid' ), ), + 'display_order' => array( + 'type' => 'string', + 'default' => $this->get_default_value( 'display_order' ), + ), 'date_format' => array( 'type' => 'string', 'default' => $this->get_default_value( 'date_format' ), @@ -286,6 +290,14 @@ public function get_fields() { 'type' => 'toggle', 'description' => __( 'If enabled, displays broadcasts in a grid, instead of a list.', 'convertkit' ), ), + 'display_order' => array( + 'label' => __( 'Display order', 'convertkit' ), + 'type' => 'select', + 'values' => array( + 'date-broadcast' => __( 'Date, Broadcast', 'convertkit' ), + 'broadcast-date' => __( 'Broadcast, Date', 'convertkit' ), + ), + ), 'date_format' => array( 'label' => __( 'Date format', 'convertkit' ), 'type' => 'select', @@ -373,6 +385,7 @@ public function get_panels() { 'label' => __( 'General', 'convertkit' ), 'fields' => array( 'display_grid', + 'display_order', 'date_format', 'display_image', 'display_description', @@ -412,6 +425,7 @@ public function get_default_values() { return array( 'display_grid' => false, + 'display_order' => 'date-broadcast', 'date_format' => 'F j, Y', 'display_image' => false, 'display_description' => false, diff --git a/resources/frontend/css/broadcasts.css b/resources/frontend/css/broadcasts.css index fd6a5c185..2007809e6 100644 --- a/resources/frontend/css/broadcasts.css +++ b/resources/frontend/css/broadcasts.css @@ -29,6 +29,12 @@ grid-template-columns: 150px auto; grid-column-gap: 20px; } +.convertkit-broadcasts[data-display-order="broadcast-date"] .convertkit-broadcasts-list li { + grid-template-areas: + "title date" + "text image"; + grid-template-columns: auto 150px; +} @media screen and (max-width: 478px) { .convertkit-broadcasts-list li { grid-template-areas: @@ -59,6 +65,14 @@ grid-template-columns: none; grid-row-gap: 10px; } +.convertkit-broadcasts[data-display-grid="1"][data-display-order="broadcast-date"] .convertkit-broadcasts-list li { + grid-template-areas: + "image" + "title" + "text" + "date"; +} + .convertkit-broadcasts[data-display-grid="1"] .convertkit-broadcasts-list li .convertkit-broadcast-read-more { margin: 10px 0 0 0; } @@ -85,6 +99,12 @@ display: inline-block; grid-area: date; } +.convertkit-broadcasts[data-display-grid="1"][data-display-order="broadcast-date"] .convertkit-broadcasts-list li time { + text-align: left; +} +.convertkit-broadcasts[data-display-order="broadcast-date"] .convertkit-broadcasts-list li time { + text-align: right; +} .convertkit-broadcasts-list li .convertkit-broadcast-title { display: inline-block; grid-area: title; From 6265ac21759aed3e82a0305881f0cdd3843747b8 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Thu, 3 Jul 2025 13:03:02 +0800 Subject: [PATCH 2/4] Increase height of modal in Classic Editor --- includes/blocks/class-convertkit-block-broadcasts.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/blocks/class-convertkit-block-broadcasts.php b/includes/blocks/class-convertkit-block-broadcasts.php index d75b2e326..f4c083ca7 100644 --- a/includes/blocks/class-convertkit-block-broadcasts.php +++ b/includes/blocks/class-convertkit-block-broadcasts.php @@ -134,7 +134,7 @@ public function get_overview() { // Shortcode: TinyMCE / QuickTags Modal Width and Height. 'modal' => array( 'width' => 650, - 'height' => 405, + 'height' => 455, ), // Shortcode: Include a closing [/shortcode] tag when using TinyMCE or QuickTag Modals. From f567c1702fadbc86f0573c89be198c4a2a8a6665 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Thu, 3 Jul 2025 13:39:47 +0800 Subject: [PATCH 3/4] Added tests --- .../PageBlockBroadcastsCest.php | 41 ++++++ .../PageShortcodeBroadcastsCest.php | 128 +++++++++++++++--- 2 files changed, 147 insertions(+), 22 deletions(-) diff --git a/tests/EndToEnd/broadcasts/blocks-shortcodes/PageBlockBroadcastsCest.php b/tests/EndToEnd/broadcasts/blocks-shortcodes/PageBlockBroadcastsCest.php index 284188641..68fbf2837 100644 --- a/tests/EndToEnd/broadcasts/blocks-shortcodes/PageBlockBroadcastsCest.php +++ b/tests/EndToEnd/broadcasts/blocks-shortcodes/PageBlockBroadcastsCest.php @@ -242,6 +242,47 @@ public function testBroadcastsBlockWithDisplayGridParameter(EndToEndTester $I) ); } + /** + * Test the Broadcasts block's "Display order" parameter works. + * + * @since 2.8.3 + * + * @param EndToEndTester $I Tester. + */ + public function testBroadcastsBlockWithDisplayOrderParameter(EndToEndTester $I) + { + // Setup Plugin and enable debug log. + $I->setupKitPlugin($I); + $I->setupKitPluginResources($I); + + // Add a Page using the Gutenberg editor. + $I->addGutenbergPage( + $I, + title: 'Kit: Page: Broadcasts: Display Order' + ); + + // Add block to Page, setting the date format. + $I->addGutenbergBlock( + $I, + blockName: 'Kit Broadcasts', + blockProgrammaticName: 'convertkit-broadcasts', + blockConfiguration: [ + 'display_order' => [ 'select', 'broadcast-date' ], + ] + ); + + // Publish and view the Page on the frontend site. + $I->publishAndViewGutenbergPage($I); + + // Confirm that the block displays correctly with the expected number of Broadcasts in the grid format. + $I->seeBroadcastsOutput( + $I, + [ + 'number_posts' => $_ENV['CONVERTKIT_API_BROADCAST_COUNT'], + ] + ); + } + /** * Test the Broadcasts block's date format parameter works. * diff --git a/tests/EndToEnd/broadcasts/blocks-shortcodes/PageShortcodeBroadcastsCest.php b/tests/EndToEnd/broadcasts/blocks-shortcodes/PageShortcodeBroadcastsCest.php index 9405a6b0d..da6783474 100644 --- a/tests/EndToEnd/broadcasts/blocks-shortcodes/PageShortcodeBroadcastsCest.php +++ b/tests/EndToEnd/broadcasts/blocks-shortcodes/PageShortcodeBroadcastsCest.php @@ -45,7 +45,7 @@ public function testBroadcastsShortcodeInVisualEditorWithDefaultParameters(EndTo $I->addVisualEditorShortcode( $I, shortcodeName: 'Kit Broadcasts', - expectedShortcodeOutput: '[convertkit_broadcasts display_grid="0" date_format="F j, Y" display_image="0" display_description="0" display_read_more="0" read_more_label="Read more" limit="10" paginate="0" paginate_label_prev="Previous" paginate_label_next="Next"]' + expectedShortcodeOutput: '[convertkit_broadcasts display_grid="0" display_order="date-broadcast" date_format="F j, Y" display_image="0" display_description="0" display_read_more="0" read_more_label="Read more" limit="10" paginate="0" paginate_label_prev="Previous" paginate_label_next="Next"]' ); // Publish and view the Page on the frontend site. @@ -91,7 +91,7 @@ public function testBroadcastsShortcodeInVisualEditorWithDisplayGridParameter(En shortcodeConfiguration: [ 'display_grid' => [ 'toggle', 'Yes' ], ], - expectedShortcodeOutput: '[convertkit_broadcasts display_grid="1" date_format="F j, Y" display_image="0" display_description="0" display_read_more="0" read_more_label="Read more" limit="10" paginate="0" paginate_label_prev="Previous" paginate_label_next="Next"]' + expectedShortcodeOutput: '[convertkit_broadcasts display_grid="1" display_order="date-broadcast" date_format="F j, Y" display_image="0" display_description="0" display_read_more="0" read_more_label="Read more" limit="10" paginate="0" paginate_label_prev="Previous" paginate_label_next="Next"]' ); // Publish and view the Page on the frontend site. @@ -107,6 +107,52 @@ public function testBroadcastsShortcodeInVisualEditorWithDisplayGridParameter(En ); } + /** + * Test the [convertkit_broadcasts] shortcode's "Display order" parameter works. + * + * @since 2.8.3 + * + * @param EndToEndTester $I Tester. + */ + public function testBroadcastsShortcodeInVisualEditorWithDisplayOrderParameter(EndToEndTester $I) + { + // Add a Page using the Classic Editor. + $I->addClassicEditorPage( + $I, + title: 'Kit: Page: Broadcasts: Shortcode: Visual Editor: Display Order' + ); + + // Add shortcode to Page. + $I->addVisualEditorShortcode( + $I, + shortcodeName: 'Kit Broadcasts', + shortcodeConfiguration: [ + 'display_order' => [ 'select', 'broadcast-date' ], + ], + expectedShortcodeOutput: '[convertkit_broadcasts display_grid="0" display_order="broadcast-date" date_format="F j, Y" display_image="0" display_description="0" display_read_more="0" read_more_label="Read more" limit="10" paginate="0" paginate_label_prev="Previous" paginate_label_next="Next"]' + ); + + // Publish and view the Page on the frontend site. + $I->publishAndViewClassicEditorPage($I); + + // Confirm that the shortcode displays correctly with the expected number of Broadcasts. + $I->seeBroadcastsOutput( + $I, + [ + 'number_posts' => $_ENV['CONVERTKIT_API_BROADCAST_COUNT'], + ] + ); + + // Confirm that the default date format is as expected. + $I->seeInSource(''); + + // Confirm that the expected Broadcast name is displayed first links to the expected URL, with UTM parameters. + $I->assertEquals( + $I->grabAttributeFrom('div.convertkit-broadcasts ul.convertkit-broadcasts-list li.convertkit-broadcast:nth-child(2) a', 'href'), + $_ENV['CONVERTKIT_API_BROADCAST_FIRST_URL'] . '?utm_source=wordpress&utm_term=en_US&utm_content=convertkit' + ); + } + /** * Test the [convertkit_broadcasts] shortcode works when specifying a non-default date format parameter, * using the Classic Editor (TinyMCE / Visual). @@ -130,7 +176,7 @@ public function testBroadcastsShortcodeInVisualEditorWithDateFormatParameter(End shortcodeConfiguration: [ 'date_format' => [ 'select', date('Y-m-d') ], ], - expectedShortcodeOutput: '[convertkit_broadcasts display_grid="0" date_format="Y-m-d" display_image="0" display_description="0" display_read_more="0" read_more_label="Read more" limit="10" paginate="0" paginate_label_prev="Previous" paginate_label_next="Next"]' + expectedShortcodeOutput: '[convertkit_broadcasts display_grid="0" display_order="date-broadcast" date_format="Y-m-d" display_image="0" display_description="0" display_read_more="0" read_more_label="Read more" limit="10" paginate="0" paginate_label_prev="Previous" paginate_label_next="Next"]' ); // Publish and view the Page on the frontend site. @@ -176,7 +222,7 @@ public function testBroadcastsShortcodeInVisualEditorWithDisplayImageParameter(E shortcodeConfiguration: [ 'display_image' => [ 'toggle', 'Yes' ], ], - expectedShortcodeOutput: '[convertkit_broadcasts display_grid="0" date_format="F j, Y" display_image="1" display_description="0" display_read_more="0" read_more_label="Read more" limit="10" paginate="0" paginate_label_prev="Previous" paginate_label_next="Next"]' + expectedShortcodeOutput: '[convertkit_broadcasts display_grid="0" display_order="date-broadcast" date_format="F j, Y" display_image="1" display_description="0" display_read_more="0" read_more_label="Read more" limit="10" paginate="0" paginate_label_prev="Previous" paginate_label_next="Next"]' ); // Publish and view the Page on the frontend site. @@ -214,7 +260,7 @@ public function testBroadcastsShortcodeInVisualEditorWithDisplayDescriptionParam shortcodeConfiguration: [ 'display_description' => [ 'toggle', 'Yes' ], ], - expectedShortcodeOutput: '[convertkit_broadcasts display_grid="0" date_format="F j, Y" display_image="0" display_description="1" display_read_more="0" read_more_label="Read more" limit="10" paginate="0" paginate_label_prev="Previous" paginate_label_next="Next"]' + expectedShortcodeOutput: '[convertkit_broadcasts display_grid="0" display_order="date-broadcast" date_format="F j, Y" display_image="0" display_description="1" display_read_more="0" read_more_label="Read more" limit="10" paginate="0" paginate_label_prev="Previous" paginate_label_next="Next"]' ); // Publish and view the Page on the frontend site. @@ -253,7 +299,7 @@ public function testBroadcastsShortcodeInVisualEditorWithDisplayReadMoreLinkPara 'display_read_more' => [ 'toggle', 'Yes' ], 'read_more_label' => [ 'input', 'Continue reading' ], ], - expectedShortcodeOutput: '[convertkit_broadcasts display_grid="0" date_format="F j, Y" display_image="0" display_description="0" display_read_more="1" read_more_label="Continue reading" limit="10" paginate="0" paginate_label_prev="Previous" paginate_label_next="Next"]' + expectedShortcodeOutput: '[convertkit_broadcasts display_grid="0" display_order="date-broadcast" date_format="F j, Y" display_image="0" display_description="0" display_read_more="1" read_more_label="Continue reading" limit="10" paginate="0" paginate_label_prev="Previous" paginate_label_next="Next"]' ); // Publish and view the Page on the frontend site. @@ -292,7 +338,7 @@ public function testBroadcastsShortcodeInVisualEditorWithLimitParameter(EndToEnd shortcodeConfiguration: [ 'limit' => [ 'input', '2', 'Pagination' ], // Click the Pagination tab first before starting to complete fields. ], - expectedShortcodeOutput: '[convertkit_broadcasts display_grid="0" date_format="F j, Y" display_image="0" display_description="0" display_read_more="0" read_more_label="Read more" limit="2" paginate="0" paginate_label_prev="Previous" paginate_label_next="Next"]' + expectedShortcodeOutput: '[convertkit_broadcasts display_grid="0" display_order="date-broadcast" date_format="F j, Y" display_image="0" display_description="0" display_read_more="0" read_more_label="Read more" limit="2" paginate="0" paginate_label_prev="Previous" paginate_label_next="Next"]' ); // Publish and view the Page on the frontend site. @@ -337,7 +383,7 @@ public function testBroadcastsShortcodeInVisualEditorWithPaginationEnabled(EndTo 'limit' => [ 'input', '2', 'Pagination' ], // Click the Pagination tab first before starting to complete fields. 'paginate' => [ 'toggle', 'Yes' ], ], - expectedShortcodeOutput: '[convertkit_broadcasts display_grid="0" date_format="F j, Y" display_image="0" display_description="0" display_read_more="0" read_more_label="Read more" limit="2" paginate="1" paginate_label_prev="Previous" paginate_label_next="Next"]' + expectedShortcodeOutput: '[convertkit_broadcasts display_grid="0" display_order="date-broadcast" date_format="F j, Y" display_image="0" display_description="0" display_read_more="0" read_more_label="Read more" limit="2" paginate="1" paginate_label_prev="Previous" paginate_label_next="Next"]' ); // Publish and view the Page on the frontend site. @@ -377,7 +423,7 @@ public function testBroadcastsShortcodeInVisualEditorWithPaginationLabelParamete 'paginate_label_prev' => [ 'input', 'Newer' ], 'paginate_label_next' => [ 'input', 'Older' ], ], - expectedShortcodeOutput: '[convertkit_broadcasts display_grid="0" date_format="F j, Y" display_image="0" display_description="0" display_read_more="0" read_more_label="Read more" limit="2" paginate="1" paginate_label_prev="Newer" paginate_label_next="Older"]' + expectedShortcodeOutput: '[convertkit_broadcasts display_grid="0" display_order="date-broadcast" date_format="F j, Y" display_image="0" display_description="0" display_read_more="0" read_more_label="Read more" limit="2" paginate="1" paginate_label_prev="Newer" paginate_label_next="Older"]' ); // Publish and view the Page on the frontend site. @@ -417,7 +463,7 @@ public function testBroadcastsShortcodeInVisualEditorWithBlankPaginationLabelPar 'paginate_label_prev' => [ 'input', '' ], 'paginate_label_next' => [ 'input', '' ], ], - expectedShortcodeOutput: '[convertkit_broadcasts display_grid="0" date_format="F j, Y" display_image="0" display_description="0" display_read_more="0" read_more_label="Read more" limit="2" paginate="1"]' + expectedShortcodeOutput: '[convertkit_broadcasts display_grid="0" display_order="date-broadcast" date_format="F j, Y" display_image="0" display_description="0" display_read_more="0" read_more_label="Read more" limit="2" paginate="1"]' ); // Publish and view the Page on the frontend site. @@ -453,7 +499,7 @@ public function testBroadcastsShortcodeInVisualEditorWithHexColorParameters(EndT $I->havePageInDatabase( [ 'post_name' => 'kit-page-broadcasts-shortcode-hex-color-params', - 'post_content' => '[convertkit_broadcasts display_grid="0" date_format="F j, Y" display_image="0" display_description="0" display_read_more="0" read_more_label="Read more" limit="2" paginate="1" paginate_label_prev="Newer" paginate_label_next="Older" link_color="' . $linkColor . '" background_color="' . $backgroundColor . '" text_color="' . $textColor . '"]', + 'post_content' => '[convertkit_broadcasts display_grid="0" display_order="date-broadcast" date_format="F j, Y" display_image="0" display_description="0" display_read_more="0" read_more_label="Read more" limit="2" paginate="1" paginate_label_prev="Newer" paginate_label_next="Older" link_color="' . $linkColor . '" background_color="' . $backgroundColor . '" text_color="' . $textColor . '"]', ] ); @@ -512,7 +558,7 @@ public function testBroadcastsShortcodeInTextEditorWithDefaultParameters(EndToEn $I->addTextEditorShortcode( $I, shortcodeProgrammaticName: 'convertkit-broadcasts', - expectedShortcodeOutput: '[convertkit_broadcasts display_grid="0" date_format="F j, Y" display_image="0" display_description="0" display_read_more="0" read_more_label="Read more" limit="10" paginate="0" paginate_label_prev="Previous" paginate_label_next="Next"]' + expectedShortcodeOutput: '[convertkit_broadcasts display_grid="0" display_order="date-broadcast" date_format="F j, Y" display_image="0" display_description="0" display_read_more="0" read_more_label="Read more" limit="10" paginate="0" paginate_label_prev="Previous" paginate_label_next="Next"]' ); // Publish and view the Page on the frontend site. @@ -556,7 +602,7 @@ public function testBroadcastsShortcodeInTextEditorWithDisplayGridParameter(EndT shortcodeConfiguration: [ 'display_grid' => [ 'toggle', 'Yes' ], ], - expectedShortcodeOutput: '[convertkit_broadcasts display_grid="1" date_format="F j, Y" display_image="0" display_description="0" display_read_more="0" read_more_label="Read more" limit="10" paginate="0" paginate_label_prev="Previous" paginate_label_next="Next"]' + expectedShortcodeOutput: '[convertkit_broadcasts display_grid="1" display_order="date-broadcast" date_format="F j, Y" display_image="0" display_description="0" display_read_more="0" read_more_label="Read more" limit="10" paginate="0" paginate_label_prev="Previous" paginate_label_next="Next"]' ); // Publish and view the Page on the frontend site. @@ -572,6 +618,44 @@ public function testBroadcastsShortcodeInTextEditorWithDisplayGridParameter(EndT ); } + /** + * Test the [convertkit_broadcasts] shortcode's "Display order" parameter works + * using the Text Editor. + * + * @since 2.8.3 + * + * @param EndToEndTester $I Tester. + */ + public function testBroadcastsShortcodeInTextEditorWithDisplayOrderParameter(EndToEndTester $I) + { + // Add a Page using the Classic Editor. + $I->addClassicEditorPage( + $I, + title: 'Kit: Page: Broadcasts: Shortcode: Text Editor: Display order' + ); + + // Add shortcode to Page. + $I->addTextEditorShortcode( + $I, + shortcodeProgrammaticName: 'convertkit-broadcasts', + shortcodeConfiguration: [ + 'display_order' => [ 'select', 'broadcast-date' ], + ], + expectedShortcodeOutput: '[convertkit_broadcasts display_grid="0" display_order="broadcast-date" date_format="F j, Y" display_image="0" display_description="0" display_read_more="0" read_more_label="Read more" limit="10" paginate="0" paginate_label_prev="Previous" paginate_label_next="Next"]' + ); + + // Publish and view the Page on the frontend site. + $I->publishAndViewClassicEditorPage($I); + + // Confirm that the shortcode displays correctly with the expected number of Broadcasts. + $I->seeBroadcastsOutput( + $I, + [ + 'number_posts' => $_ENV['CONVERTKIT_API_BROADCAST_COUNT'], + ] + ); + } + /** * Test the [convertkit_broadcasts] shortcode works when specifying a non-default date format parameter, * using the Text Editor. @@ -595,7 +679,7 @@ public function testBroadcastsShortcodeInTextEditorWithDateFormatParameter(EndTo shortcodeConfiguration: [ 'date_format' => [ 'select', date('Y-m-d') ], ], - expectedShortcodeOutput: '[convertkit_broadcasts display_grid="0" date_format="Y-m-d" display_image="0" display_description="0" display_read_more="0" read_more_label="Read more" limit="10" paginate="0" paginate_label_prev="Previous" paginate_label_next="Next"]' + expectedShortcodeOutput: '[convertkit_broadcasts display_grid="0" display_order="date-broadcast" date_format="Y-m-d" display_image="0" display_description="0" display_read_more="0" read_more_label="Read more" limit="10" paginate="0" paginate_label_prev="Previous" paginate_label_next="Next"]' ); // Publish and view the Page on the frontend site. @@ -636,7 +720,7 @@ public function testBroadcastsShortcodeInTextEditorWithDisplayImageParameter(End shortcodeConfiguration: [ 'display_image' => [ 'toggle', 'Yes' ], ], - expectedShortcodeOutput: '[convertkit_broadcasts display_grid="0" date_format="F j, Y" display_image="1" display_description="0" display_read_more="0" read_more_label="Read more" limit="10" paginate="0" paginate_label_prev="Previous" paginate_label_next="Next"]' + expectedShortcodeOutput: '[convertkit_broadcasts display_grid="0" display_order="date-broadcast" date_format="F j, Y" display_image="1" display_description="0" display_read_more="0" read_more_label="Read more" limit="10" paginate="0" paginate_label_prev="Previous" paginate_label_next="Next"]' ); // Publish and view the Page on the frontend site. @@ -675,7 +759,7 @@ public function testBroadcastsShortcodeInTextEditorWithDisplayDescriptionParamet shortcodeConfiguration: [ 'display_description' => [ 'toggle', 'Yes' ], ], - expectedShortcodeOutput: '[convertkit_broadcasts display_grid="0" date_format="F j, Y" display_image="0" display_description="1" display_read_more="0" read_more_label="Read more" limit="10" paginate="0" paginate_label_prev="Previous" paginate_label_next="Next"]' + expectedShortcodeOutput: '[convertkit_broadcasts display_grid="0" display_order="date-broadcast" date_format="F j, Y" display_image="0" display_description="1" display_read_more="0" read_more_label="Read more" limit="10" paginate="0" paginate_label_prev="Previous" paginate_label_next="Next"]' ); // Publish and view the Page on the frontend site. @@ -715,7 +799,7 @@ public function testBroadcastsShortcodeInTextEditorWithDisplayReadMoreLinkParame 'display_read_more' => [ 'toggle', 'Yes' ], 'read_more_label' => [ 'input', 'Continue reading' ], ], - expectedShortcodeOutput: '[convertkit_broadcasts display_grid="0" date_format="F j, Y" display_image="0" display_description="0" display_read_more="1" read_more_label="Continue reading" limit="10" paginate="0" paginate_label_prev="Previous" paginate_label_next="Next"]' + expectedShortcodeOutput: '[convertkit_broadcasts display_grid="0" display_order="date-broadcast" date_format="F j, Y" display_image="0" display_description="0" display_read_more="1" read_more_label="Continue reading" limit="10" paginate="0" paginate_label_prev="Previous" paginate_label_next="Next"]' ); // Publish and view the Page on the frontend site. @@ -754,7 +838,7 @@ public function testBroadcastsShortcodeInTextEditorWithLimitParameter(EndToEndTe shortcodeConfiguration: [ 'limit' => [ 'input', '2', 'Pagination' ], // Click the Pagination tab first before starting to complete fields. ], - expectedShortcodeOutput: '[convertkit_broadcasts display_grid="0" date_format="F j, Y" display_image="0" display_description="0" display_read_more="0" read_more_label="Read more" limit="2" paginate="0" paginate_label_prev="Previous" paginate_label_next="Next"]' + expectedShortcodeOutput: '[convertkit_broadcasts display_grid="0" display_order="date-broadcast" date_format="F j, Y" display_image="0" display_description="0" display_read_more="0" read_more_label="Read more" limit="2" paginate="0" paginate_label_prev="Previous" paginate_label_next="Next"]' ); // Publish and view the Page on the frontend site. @@ -796,7 +880,7 @@ public function testBroadcastsShortcodeInTextEditorWithPaginationEnabled(EndToEn 'limit' => [ 'input', '2', 'Pagination' ], // Click the Pagination tab first before starting to complete fields. 'paginate' => [ 'toggle', 'Yes' ], ], - expectedShortcodeOutput: '[convertkit_broadcasts display_grid="0" date_format="F j, Y" display_image="0" display_description="0" display_read_more="0" read_more_label="Read more" limit="2" paginate="1" paginate_label_prev="Previous" paginate_label_next="Next"]' + expectedShortcodeOutput: '[convertkit_broadcasts display_grid="0" display_order="date-broadcast" date_format="F j, Y" display_image="0" display_description="0" display_read_more="0" read_more_label="Read more" limit="2" paginate="1" paginate_label_prev="Previous" paginate_label_next="Next"]' ); // Publish and view the Page on the frontend site. @@ -836,7 +920,7 @@ public function testBroadcastsShortcodeInTextEditorWithPaginationLabelParameters 'paginate_label_prev' => [ 'input', 'Newer' ], 'paginate_label_next' => [ 'input', 'Older' ], ], - expectedShortcodeOutput: '[convertkit_broadcasts display_grid="0" date_format="F j, Y" display_image="0" display_description="0" display_read_more="0" read_more_label="Read more" limit="2" paginate="1" paginate_label_prev="Newer" paginate_label_next="Older"]' + expectedShortcodeOutput: '[convertkit_broadcasts display_grid="0" display_order="date-broadcast" date_format="F j, Y" display_image="0" display_description="0" display_read_more="0" read_more_label="Read more" limit="2" paginate="1" paginate_label_prev="Newer" paginate_label_next="Older"]' ); // Publish and view the Page on the frontend site. @@ -881,7 +965,7 @@ public function testBroadcastsShortcodeWhenSwitchingEditors(EndToEndTester $I) 'limit' => [ 'input', '2', 'Pagination' ], // Click the Pagination tab first before starting to complete fields. 'paginate' => [ 'toggle', 'Yes' ], ], - expectedShortcodeOutput: '[convertkit_broadcasts display_grid="0" date_format="F j, Y" display_image="0" display_description="0" display_read_more="0" read_more_label="Read more" limit="2" paginate="1" paginate_label_prev="Previous" paginate_label_next="Next"]' + expectedShortcodeOutput: '[convertkit_broadcasts display_grid="0" display_order="date-broadcast" date_format="F j, Y" display_image="0" display_description="0" display_read_more="0" read_more_label="Read more" limit="2" paginate="1" paginate_label_prev="Previous" paginate_label_next="Next"]' ); // Publish and view the Page on the frontend site. @@ -902,7 +986,7 @@ public function testBroadcastsShortcodeParameterEscaping(EndToEndTester $I) $I->havePageInDatabase( [ 'post_name' => 'kit-page-broadcasts-shortcode-parameter-escaping', - 'post_content' => '[convertkit_broadcasts display_grid="0" date_format="F j, Y" display_image="0" display_description="0" display_read_more="0" read_more_label="Read more" limit="2" paginate="1" paginate_label_prev="Previous" paginate_label_next="Next" link_color=\'red" onmouseover="alert(1)"\']', + 'post_content' => '[convertkit_broadcasts display_grid="0" display_order="date-broadcast" date_format="F j, Y" display_image="0" display_description="0" display_read_more="0" read_more_label="Read more" limit="2" paginate="1" paginate_label_prev="Previous" paginate_label_next="Next" link_color=\'red" onmouseover="alert(1)"\']', ] ); From 77826f8bb11dcce36bed1b8d0530a38a5931f707 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Thu, 3 Jul 2025 13:44:04 +0800 Subject: [PATCH 4/4] Tests: Check `display_order` data attribute --- .../blocks-shortcodes/PageBlockBroadcastsCest.php | 3 ++- .../blocks-shortcodes/PageShortcodeBroadcastsCest.php | 6 ++++-- tests/Support/Helper/KitBroadcasts.php | 6 ++++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/EndToEnd/broadcasts/blocks-shortcodes/PageBlockBroadcastsCest.php b/tests/EndToEnd/broadcasts/blocks-shortcodes/PageBlockBroadcastsCest.php index 68fbf2837..ba5bec820 100644 --- a/tests/EndToEnd/broadcasts/blocks-shortcodes/PageBlockBroadcastsCest.php +++ b/tests/EndToEnd/broadcasts/blocks-shortcodes/PageBlockBroadcastsCest.php @@ -278,7 +278,8 @@ public function testBroadcastsBlockWithDisplayOrderParameter(EndToEndTester $I) $I->seeBroadcastsOutput( $I, [ - 'number_posts' => $_ENV['CONVERTKIT_API_BROADCAST_COUNT'], + 'number_posts' => $_ENV['CONVERTKIT_API_BROADCAST_COUNT'], + 'see_display_order' => 'broadcast-date', ] ); } diff --git a/tests/EndToEnd/broadcasts/blocks-shortcodes/PageShortcodeBroadcastsCest.php b/tests/EndToEnd/broadcasts/blocks-shortcodes/PageShortcodeBroadcastsCest.php index da6783474..63b6c838a 100644 --- a/tests/EndToEnd/broadcasts/blocks-shortcodes/PageShortcodeBroadcastsCest.php +++ b/tests/EndToEnd/broadcasts/blocks-shortcodes/PageShortcodeBroadcastsCest.php @@ -139,7 +139,8 @@ public function testBroadcastsShortcodeInVisualEditorWithDisplayOrderParameter(E $I->seeBroadcastsOutput( $I, [ - 'number_posts' => $_ENV['CONVERTKIT_API_BROADCAST_COUNT'], + 'number_posts' => $_ENV['CONVERTKIT_API_BROADCAST_COUNT'], + 'see_display_order' => 'broadcast-date', ] ); @@ -651,7 +652,8 @@ public function testBroadcastsShortcodeInTextEditorWithDisplayOrderParameter(End $I->seeBroadcastsOutput( $I, [ - 'number_posts' => $_ENV['CONVERTKIT_API_BROADCAST_COUNT'], + 'number_posts' => $_ENV['CONVERTKIT_API_BROADCAST_COUNT'], + 'see_display_order' => 'broadcast-date', ] ); } diff --git a/tests/Support/Helper/KitBroadcasts.php b/tests/Support/Helper/KitBroadcasts.php index 074b83ee7..60de6e27f 100644 --- a/tests/Support/Helper/KitBroadcasts.php +++ b/tests/Support/Helper/KitBroadcasts.php @@ -100,6 +100,7 @@ public function seeBroadcastsOutput($I, $options = false) 'see_prev_pagination_label' => false, 'see_next_pagination_label' => false, 'see_grid' => false, + 'see_display_order' => false, 'see_image' => false, 'see_description' => false, 'see_read_more' => false, @@ -131,6 +132,11 @@ public function seeBroadcastsOutput($I, $options = false) $I->dontSeeElementInDOM('div.convertkit-broadcasts[data-display-grid="1"]'); } + // If Display order is set to broadcast-date, confirm the applicable HTML exists so that CSS can style this layout. + if ($options['see_display_order']) { + $I->seeElementInDOM('div.convertkit-broadcasts[data-display-order="' . $options['see_display_order'] . '"]'); + } + // If Display image is enabled, confirm the image is displayed. if ($options['see_image']) { $I->seeElementInDOM('a.convertkit-broadcast-image img');