Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 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
3 changes: 3 additions & 0 deletions app/_locales/en/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions app/_locales/en_GB/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

77 changes: 67 additions & 10 deletions test/e2e/tests/shield/shield-plan-subscription.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,8 @@ describe('Shield Subscription Tests', function () {
},
);
});
});

describe('Shield Settings Subscription', function () {
it('should subscribe to the shield plan from the settings > shield - annual plan', async function () {
it('should shield-plan page redirect to homepage when user clicks back button', async function () {
await withFixtures(
{
fixtures: createShieldFixture().build(),
Expand All @@ -113,16 +111,42 @@ describe('Shield Subscription Tests', function () {
await homePage.clickOnShieldEntryModalGetStarted();

const shieldPlanPage = new ShieldPlanPage(driver);
await shieldPlanPage.checkPageIsLoaded();
await shieldPlanPage.clickBackButton();

await homePage.checkShieldEntryModalIsDisplayed();
},
);
});
});

describe('Shield Settings Subscription', function () {
it('should subscribe to the shield plan from the settings > shield - annual plan', async function () {
await withFixtures(
{
fixtures: createShieldFixture().build(),
title: this.test?.fullTitle(),
testSpecificMock: (server: Mockttp) => {
const shieldMockttpService = new ShieldMockttpService();
return shieldMockttpService.setup(server, {
mockNotEligible: true,
});
},
},
async ({ driver }) => {
await loginWithBalanceValidation(driver);

const homePage = new HomePage(driver);

// open menu and settings
await homePage.headerNavbar.openSettingsPage();
const settingsPage = new SettingsPage(driver);
await settingsPage.checkPageIsLoaded();
await settingsPage.goToTransactionShieldPage();

await homePage.checkShieldEntryModalIsDisplayed();
await homePage.clickOnShieldEntryModalGetStarted();

const shieldPlanPage = new ShieldPlanPage(driver);
await shieldPlanPage.completeShieldPlanSubscriptionFlow('annual');

const shieldDetailPage = new ShieldDetailPage(driver);
Expand All @@ -138,29 +162,62 @@ describe('Shield Subscription Tests', function () {
title: this.test?.fullTitle(),
testSpecificMock: (server: Mockttp) => {
const shieldMockttpService = new ShieldMockttpService();
return shieldMockttpService.setup(server);
return shieldMockttpService.setup(server, {
mockNotEligible: true,
});
},
},
async ({ driver }) => {
await loginWithBalanceValidation(driver);

const homePage = new HomePage(driver);

await homePage.headerNavbar.openSettingsPage();
const settingsPage = new SettingsPage(driver);
await settingsPage.checkPageIsLoaded();
await settingsPage.goToTransactionShieldPage();

await homePage.checkShieldEntryModalIsDisplayed();
await homePage.clickOnShieldEntryModalGetStarted();

const shieldPlanPage = new ShieldPlanPage(driver);
await shieldPlanPage.checkPageIsLoaded();
await shieldPlanPage.clickBackButton();
await shieldPlanPage.completeShieldPlanSubscriptionFlow('monthly');

const shieldDetailPage = new ShieldDetailPage(driver);
await shieldDetailPage.validateShieldDetailPage();
},
);
});

it('should shield-plan page redirect to settings page when user clicks back button', async function () {
await withFixtures(
{
fixtures: createShieldFixture().build(),
title: this.test?.fullTitle(),
testSpecificMock: (server: Mockttp) => {
const shieldMockttpService = new ShieldMockttpService();
return shieldMockttpService.setup(server, {
mockNotEligible: true,
});
},
},
async ({ driver }) => {
await loginWithBalanceValidation(driver);

const homePage = new HomePage(driver);

await homePage.headerNavbar.openSettingsPage();
const settingsPage = new SettingsPage(driver);
await settingsPage.checkPageIsLoaded();
await settingsPage.goToTransactionShieldPage();

await homePage.checkShieldEntryModalIsDisplayed();
await homePage.clickOnShieldEntryModalGetStarted();
await shieldPlanPage.completeShieldPlanSubscriptionFlow('monthly');

const shieldDetailPage = new ShieldDetailPage(driver);
await shieldDetailPage.validateShieldDetailPage();
const shieldPlanPage = new ShieldPlanPage(driver);
await shieldPlanPage.clickBackButton();

await settingsPage.checkPageIsLoaded();
},
);
});
Expand Down
46 changes: 46 additions & 0 deletions ui/components/app/api-error-handler/api-error-handler.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import React from 'react';
import browser from 'webextension-polyfill';
import { useI18nContext } from '../../../hooks/useI18nContext';

Check failure on line 3 in ui/components/app/api-error-handler/api-error-handler.tsx

View workflow job for this annotation

GitHub Actions / test-lint / Test lint

`../../../hooks/useI18nContext` import should occur after import of `classnames`
import {
Box,
Button,
ButtonSize,
ButtonVariant,
Icon,
IconColor,
IconName,
Text,
TextVariant,
} from '@metamask/design-system-react';
import classnames from 'classnames';

const ApiErrorHandler = ({ className = '' }: { className?: string }) => {
const t = useI18nContext();

return (
<Box
className={classnames(
'flex flex-col items-center text-center gap-4',
className,
)}
>
<Icon
className="w-12 h-12"
name={IconName.Error}
color={IconColor.IconAlternative}
/>
<Text variant={TextVariant.BodyMd}>{t('shieldPlanErrorText')}</Text>
<Button
className="w-full"
size={ButtonSize.Lg}
variant={ButtonVariant.Primary}
// this reloads the entire extension
onClick={() => browser.runtime.reload()}
>
{t('tryAgain')}
</Button>
</Box>
);
};

export default ApiErrorHandler;
1 change: 1 addition & 0 deletions ui/components/app/api-error-handler/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './api-error-handler';
5 changes: 5 additions & 0 deletions ui/pages/shield-plan/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
.shield-plan-page {
max-width: 600px;

.shield-plan-page__error-content {
margin-top: 120px;
}


.shield-plan-page__plans {
grid-template-columns: 1fr 1fr;
}
Expand Down
Loading
Loading