Skip to content

Commit

Permalink
Merge pull request #1051 from Codeinwp/fix/loop-button
Browse files Browse the repository at this point in the history
fix: Feedzy Loop button not working with Groups
  • Loading branch information
vytisbulkevicius authored Jan 10, 2025
2 parents eb38563 + 1cd0a69 commit bfd76b9
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 8 deletions.
10 changes: 8 additions & 2 deletions js/FeedzyLoop/components/FeedControl.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/**
* WordPress dependencies.
*/
import { __ } from '@wordpress/i18n';

import { useState, useEffect, useRef } from '@wordpress/element';

const FeedControl = ({ value, options, onChange }) => {
Expand Down Expand Up @@ -80,7 +82,10 @@ const FeedControl = ({ value, options, onChange }) => {
value={selectedOption ? selectedOption.label : inputValue}
onChange={handleInputChange}
onBlur={handleInputBlur}
placeholder="Enter URLs or select a category"
placeholder={__(
'Enter URLs or select a Feed Group',
'feedzy-rss-feeds'
)}
disabled={selectedOption !== null}
className="fz-input-field"
/>
Expand All @@ -89,7 +94,7 @@ const FeedControl = ({ value, options, onChange }) => {
<button
onClick={handleClear}
className="fz-clear-button"
title="Clear selection"
title={__('Clear', 'feedzy-rss-feeds')}
>
<svg
width="14"
Expand All @@ -111,6 +116,7 @@ const FeedControl = ({ value, options, onChange }) => {
<button
onClick={() => setIsOpen(!isOpen)}
className="fz-dropdown-button"
title={__('Select Feed Group', 'feedzy-rss-feeds')}
>
<svg
width="12"
Expand Down
5 changes: 1 addition & 4 deletions js/FeedzyLoop/placeholder.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,7 @@ const BlockPlaceholder = ({ attributes, setAttributes, onSaveFeed }) => {
<Button
variant="primary"
onClick={() => {
if (
attributes?.feed?.source &&
attributes?.feed?.source.length > 0
) {
if (attributes?.feed?.source) {
onSaveFeed();
}
}}
Expand Down
37 changes: 35 additions & 2 deletions tests/e2e/specs/loop.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ test.describe('Feedzy Loop', () => {
const POST_TITLE = `Feedzy Loop Test ${Math.floor(Math.random() * 1000)}`;

test('add Feedzy Loop Block', async ({ editor, page }) => {
await page.goto('/wp-admin/post-new.php?post_type=feedzy_categories');
await page.getByLabel('Add title').click();
await page.keyboard.type('Group One');

await page.locator('textarea[name="feedzy_category_feed"]').click();
await page.keyboard.type(FEED_URL);
await page
.getByRole('button', { name: 'Publish', exact: true })
.click();
await page.waitForTimeout(1000);

await page.goto('/wp-admin/post-new.php');

if (
Expand Down Expand Up @@ -36,13 +47,35 @@ test.describe('Feedzy Loop', () => {
await page.getByPlaceholder('Enter URLs or select a').click();
await page.keyboard.type(FEED_URL);

const loadFeedButton = await page.getByRole('button', {
name: 'Load Feed',
exact: true,
});
const isDisabled = await loadFeedButton.isDisabled();
expect(isDisabled).toBe(false);
await loadFeedButton.click();
await page.waitForTimeout(1000);

await page.getByLabel('Display curated RSS content').click();
await page.waitForTimeout(1000);

// Now that we have tested we can insert URL, we can test the Feed Group.

await page
.getByLabel('Block: Feedzy Loop')
.locator('div')
.nth(1)
.click();
await page.getByRole('button', { name: 'Edit Feed' }).click();

await page.getByRole('button', { name: 'Select Feed Group' }).click();
await page.locator('.fz-dropdown-item').first().click();

await page
.getByRole('button', { name: 'Load Feed', exact: true })
.click();
await page.waitForTimeout(1000);

await page.getByLabel('Display curated RSS content').click();

await page
.getByRole('button', { name: 'Publish', exact: true })
.click();
Expand Down

0 comments on commit bfd76b9

Please sign in to comment.