Skip to content

Commit d6c5aef

Browse files
authored
Merge branch 'develop' into improv/account_syncing_various_updates
2 parents a743f3a + 71d01b8 commit d6c5aef

File tree

8 files changed

+474
-12
lines changed

8 files changed

+474
-12
lines changed

app/_locales/en/messages.json

+18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
import assert from 'assert';
2+
import { Mockttp, MockedEndpoint } from 'mockttp';
3+
import { withFixtures, regularDelayMs } from '../../helpers';
4+
import FixtureBuilder from '../../fixture-builder';
5+
import HomePage from '../../page-objects/pages/homepage';
6+
import OnboardingCompletePage from '../../page-objects/pages/onboarding/onboarding-complete-page';
7+
import {
8+
importSRPOnboardingFlow,
9+
createNewWalletOnboardingFlow,
10+
} from '../../page-objects/flows/onboarding.flow';
11+
12+
// Mock function implementation for Token Price requests
13+
async function mockTokenPriceApi(
14+
mockServer: Mockttp,
15+
): Promise<MockedEndpoint[]> {
16+
return [
17+
// mainnet
18+
await mockServer
19+
.forGet('https://price.api.cx.metamask.io/v2/chains/1/spot-prices')
20+
.thenCallback(() => ({
21+
statusCode: 200,
22+
json: {},
23+
})),
24+
// linea
25+
await mockServer
26+
.forGet('https://price.api.cx.metamask.io/v2/chains/59144/spot-prices')
27+
.thenCallback(() => ({
28+
statusCode: 200,
29+
json: {},
30+
})),
31+
];
32+
}
33+
34+
describe('MetaMask onboarding @no-mmi', function () {
35+
it("doesn't make any token price API requests before create new wallet onboarding is completed", async function () {
36+
await withFixtures(
37+
{
38+
fixtures: new FixtureBuilder({ onboarding: true })
39+
.withNetworkControllerOnMainnet()
40+
.build(),
41+
title: this.test?.fullTitle(),
42+
testSpecificMock: mockTokenPriceApi,
43+
},
44+
async ({ driver, mockedEndpoint: mockedEndpoints }) => {
45+
await createNewWalletOnboardingFlow({ driver });
46+
47+
// Check no requests are made before completing creat new wallet onboarding
48+
// Intended delay to ensure we cover at least 1 polling loop of time for the network request
49+
await driver.delay(regularDelayMs);
50+
for (const mockedEndpoint of mockedEndpoints) {
51+
const isPending = await mockedEndpoint.isPending();
52+
assert.equal(
53+
isPending,
54+
true,
55+
`${mockedEndpoint} mock should still be pending before onboarding`,
56+
);
57+
const requests = await mockedEndpoint.getSeenRequests();
58+
assert.equal(
59+
requests.length,
60+
0,
61+
`${mockedEndpoint} should make no requests before onboarding`,
62+
);
63+
}
64+
65+
// complete create new wallet onboarding
66+
const onboardingCompletePage = new OnboardingCompletePage(driver);
67+
await onboardingCompletePage.check_pageIsLoaded();
68+
await onboardingCompletePage.completeOnboarding();
69+
const homePage = new HomePage(driver);
70+
await homePage.check_pageIsLoaded();
71+
72+
// network requests happen here
73+
for (const mockedEndpoint of mockedEndpoints) {
74+
await driver.wait(async () => {
75+
const isPending = await mockedEndpoint.isPending();
76+
return isPending === false;
77+
}, driver.timeout);
78+
79+
const requests = await mockedEndpoint.getSeenRequests();
80+
assert.equal(
81+
requests.length > 0,
82+
true,
83+
`${mockedEndpoint} should make requests after onboarding`,
84+
);
85+
}
86+
},
87+
);
88+
});
89+
90+
it("doesn't make any token price API requests before onboarding by import is completed", async function () {
91+
await withFixtures(
92+
{
93+
fixtures: new FixtureBuilder({ onboarding: true })
94+
.withNetworkControllerOnMainnet()
95+
.build(),
96+
title: this.test?.fullTitle(),
97+
testSpecificMock: mockTokenPriceApi,
98+
},
99+
async ({ driver, mockedEndpoint: mockedEndpoints }) => {
100+
await importSRPOnboardingFlow({ driver });
101+
102+
// Check no requests before completing onboarding
103+
// Intended delay to ensure we cover at least 1 polling loop of time for the network request
104+
await driver.delay(regularDelayMs);
105+
for (const mockedEndpoint of mockedEndpoints) {
106+
const requests = await mockedEndpoint.getSeenRequests();
107+
assert.equal(
108+
requests.length,
109+
0,
110+
`${mockedEndpoint} should make no requests before import wallet onboarding complete`,
111+
);
112+
}
113+
114+
// complete import wallet onboarding
115+
const onboardingCompletePage = new OnboardingCompletePage(driver);
116+
await onboardingCompletePage.check_pageIsLoaded();
117+
await onboardingCompletePage.completeOnboarding();
118+
const homePage = new HomePage(driver);
119+
await homePage.check_pageIsLoaded();
120+
121+
// requests happen here
122+
for (const mockedEndpoint of mockedEndpoints) {
123+
await driver.wait(async () => {
124+
const isPending = await mockedEndpoint.isPending();
125+
return isPending === false;
126+
}, driver.timeout);
127+
128+
const requests = await mockedEndpoint.getSeenRequests();
129+
assert.equal(
130+
requests.length > 0,
131+
true,
132+
`${mockedEndpoint} should make requests after onboarding`,
133+
);
134+
}
135+
},
136+
);
137+
});
138+
});

ui/pages/confirmations/components/confirm/info/shared/static-simulation/static-simulation.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ import Preloader from '../../../../../../../components/ui/icon/preloader';
1515
const StaticSimulation: React.FC<{
1616
title: string;
1717
titleTooltip: string;
18-
description: string;
18+
description?: string;
1919
simulationElements: React.ReactNode;
2020
isLoading?: boolean;
2121
}> = ({ title, titleTooltip, description, simulationElements, isLoading }) => {
2222
return (
2323
<ConfirmInfoSection data-testid="confirmation__simulation_section">
2424
<ConfirmInfoRow label={title} tooltip={titleTooltip}>
25-
<ConfirmInfoRowText text={description} />
25+
{description && <ConfirmInfoRowText text={description} />}
2626
</ConfirmInfoRow>
2727
{isLoading ? (
2828
<Box display={Display.Flex} justifyContent={JustifyContent.center}>

ui/pages/confirmations/components/confirm/info/typed-sign/permit-simulation/__snapshots__/permit-simulation.test.tsx.snap

+80-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,86 @@
22

33
exports[`PermitSimulation should not render default simulation if decodingLoading is true 1`] = `
44
<div>
5-
<div>
6-
"DECODED SIMULATION IMPLEMENTATION"
5+
<div
6+
class="mm-box mm-box--margin-bottom-4 mm-box--padding-2 mm-box--background-color-background-default mm-box--rounded-md"
7+
data-testid="confirmation__simulation_section"
8+
>
9+
<div
10+
class="mm-box confirm-info-row mm-box--margin-top-2 mm-box--margin-bottom-2 mm-box--padding-right-2 mm-box--padding-left-2 mm-box--display-flex mm-box--flex-direction-row mm-box--flex-wrap-wrap mm-box--justify-content-space-between mm-box--align-items-center mm-box--color-text-default mm-box--rounded-lg"
11+
style="overflow-wrap: anywhere; min-height: 24px; position: relative;"
12+
>
13+
<div
14+
class="mm-box mm-box--display-flex mm-box--flex-direction-row mm-box--justify-content-center mm-box--align-items-flex-start"
15+
>
16+
<div
17+
class="mm-box mm-box--display-flex mm-box--align-items-center"
18+
>
19+
<p
20+
class="mm-box mm-text mm-text--body-md-medium mm-box--color-inherit"
21+
>
22+
Estimated changes
23+
</p>
24+
<div>
25+
<div
26+
aria-describedby="tippy-tooltip-5"
27+
class=""
28+
data-original-title="Estimated changes are what might happen if you go through with this transaction. This is just a prediction, not a guarantee."
29+
data-tooltipped=""
30+
style="display: flex;"
31+
tabindex="0"
32+
>
33+
<span
34+
class="mm-box mm-icon mm-icon--size-sm mm-box--margin-left-1 mm-box--display-inline-block mm-box--color-icon-muted"
35+
style="mask-image: url('./images/icons/question.svg');"
36+
/>
37+
</div>
38+
</div>
39+
</div>
40+
</div>
41+
</div>
42+
<div
43+
class="mm-box mm-box--display-flex mm-box--justify-content-center"
44+
>
45+
<svg
46+
class="preloader__icon"
47+
fill="none"
48+
height="20"
49+
viewBox="0 0 16 16"
50+
width="20"
51+
xmlns="http://www.w3.org/2000/svg"
52+
>
53+
<path
54+
clip-rule="evenodd"
55+
d="M8 13.7143C4.84409 13.7143 2.28571 11.1559 2.28571 8C2.28571 4.84409 4.84409 2.28571 8 2.28571C11.1559 2.28571 13.7143 4.84409 13.7143 8C13.7143 11.1559 11.1559 13.7143 8 13.7143ZM8 16C3.58172 16 0 12.4183 0 8C0 3.58172 3.58172 0 8 0C12.4183 0 16 3.58172 16 8C16 12.4183 12.4183 16 8 16Z"
56+
fill="var(--color-primary-muted)"
57+
fill-rule="evenodd"
58+
/>
59+
<mask
60+
height="16"
61+
id="mask0"
62+
mask-type="alpha"
63+
maskUnits="userSpaceOnUse"
64+
width="16"
65+
x="0"
66+
y="0"
67+
>
68+
<path
69+
clip-rule="evenodd"
70+
d="M8 13.7143C4.84409 13.7143 2.28571 11.1559 2.28571 8C2.28571 4.84409 4.84409 2.28571 8 2.28571C11.1559 2.28571 13.7143 4.84409 13.7143 8C13.7143 11.1559 11.1559 13.7143 8 13.7143ZM8 16C3.58172 16 0 12.4183 0 8C0 3.58172 3.58172 0 8 0C12.4183 0 16 3.58172 16 8C16 12.4183 12.4183 16 8 16Z"
71+
fill="var(--color-primary-default)"
72+
fill-rule="evenodd"
73+
/>
74+
</mask>
75+
<g
76+
mask="url(#mask0)"
77+
>
78+
<path
79+
d="M6.85718 17.9999V11.4285V8.28564H-4.85711V17.9999H6.85718Z"
80+
fill="var(--color-primary-default)"
81+
/>
82+
</g>
83+
</svg>
84+
</div>
785
</div>
886
</div>
987
`;

ui/pages/confirmations/components/confirm/info/typed-sign/permit-simulation/decoded-simulation/__snapshots__/decoded-simulation.test.tsx.snap

+98-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,104 @@
22

33
exports[`DecodedSimulation renders component correctly 1`] = `
44
<div>
5-
<div>
6-
"DECODED SIMULATION IMPLEMENTATION"
5+
<div
6+
class="mm-box mm-box--margin-bottom-4 mm-box--padding-2 mm-box--background-color-background-default mm-box--rounded-md"
7+
data-testid="confirmation__simulation_section"
8+
>
9+
<div
10+
class="mm-box confirm-info-row mm-box--margin-top-2 mm-box--margin-bottom-2 mm-box--padding-right-2 mm-box--padding-left-2 mm-box--display-flex mm-box--flex-direction-row mm-box--flex-wrap-wrap mm-box--justify-content-space-between mm-box--align-items-center mm-box--color-text-default mm-box--rounded-lg"
11+
style="overflow-wrap: anywhere; min-height: 24px; position: relative;"
12+
>
13+
<div
14+
class="mm-box mm-box--display-flex mm-box--flex-direction-row mm-box--justify-content-center mm-box--align-items-flex-start"
15+
>
16+
<div
17+
class="mm-box mm-box--display-flex mm-box--align-items-center"
18+
>
19+
<p
20+
class="mm-box mm-text mm-text--body-md-medium mm-box--color-inherit"
21+
>
22+
Estimated changes
23+
</p>
24+
<div>
25+
<div
26+
aria-describedby="tippy-tooltip-1"
27+
class=""
28+
data-original-title="Estimated changes are what might happen if you go through with this transaction. This is just a prediction, not a guarantee."
29+
data-tooltipped=""
30+
style="display: flex;"
31+
tabindex="0"
32+
>
33+
<span
34+
class="mm-box mm-icon mm-icon--size-sm mm-box--margin-left-1 mm-box--display-inline-block mm-box--color-icon-muted"
35+
style="mask-image: url('./images/icons/question.svg');"
36+
/>
37+
</div>
38+
</div>
39+
</div>
40+
</div>
41+
</div>
42+
<div
43+
class="mm-box"
44+
>
45+
<p
46+
class="mm-box mm-text mm-text--body-md-medium mm-box--margin-left-2 mm-box--color-inherit"
47+
>
48+
Spending cap
49+
</p>
50+
<div
51+
class="mm-box"
52+
>
53+
<div
54+
class="mm-box mm-box--display-flex mm-box--justify-content-flex-end"
55+
>
56+
<div
57+
class="mm-box mm-box--margin-inline-end-1 mm-box--display-inline mm-box--min-width-0"
58+
>
59+
<div
60+
style="min-width: 0;"
61+
>
62+
<div
63+
aria-describedby="tippy-tooltip-2"
64+
class=""
65+
data-original-title="1,461,501,637,330,902,918,203,684,832,716,283,019,655,932,542,975"
66+
data-tooltipped=""
67+
style="display: inline;"
68+
tabindex="0"
69+
>
70+
<p
71+
class="mm-box mm-text mm-text--body-md mm-text--text-align-center mm-box--padding-inline-2 mm-box--color-text-default mm-box--background-color-background-alternative mm-box--rounded-xl"
72+
data-testid="simulation-token-value"
73+
style="padding-top: 1px; padding-bottom: 1px;"
74+
>
75+
1,461,501,637,3...
76+
</p>
77+
</div>
78+
</div>
79+
</div>
80+
<div
81+
class="mm-box mm-box--display-flex"
82+
>
83+
<div
84+
class="name name__missing"
85+
>
86+
<span
87+
class="mm-box name__icon mm-icon mm-icon--size-md mm-box--display-inline-block mm-box--color-inherit"
88+
style="mask-image: url('./images/icons/question.svg');"
89+
/>
90+
<p
91+
class="mm-box mm-text name__value mm-text--body-md mm-box--color-text-default"
92+
>
93+
0x6B175...71d0F
94+
</p>
95+
</div>
96+
</div>
97+
</div>
98+
<div
99+
class="mm-box"
100+
/>
101+
</div>
102+
</div>
7103
</div>
8104
</div>
9105
`;

0 commit comments

Comments
 (0)