This commit is contained in:
Valerie Pomerleau 2024-08-06 23:31:04 -07:00
Родитель bded1df1da
Коммит c9f356e204
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 33A451F0BB2180B4
2 изменённых файлов: 85 добавлений и 0 удалений

Просмотреть файл

@ -37,6 +37,44 @@ describe('BentoMenu', () => {
expect(screen.queryByTestId(dropDownId)).not.toBeInTheDocument();
});
it('renders the expected product links', () => {
renderWithLocalizationProvider(<BentoMenu />);
fireEvent.click(screen.getByTestId('drop-down-bento-menu-toggle'));
expect(screen.queryByTestId(dropDownId)).toBeInTheDocument();
expect(
screen.getByRole('link', { name: /Firefox Browser for Desktop/ })
).toHaveAttribute(
'href',
'https://www.mozilla.org/firefox/new/?utm_source=moz-account&utm_medium=mozilla-websites&utm_term=bento&utm_content=fx-desktop&utm_campaign=permanent'
);
expect(
screen.getByRole('link', { name: /Firefox Browser for Mobile/ })
).toHaveAttribute(
'href',
'https://www.mozilla.org/firefox/mobile/?utm_source=moz-account&utm_medium=mozilla-websites&utm_term=bento&utm_content=fx-mobile&utm_campaign=permanent'
);
expect(
screen.getByRole('link', { name: /Mozilla Monitor/ })
).toHaveAttribute(
'href',
'https://monitor.mozilla.org/?utm_source=moz-account&utm_medium=mozilla-websites&utm_term=bento&utm_content=monitor&utm_campaign=permanent'
);
expect(screen.getByRole('link', { name: /Pocket/ })).toHaveAttribute(
'href',
'https://app.adjust.com/hr2n0yz?redirect_macos=https%3A%2F%2Fgetpocket.com%2Fpocket-and-firefox&redirect_windows=https%3A%2F%2Fgetpocket.com%2Fpocket-and-firefox&engagement_type=fallback_click&fallback=https%3A%2F%2Fgetpocket.com%2Ffirefox_learnmore%3Fsrc%3Dff_bento&fallback_lp=https%3A%2F%2Fapps.apple.com%2Fapp%2Fpocket-save-read-grow%2Fid309601447'
);
expect(screen.getByRole('link', { name: /Firefox Relay/ })).toHaveAttribute(
'href',
'https://relay.firefox.com/?utm_source=moz-account&utm_medium=mozilla-websites&utm_term=bento&utm_content=relay&utm_campaign=permanent'
);
expect(screen.getByRole('link', { name: /Mozilla VPN/ })).toHaveAttribute(
'href',
'https://vpn.mozilla.org/?utm_source=moz-account&utm_medium=mozilla-websites&utm_term=bento&utm_content=vpn&utm_campaign=permanent'
);
});
it('closes on esc keypress', () => {
renderWithLocalizationProvider(<BentoMenu />);

Просмотреть файл

@ -3,6 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import {
constructHrefWithUtm,
deepMerge,
isBase32Crockford,
once,
@ -147,3 +148,49 @@ describe('once', () => {
expect(count).toEqual(2);
});
});
describe('constructHrefWithUtm', () => {
test('should construct URL with given UTM parameters', () => {
const pathname = 'https://example.com';
const utmMedium = 'mozilla-websites';
const utmSource = 'moz-account';
const utmTerm = 'bento';
const utmContent = 'fx-desktop';
const utmCampaign = 'permanent';
const result = constructHrefWithUtm(
pathname,
utmMedium,
utmSource,
utmTerm,
utmContent,
utmCampaign
);
const expected =
'https://example.com?utm_source=moz-account&utm_medium=mozilla-websites&utm_term=bento&utm_content=fx-desktop&utm_campaign=permanent';
expect(result).toBe(expected);
});
test('should construct URL with different UTM parameters', () => {
const pathname = 'https://example.com';
const utmMedium = 'product-partnership';
const utmSource = 'moz-account';
const utmTerm = 'sidebar';
const utmContent = 'vpn';
const utmCampaign = 'connect-device';
const result = constructHrefWithUtm(
pathname,
utmMedium,
utmSource,
utmTerm,
utmContent,
utmCampaign
);
const expected =
'https://example.com?utm_source=moz-account&utm_medium=product-partnership&utm_term=sidebar&utm_content=vpn&utm_campaign=connect-device';
expect(result).toBe(expected);
});
});