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
44 changes: 6 additions & 38 deletions src/amo/pages/UserProfileEdit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ import type {
ReactRouterMatchType,
} from 'amo/types/router';
import { setViewContext } from 'amo/actions/viewContext';
import { isMzaBranding } from 'amo/utils/fxa';

import './styles.scss';

Expand Down Expand Up @@ -542,35 +541,9 @@ export class UserProfileEditBase extends React.Component<InternalProps, State> {
const userProfileURL = `/user/${userId}/`;
const overlayClassName = 'UserProfileEdit-deletion-modal';

const title = isMzaBranding()
? i18n.gettext(
'Firefox Accounts was renamed to Mozilla accounts on Nov 1',
)
: i18n.gettext(
'Firefox Accounts will be renamed to Mozilla accounts on Nov 1',
);

return (
<Page>
{alternateOutput || [
<div
className="UserProfileEdit-notice-wrapper"
key="UserProfileEdit-notice-wrapper"
>
<Notice
actionHref="https://support.mozilla.org/kb/firefox-accounts-renamed-mozilla-accounts"
actionTarget="_blank"
actionText={i18n.gettext('Learn more')}
className="UserProfileEdit-fxa-notice"
type="warning"
>
<strong>{title}</strong>
<br />
{i18n.gettext(`You will still sign in with the same username and
password, and there are no other changes to the products that
you use.`)}
</Notice>
</div>,
{alternateOutput || (
<div className="UserProfileEdit" key="UserProfileEdit">
{user && (
<Helmet>
Expand Down Expand Up @@ -639,11 +612,8 @@ export class UserProfileEditBase extends React.Component<InternalProps, State> {
// eslint-disable-next-line react/no-danger
dangerouslySetInnerHTML={sanitizeHTML(
i18n.sprintf(
isMzaBranding()
? i18n.gettext(`You can change your email address on
Mozilla accounts. %(startLink)sNeed help?%(endLink)s`)
: i18n.gettext(`You can change your email address on
Firefox Accounts. %(startLink)sNeed help?%(endLink)s`),
i18n.gettext(`You can change your email address on
Mozilla accounts. %(startLink)sNeed help?%(endLink)s`),
{
startLink:
'<a href="https://support.mozilla.org/kb/change-primary-email-address-firefox-accounts">',
Expand All @@ -661,9 +631,7 @@ export class UserProfileEditBase extends React.Component<InternalProps, State> {
href={user.fxa_edit_email_url}
className="UserProfileEdit-manage-account-link"
>
{isMzaBranding()
? i18n.gettext('Manage Mozilla accounts…')
: i18n.gettext('Manage Firefox Accounts…')}
{i18n.gettext('Manage Mozilla accounts…')}
</a>
)}
</div>
Expand Down Expand Up @@ -933,8 +901,8 @@ export class UserProfileEditBase extends React.Component<InternalProps, State> {
</div>
</OverlayCard>
)}
</div>,
]}
</div>
)}
</Page>
);
}
Expand Down
8 changes: 0 additions & 8 deletions src/amo/pages/UserProfileEdit/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@

$font-size-aside: $font-size-xs;

.UserProfileEdit-notice-wrapper {
@include page-padding;

@include respond-to(large) {
margin-bottom: -$padding-page;
}
}

.UserProfileEdit {
@include page-padding;

Expand Down
6 changes: 0 additions & 6 deletions src/amo/utils/fxa.js

This file was deleted.

101 changes: 0 additions & 101 deletions tests/unit/amo/pages/TestUserProfileEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { createMemoryHistory } from 'history';
import userEvent from '@testing-library/user-event';
import { createEvent, fireEvent, waitFor } from '@testing-library/react';

import * as MzAUtils from 'amo/utils/fxa';
import { setViewContext } from 'amo/actions/viewContext';
import { createApiError } from 'amo/api/index';
import { extractId } from 'amo/pages/UserProfileEdit';
Expand Down Expand Up @@ -54,7 +53,6 @@ describe(__filename, () => {
const defaultUserId = fakeAuthors[0].id;
let history;
let store;
let isMzaBrandingMock;

const savedLocation = window.location;

Expand All @@ -65,14 +63,10 @@ describe(__filename, () => {
assign: jest.fn(),
});
window.scroll = jest.fn();
isMzaBrandingMock = jest
.spyOn(MzAUtils, 'isMzaBranding')
.mockReturnValue(true);
});

afterEach(() => {
window.location = savedLocation;
isMzaBrandingMock.mockRestore();
});

function defaultUserProps(props = {}) {
Expand Down Expand Up @@ -1413,99 +1407,4 @@ describe(__filename, () => {
).not.toHaveClass('UserProfileEditPicture-file--has-focus');
});
});

describe('Tests for accounts branding', () => {
it('renders the Mozilla accounts Branding', () => {
isMzaBrandingMock.mockReturnValue(true);
renderForCurrentUser();

expect(
screen.getByRole('link', {
name: 'Manage Mozilla accounts…',
}),
).toBeInTheDocument();
expect(
screen.getByTextAcrossTags(
'You can change your email address on Mozilla accounts. Need help?',
),
).toBeInTheDocument();

const bannerElement = screen.getByClassName('UserProfileEdit-fxa-notice');
expect(bannerElement).toBeInTheDocument();
expect(bannerElement).toHaveTextContent(
'Firefox Accounts was renamed to Mozilla accounts on Nov 1',
);
});

it('renders the Firefox Accounts Branding', () => {
isMzaBrandingMock.mockReturnValue(false);
renderForCurrentUser();

expect(
screen.getByRole('link', {
name: 'Manage Firefox Accounts…',
}),
).toBeInTheDocument();
expect(
screen.getByTextAcrossTags(
'You can change your email address on Firefox Accounts. Need help?',
),
).toBeInTheDocument();

const bannerElement = screen.getByClassName('UserProfileEdit-fxa-notice');
expect(bannerElement).toBeInTheDocument();
expect(bannerElement).toHaveTextContent(
'Firefox Accounts will be renamed to Mozilla accounts on Nov 1',
);
});
});

describe('isMzaBranding datetime switch', () => {
let dateMock;

beforeEach(() => {
isMzaBrandingMock.mockRestore();
});

afterEach(() => {
dateMock?.mockRestore();
});

it('returns false if the date is earlier than MZA_LAUNCH_DATETIME', () => {
const before = new Date();
before.setTime(MzAUtils.MZA_LAUNCH_DATETIME.getTime() - 1000);
dateMock = jest.spyOn(global, 'Date').mockImplementation(() => before);
expect(MzAUtils.isMzaBranding()).toBe(false);
});

it('returns true if the date is earlier than MZA_LAUNCH_DATETIME', () => {
const after = new Date();
after.setTime(MzAUtils.MZA_LAUNCH_DATETIME.getTime() + 1000);
dateMock = jest.spyOn(global, 'Date').mockImplementation(() => after);
expect(MzAUtils.isMzaBranding()).toBe(true);
});
});

describe('fxa banner tests', () => {
it('renders the banner on the page', () => {
renderForCurrentUser();

const bannerElement = screen.getByClassName('UserProfileEdit-fxa-notice');
expect(bannerElement).toBeInTheDocument();

expect(bannerElement).toHaveTextContent(
'Firefox Accounts was renamed to Mozilla accounts on Nov 1',
);
expect(bannerElement).toHaveTextContent(
'You will still sign in with the same username and password, and there are no other changes to the products that you use.',
);

const infoLink = screen.getByClassName('Notice-button');
expect(infoLink).toBeInTheDocument();
expect(infoLink).toHaveAttribute(
'href',
'https://support.mozilla.org/kb/firefox-accounts-renamed-mozilla-accounts',
);
});
});
});