From 48b78c0a675b3389cefd92049a1a5d72ede83b92 Mon Sep 17 00:00:00 2001 From: StanleyJochman Date: Mon, 21 Sep 2026 12:31:54 +0200 Subject: [PATCH 1/2] fix(ChatbotFootnote): skip popover validation when no popover is provided MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The console.error guard fires when popover is undefined because `!popover?.cta && !popover?.showClose` is truthy for any falsy popover. This is a false positive — the label-only path (no popover) is valid. Gate the check on `popover` being defined so it only validates when a popover config is actually provided. Co-authored-by: Cursor --- packages/module/src/ChatbotFooter/ChatbotFootnote.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/module/src/ChatbotFooter/ChatbotFootnote.tsx b/packages/module/src/ChatbotFooter/ChatbotFootnote.tsx index f948e26b3..be0213528 100644 --- a/packages/module/src/ChatbotFooter/ChatbotFootnote.tsx +++ b/packages/module/src/ChatbotFooter/ChatbotFootnote.tsx @@ -63,7 +63,7 @@ export const ChatbotFootnote: FunctionComponent = ({ className, ...props }: ChatbotFootnoteProps) => { - if (!popover?.cta && !popover?.showClose) { + if (popover && !popover.cta && !popover.showClose) { // eslint-disable-next-line no-console console.error( 'ChatbotFootnote: You must provide either the popover.cta or popover.showClose props in order to render a button that can close the popover.' From 5350ba29f47c1e9076544a267019703e4e517682 Mon Sep 17 00:00:00 2001 From: StanleyJochman Date: Wed, 23 Sep 2026 11:24:51 +0200 Subject: [PATCH 2/2] adding tests --- .../ChatbotFooter/ChatbotFooternote.test.tsx | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/packages/module/src/ChatbotFooter/ChatbotFooternote.test.tsx b/packages/module/src/ChatbotFooter/ChatbotFooternote.test.tsx index 9a34337a1..01f6a93f6 100644 --- a/packages/module/src/ChatbotFooter/ChatbotFooternote.test.tsx +++ b/packages/module/src/ChatbotFooter/ChatbotFooternote.test.tsx @@ -1,6 +1,9 @@ import { act, fireEvent, render, screen, waitFor } from '@testing-library/react'; import ChatbotFootnote from './ChatbotFootnote'; +const POPOVER_CLOSE_ERROR = + 'ChatbotFootnote: You must provide either the popover.cta or popover.showClose props in order to render a button that can close the popover.'; + describe('ChatbotFooternote', () => { const onClick = jest.fn(); const popoverProps = { @@ -20,11 +23,58 @@ describe('ChatbotFooternote', () => { } }; + let consoleErrorSpy: jest.SpyInstance; + + beforeEach(() => { + consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(jest.fn()); + }); + + afterEach(() => { + consoleErrorSpy.mockRestore(); + }); + it('should render ChatbotFooternote', () => { render(); expect(screen.getByText('Chatbot footer')).toBeTruthy(); }); + it('should not log a console error when no popover is provided', () => { + render(); + expect(consoleErrorSpy).not.toHaveBeenCalledWith(POPOVER_CLOSE_ERROR); + }); + + it('should not log a console error when popover has a cta', () => { + render(); + expect(consoleErrorSpy).not.toHaveBeenCalledWith(POPOVER_CLOSE_ERROR); + }); + + it('should not log a console error when popover has showClose', () => { + render( + + ); + expect(consoleErrorSpy).not.toHaveBeenCalledWith(POPOVER_CLOSE_ERROR); + }); + + it('should log a console error when popover is provided without cta or showClose', () => { + render( + + ); + expect(consoleErrorSpy).toHaveBeenCalledWith(POPOVER_CLOSE_ERROR); + }); + it('should render ChatbotFooternote with popover', async () => { render();