Skip to content

Commit ee3a4ae

Browse files
committed
Fix no message for zero trackers
Bug: Tracker Status UI: No Message for Zero Trackers. The TrackerStatus function computes totalTrackersPillText for the zero-trackers case but never displays it. When totalTrackersBlocked === 0, the condition {totalTrackersBlocked > 0 && <TickPill .../>} prevents rendering any tracker status message. The legacy TrackerStatusLegacy displays "No trackers blocked" or "No trackers found" in this scenario, but the new implementation shows nothing, breaking the expected UI behavior for sites with no blocked trackers. #2039 (comment)
1 parent 66366e3 commit ee3a4ae

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed

special-pages/pages/new-tab/app/activity/components/Activity.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ function TrackerStatus({ id, trackersFound }) {
253253
return (
254254
<div class={styles.companiesIconRow} data-testid="TrackerStatus">
255255
<div class={styles.companiesText}>
256-
{totalTrackersBlocked > 0 && <TickPill text={totalTrackersPillText} />}
256+
<TickPill text={totalTrackersPillText} />
257257
{cookiePopUpBlocked && <TickPill text={t('activity_cookiePopUpBlocked')} />}
258258
</div>
259259
</div>

special-pages/pages/new-tab/app/activity/integration-tests/activity.page.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,41 @@ export class ActivityPage {
395395
`);
396396
}
397397

398+
/**
399+
* Test that the new TrackerStatus component displays zero-tracker messages when CPM is enabled
400+
*/
401+
async showsZeroTrackerMessagesWithCpm() {
402+
// Twitter has trackersFound: true, totalCount: 0 → should show "No trackers blocked"
403+
await expect(this.context().getByTestId('ActivityItem').nth(3)).toMatchAriaSnapshot(`
404+
- listitem:
405+
- link "twitter.com"
406+
- button "Add twitter.com to favorites":
407+
- img
408+
- button "Clear browsing history and data for twitter.com":
409+
- img
410+
- text: No trackers blocked
411+
- list:
412+
- listitem:
413+
- link "Trending Topics"
414+
- text: 2 days ago
415+
`);
416+
417+
// LinkedIn has trackersFound: false, totalCount: 0 → should show "No trackers found"
418+
await expect(this.context().getByTestId('ActivityItem').nth(4)).toMatchAriaSnapshot(`
419+
- listitem:
420+
- link "app.linkedin.com"
421+
- button "Add app.linkedin.com to favorites":
422+
- img
423+
- button "Clear browsing history and data for app.linkedin.com":
424+
- img
425+
- text: No trackers found
426+
- list:
427+
- listitem:
428+
- link "Profile Page"
429+
- text: 2 hrs ago
430+
`);
431+
}
432+
398433
async hasEmptyTrackersOnlyTitle() {
399434
const { page } = this;
400435
await expect(page.getByTestId('ActivityHeading')).toMatchAriaSnapshot(`

special-pages/pages/new-tab/app/activity/integration-tests/activity.spec.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,14 @@ test.describe('activity widget', () => {
116116
await ap.didRender();
117117
await ap.hidesCookiePopupIndicatorWhenNotBlocked();
118118
});
119+
test('shows zero-tracker messages with new component when CPM enabled', async ({ page }, workerInfo) => {
120+
const ntp = NewtabPage.create(page, workerInfo);
121+
const ap = new ActivityPage(page, ntp);
122+
await ntp.reducedMotion();
123+
await ntp.openPage({ additional: { ...defaultPageParams, cpm: 'true' } });
124+
await ap.didRender();
125+
await ap.showsZeroTrackerMessagesWithCpm();
126+
});
119127
test('after rendering and navigating to a new tab, data is re-requested on return', async ({ page }, workerInfo) => {
120128
const ntp = NewtabPage.create(page, workerInfo);
121129
const ap = new ActivityPage(page, ntp);

0 commit comments

Comments
 (0)