Skip to content

Commit 401a5e7

Browse files
committed
support trackersFound
1 parent 574a883 commit 401a5e7

File tree

11 files changed

+87
-21
lines changed

11 files changed

+87
-21
lines changed

special-pages/pages/new-tab/app/activity/ActivityProvider.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ export function ActivityProvider(props) {
123123
* @property {string|null|undefined} props.favoriteSrc
124124
* @property {number} props.faviconMax
125125
* @property {string} props.etldPlusOne
126+
* @property {boolean} props.trackersFound
126127
*/
127128

128129
/**
@@ -155,6 +156,7 @@ function normalizeItems(prev, data) {
155156
url: x.url,
156157
faviconMax: x.favicon?.maxAvailableSize ?? DDG_DEFAULT_ICON_SIZE,
157158
favoriteSrc: x.favicon?.src,
159+
trackersFound: x.trackersFound,
158160
};
159161
const differs = shallowDiffers(next, prev.items[x.url] || {});
160162
return [x.url, differs ? next : prev.items[x.url] || {}];

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

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ const BurnableItem = memo(
110110
canBurn={true}
111111
documentVisibility={documentVisibility}
112112
>
113-
<TrackerStatus id={id} />
113+
<TrackerStatus id={id} trackersFound={item.value.trackersFound} />
114114
<HistoryItems id={id} />
115115
</ActivityItem>
116116
</ActivityItemAnimationWrapper>
@@ -138,7 +138,7 @@ const RemovableItem = memo(
138138
canBurn={canBurn}
139139
documentVisibility={documentVisibility}
140140
>
141-
<TrackerStatus id={id} />
141+
<TrackerStatus id={id} trackersFound={item.value.trackersFound} />
142142
<HistoryItems id={id} />
143143
</ActivityItem>
144144
);
@@ -149,20 +149,20 @@ const DDG_MAX_TRACKER_ICONS = 3;
149149
/**
150150
* @param {object} props
151151
* @param {string} props.id
152+
* @param {boolean} props.trackersFound
152153
*/
153-
function TrackerStatus({ id }) {
154+
function TrackerStatus({ id, trackersFound }) {
154155
const { t } = useTypedTranslationWith(/** @type {enStrings} */ ({}));
155156
const { activity } = useContext(SignalStateContext);
156157
const status = useComputed(() => activity.value.trackingStatus[id]);
157158
const other = status.value.trackerCompanies.length - DDG_MAX_TRACKER_ICONS;
158-
const { env } = useEnv();
159-
160-
if (env === 'development') {
161-
console.groupCollapsed(`trackingStatus ${id}`);
162-
console.log(' [total]', status.value.totalCount);
163-
console.log('[companies]', status.value.trackerCompanies);
164-
console.groupEnd();
165-
}
159+
// const { env } = useEnv();
160+
// if (env === 'development') {
161+
// console.groupCollapsed(`trackingStatus ${id}`);
162+
// console.log(' [total]', status.value.totalCount);
163+
// console.log('[companies]', status.value.trackerCompanies);
164+
// console.groupEnd();
165+
// }
166166

167167
const companyIconsMax = other === 0 ? DDG_MAX_TRACKER_ICONS : DDG_MAX_TRACKER_ICONS - 1;
168168
const icons = status.value.trackerCompanies.slice(0, companyIconsMax).map((item, index) => {
@@ -171,7 +171,10 @@ function TrackerStatus({ id }) {
171171

172172
const otherIcon = other > 0 ? <span class={styles.otherIcon}>+{other + 1}</span> : null;
173173

174-
if (status.value.totalCount === 0) return <p>{t('activity_no_trackers')}</p>;
174+
if (status.value.totalCount === 0) {
175+
if (trackersFound) return <p>{t('activity_no_trackers_blocked')}</p>;
176+
return <p>{t('activity_no_trackers')}</p>;
177+
}
175178

176179
return (
177180
<div class={styles.companiesIconRow} data-testid="TrackerStatus">

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const ActivityItem = memo(
2626
*/
2727
function ActivityItem({ canBurn, documentVisibility, title, url, favoriteSrc, faviconMax, etldPlusOne, children }) {
2828
return (
29-
<li key={url} class={cn(styles.item)}>
29+
<li key={url} class={cn(styles.item)} data-testid="ActivityItem">
3030
<div class={styles.heading}>
3131
<a class={styles.favicon} href={url} title={title} data-url={url}>
3232
{documentVisibility === 'visible' && (

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

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,8 @@ export class ActivityPage {
210210
}
211211

212212
async listsAtMost3TrackerCompanies() {
213-
// const { page } = this;
213+
const { page } = this;
214+
await page.pause();
214215
// const first = this.context().getByTestId('TrackerStatus').nth(0);
215216
// const second = this.context().getByTestId('TrackerStatus').nth(1);
216217
// await expect(second).toMatchAriaSnapshot(`
@@ -223,4 +224,34 @@ export class ActivityPage {
223224
// - text: 1 day ago
224225
// `);
225226
}
227+
async showsEmptyTrackerState() {
228+
await expect(this.context().getByTestId('ActivityItem').nth(3)).toMatchAriaSnapshot(`
229+
- listitem:
230+
- link "t w"
231+
- link "twitter.com"
232+
- button "Add twitter.com to favorites":
233+
- img
234+
- button "Clear browsing history and data for twitter.com":
235+
- img
236+
- paragraph: No trackers blocked
237+
- list:
238+
- listitem:
239+
- link "Trending Topics"
240+
- text: 2 days ago`);
241+
242+
await expect(this.context().getByTestId('ActivityItem').nth(4)).toMatchAriaSnapshot(`
243+
- listitem:
244+
- link "l i"
245+
- link "app.linkedin.com"
246+
- button "Add app.linkedin.com to favorites":
247+
- img
248+
- button "Clear browsing history and data for app.linkedin.com":
249+
- img
250+
- paragraph: No trackers found
251+
- list:
252+
- listitem:
253+
- link "Profile Page"
254+
- text: 2 hrs ago
255+
`);
256+
}
226257
}

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
@@ -92,6 +92,14 @@ test.describe('activity widget', () => {
9292
await ap.didRender();
9393
await ap.listsAtMost3TrackerCompanies();
9494
});
95+
test('supported empty trackers states', async ({ page }, workerInfo) => {
96+
const ntp = NewtabPage.create(page, workerInfo);
97+
const ap = new ActivityPage(page, ntp);
98+
await ntp.reducedMotion();
99+
await ntp.openPage({ additional: { feed: 'activity' } });
100+
await ap.didRender();
101+
await ap.showsEmptyTrackerState();
102+
});
95103
test('after rendering and navigating to a new tab, data is re-requested on return', async ({ page }, workerInfo) => {
96104
const ntp = NewtabPage.create(page, workerInfo);
97105
const ap = new ActivityPage(page, ntp);

special-pages/pages/new-tab/app/activity/mocks/activity.mock-transport.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export function activityMockTransport() {
3333
favicon: null,
3434
history: [],
3535
favorite: false,
36+
trackersFound: false,
3637
trackingStatus: { trackerCompanies: [], totalCount: 0 },
3738
title: 'example.com',
3839
});

special-pages/pages/new-tab/app/activity/mocks/activity.mocks.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export const activityMocks = {
1111
title: 'example.com',
1212
etldPlusOne: 'example.com',
1313
favorite: false,
14+
trackersFound: true,
1415
trackingStatus: {
1516
trackerCompanies: [{ displayName: 'Google' }, { displayName: 'Facebook' }, { displayName: 'Amazon' }],
1617
totalCount: 56,
@@ -44,6 +45,7 @@ export const activityMocks = {
4445
title: 'youtube.com',
4546
etldPlusOne: 'youtube.com',
4647
favorite: true,
48+
trackersFound: true,
4749
trackingStatus: {
4850
trackerCompanies: [
4951
{ displayName: 'Google' },
@@ -67,6 +69,7 @@ export const activityMocks = {
6769
title: 'amazon.com',
6870
etldPlusOne: 'amazon.com',
6971
favorite: false,
72+
trackersFound: true,
7073
trackingStatus: {
7174
trackerCompanies: [{ displayName: 'Adobe Analytics' }, { displayName: 'Facebook' }],
7275
totalCount: 12,
@@ -85,9 +88,10 @@ export const activityMocks = {
8588
title: 'twitter.com',
8689
etldPlusOne: 'twitter.com',
8790
favorite: false,
91+
trackersFound: true,
8892
trackingStatus: {
89-
trackerCompanies: [{ displayName: 'Google' }, { displayName: 'Meta' }],
90-
totalCount: 8,
93+
trackerCompanies: [],
94+
totalCount: 0,
9195
},
9296
history: [
9397
{
@@ -103,9 +107,10 @@ export const activityMocks = {
103107
title: 'app.linkedin.com',
104108
etldPlusOne: 'linkedin.com',
105109
favorite: false,
110+
trackersFound: false,
106111
trackingStatus: {
107-
trackerCompanies: [{ displayName: 'LinkedIn Analytics' }],
108-
totalCount: 4,
112+
trackerCompanies: [],
113+
totalCount: 0,
109114
},
110115
history: [
111116
{

special-pages/pages/new-tab/app/activity/strings.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
{
22
"activity_no_trackers": {
33
"title": "No trackers found",
4-
"note": "Placeholder message indicating that no trackers are detected or blocked currently"
4+
"note": "Placeholder message indicating that no trackers are detected"
5+
},
6+
"activity_no_trackers_blocked": {
7+
"title": "No trackers blocked",
8+
"note": "Placeholder message indicating that no trackers are blocked"
59
},
610
"activity_countBlockedPlural": {
711
"title": "<b>{count}</b> tracking attempts blocked",

special-pages/pages/new-tab/messages/types/activity.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
"trackingStatus": {
3434
"$ref": "#/definitions/TrackingStatus"
3535
},
36+
"trackersFound": {
37+
"type": "boolean",
38+
"description": "Indicates whether trackers were found"
39+
},
3640
"history": {
3741
"type": "array",
3842
"items": {
@@ -43,7 +47,7 @@
4347
"type": "boolean"
4448
}
4549
},
46-
"required": ["etldPlusOne", "title", "url", "trackingStatus", "history", "favorite", "favicon"]
50+
"required": ["etldPlusOne", "title", "url", "trackingStatus", "trackersFound", "history", "favorite", "favicon"]
4751
},
4852
"TrackingStatus": {
4953
"type": "object",

special-pages/pages/new-tab/public/locales/en/new-tab.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,11 @@
275275
},
276276
"activity_no_trackers": {
277277
"title": "No trackers found",
278-
"note": "Placeholder message indicating that no trackers are detected or blocked currently"
278+
"note": "Placeholder message indicating that no trackers are detected"
279+
},
280+
"activity_no_trackers_blocked": {
281+
"title": "No trackers blocked",
282+
"note": "Placeholder message indicating that no trackers are blocked"
279283
},
280284
"activity_countBlockedPlural": {
281285
"title": "<b>{count}</b> tracking attempts blocked",

0 commit comments

Comments
 (0)