Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions packages/cli/src/ui/hooks/useBanner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,24 @@ describe('useBanner', () => {
.update(defaultBannerData.defaultText)
.digest('hex')]: 5,
});
});

it('should not hide banner if show count exceeds max limit (Legacy format) if it contains an Antigravity announcement', async () => {
const antigravityBannerData = {
defaultText: 'Antigravity is coming to town!',
warningText: '',
};

mockedPersistentStateGet.mockReturnValue({
[crypto
.createHash('sha256')
.update(antigravityBannerData.defaultText)
.digest('hex')]: 5,
});

const { result } = await renderHook(() => useBanner(defaultBannerData));
const { result } = await renderHook(() => useBanner(antigravityBannerData));

expect(result.current.bannerText).toBe('');
expect(result.current.bannerText).toBe('Antigravity is coming to town!');
});
Comment on lines +80 to 98

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The cherry-pick or patch modification accidentally truncated the existing test 'should hide banner if show count exceeds max limit (Legacy format)'. This restores the original test's assertion. Additionally, ensure that all banners, including those with warnings or special announcements like Antigravity, are hidden after reaching the maximum display count.

    const { result } = await renderHook(() => useBanner(defaultBannerData));

    expect(result.current.bannerText).toBe('');
  });

  it('should hide banner if show count exceeds max limit (Legacy format) even if it contains an Antigravity announcement', async () => {
    const antigravityBannerData = {
      defaultText: 'Antigravity is coming to town!',
      warningText: '',
    };

    mockedPersistentStateGet.mockReturnValue({
      [crypto
        .createHash('sha256')
        .update(antigravityBannerData.defaultText)
        .digest('hex')]: 5,
    });

    const { result } = await renderHook(() => useBanner(antigravityBannerData));

    expect(result.current.bannerText).toBe('');
  });
References
  1. Banners, including those with warnings, should be hidden after reaching a maximum display count.


it('should increment the persistent count when banner is shown', async () => {
Expand Down
4 changes: 3 additions & 1 deletion packages/cli/src/ui/hooks/useBanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ export function useBanner(bannerData: BannerData) {
const currentBannerCount = bannerCounts[hashedText] || 0;

const showBanner =
activeText !== '' && currentBannerCount < DEFAULT_MAX_BANNER_SHOWN_COUNT;
activeText !== '' &&
(currentBannerCount < DEFAULT_MAX_BANNER_SHOWN_COUNT ||
activeText.includes('Antigravity'));

const rawBannerText = showBanner ? activeText : '';
const bannerText = rawBannerText.replace(/\\n/g, '\n');
Expand Down
Loading