Skip to content

Commit f480dc0

Browse files
fix: NTP Privacy Stats widget number formatting (#1735)
* fix: OtherText number formatting * chore: Adjust the mock to display the change * test: Update snapshots * fix: text test * more snapshots --------- Co-authored-by: Shane Osbourne <shane.osbourne8@gmail.com>
1 parent 69f6c7a commit f480dc0

File tree

8 files changed

+6
-3
lines changed

8 files changed

+6
-3
lines changed

special-pages/pages/new-tab/app/privacy-stats/components/PrivacyStats.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,9 @@ function PillShowMoreLess({ expansion }) {
207207
*/
208208
export function OtherText({ count }) {
209209
const { t } = useTypedTranslationWith(/** @type {Strings} */ ({}));
210-
const otherText = t('stats_otherCount', { count: String(count) });
210+
const [formatter] = useState(() => new Intl.NumberFormat());
211+
const formattedCount = formatter.format(count);
212+
213+
const otherText = t('stats_otherCount', { count: String(formattedCount) });
211214
return <div class={styles.otherTrackersRow}>{otherText}</div>;
212215
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ test.describe('newtab privacy stats', () => {
2626
expect(await listItems.nth(2).textContent()).toBe('Amazon67');
2727
expect(await listItems.nth(3).textContent()).toBe('Google Ads2');
2828

29-
await expect(psp.listFooter()).toHaveText('210 attempts from other networks');
29+
await expect(psp.listFooter()).toHaveText('2,100 attempts from other networks');
3030

3131
// show/hide
3232
await page.getByLabel('Hide recent activity').click();

special-pages/pages/new-tab/app/privacy-stats/mocks/privacy-stats.mocks.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const privacyStatsMocks = {
2828
},
2929
{
3030
displayName: DDG_STATS_OTHER_COMPANY_IDENTIFIER,
31-
count: 210,
31+
count: 2100,
3232
},
3333
{
3434
displayName: 'Amazon.com',
Loading
Loading
Loading
-39 Bytes
Loading
-8 Bytes
Loading

0 commit comments

Comments
 (0)