From 260109f6ecc322a4688fd4978b1227d40d5f91c3 Mon Sep 17 00:00:00 2001 From: girishpanchal30 Date: Wed, 5 Aug 2026 17:37:22 +0530 Subject: [PATCH 1/2] fix: handle missing Tagify method --- js/ActionPopup/index.js | 17 ++++++++++- tests/e2e/specs/import.spec.js | 53 ++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 1 deletion(-) diff --git a/js/ActionPopup/index.js b/js/ActionPopup/index.js index da616f52..cff6be3d 100644 --- a/js/ActionPopup/index.js +++ b/js/ActionPopup/index.js @@ -17,6 +17,21 @@ import { import { Icon, dragHandle, close, plus, trash } from '@wordpress/icons'; +/** + * Drop the data Tagify keeps in the browser storage for the given instance. + * + * @param {Object} tagify The Tagify instance. + */ +const clearTagifyPersistedData = (tagify) => { + if ('function' === typeof tagify?.clearPersistedData) { + tagify.clearPersistedData(); + return; + } + if ('function' === typeof tagify?.setPersistedData) { + tagify.setPersistedData([], 'value'); + } +}; + const ActionModal = () => { // useRef const userRef = useRef(null); @@ -236,7 +251,7 @@ const ActionModal = () => { if ('import_post_featured_img' === fieldName) { inputField.removeAllTags(); inputField.addEmptyTag(); - inputField.clearPersistedData(); + clearTagifyPersistedData(inputField); } if (null === editModeTag || 'import_post_featured_img' === fieldName) { const tagElm = inputField.createTagElem({ value: _action }); diff --git a/tests/e2e/specs/import.spec.js b/tests/e2e/specs/import.spec.js index b994a0c2..30d98af8 100644 --- a/tests/e2e/specs/import.spec.js +++ b/tests/e2e/specs/import.spec.js @@ -305,6 +305,59 @@ test.describe('Feed Import', () => { ).resolves.toBeGreaterThan(0); // We should have some imported images. }); + test('save featured image action when Tagify has no persistence API', async ({ + page, + }) => { + const featuredImgInput = + 'input[name="feedzy_meta_data[import_post_featured_img]"]'; + const pageErrors = []; + page.on('pageerror', (error) => pageErrors.push(error.message)); + + await page.goto('/wp-admin/post-new.php?post_type=feedzy_imports'); + await tryCloseTourModal(page); + + await page.getByRole('button', { name: 'Step 3 Map content ' }).click(); + + // Simulate a Tagify build that does not expose the optional persistence API. + await page.waitForFunction( + (selector) => Boolean(window.jQuery(selector).data('tagify')), + featuredImgInput + ); + await page.evaluate((selector) => { + const tagify = window.jQuery(selector).data('tagify'); + delete tagify.clearPersistedData; + delete tagify.setPersistedData; + }, featuredImgInput); + + // Open the action popup for the featured image tag. + await page.locator('.fz-image-action-tags .btn-add-fields').click(); + await page + .locator('.fz-image-action-tags [data-action_popup="item_image"]') + .click(); + + await expect( + page.getByRole('heading', { name: 'Add actions to this tag' }) + ).toBeVisible(); + + await page.getByRole('button', { name: 'Skip Actions' }).click(); + + // The modal closes and the tag is persisted on the field. + await expect( + page.getByRole('heading', { name: 'Add actions to this tag' }) + ).not.toBeVisible(); + await expect + .poll(() => + page.evaluate( + (selector) => document.querySelector(selector).value, + featuredImgInput + ) + ) + .toContain('item_image'); + expect( + pageErrors.filter((message) => message.includes('PersistedData')) + ).toEqual([]); + }); + test('close Feedzy Action modal when clicking outside', async ({ page, }) => { From 3863b7f5a5344b565e7c58522316b0b5f443ed00 Mon Sep 17 00:00:00 2001 From: Girish Panchal <79647963+girishpanchal30@users.noreply.github.com> Date: Wed, 5 Aug 2026 17:54:49 +0530 Subject: [PATCH 2/2] fix: remove Tagify method Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- tests/e2e/specs/import.spec.js | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/e2e/specs/import.spec.js b/tests/e2e/specs/import.spec.js index 30d98af8..16198f75 100644 --- a/tests/e2e/specs/import.spec.js +++ b/tests/e2e/specs/import.spec.js @@ -326,7 +326,6 @@ test.describe('Feed Import', () => { await page.evaluate((selector) => { const tagify = window.jQuery(selector).data('tagify'); delete tagify.clearPersistedData; - delete tagify.setPersistedData; }, featuredImgInput); // Open the action popup for the featured image tag.