Skip to content

Commit 60cf491

Browse files
committed
fix: remove delay and wait for accounts to be synced
1 parent 32e6368 commit 60cf491

File tree

4 files changed

+71
-10
lines changed

4 files changed

+71
-10
lines changed

test/e2e/tests/identity/account-syncing/new-user-sync.spec.ts

+14-2
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,20 @@ describe('Account syncing - New User', function () {
6363
accountType: ACCOUNT_TYPE.Ethereum,
6464
accountName: secondAccountName,
6565
});
66-
// Add a delay to allow the account to sync, this can be long for MV2
67-
await driver.delay(2000);
66+
// Wait for the account to be synced
67+
await driver.waitUntil(
68+
async () => {
69+
return (
70+
userStorageMockttpController.paths.get(
71+
USER_STORAGE_FEATURE_NAMES.accounts,
72+
)?.response.length === 2
73+
);
74+
},
75+
{
76+
timeout: 5000,
77+
interval: 500,
78+
},
79+
);
6880

6981
// Set SRP to use for retreival
7082
const headerNavbar = new HeaderNavbar(driver);

test/e2e/tests/identity/account-syncing/onboarding-with-opt-out.spec.ts

+14-2
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,20 @@ describe('Account syncing - Opt-out Profile Sync', function () {
165165
accountType: ACCOUNT_TYPE.Ethereum,
166166
accountName: 'New Account',
167167
});
168-
// Add a delay to allow the account to sync, this can be long for MV2
169-
await driver.delay(2000);
168+
// Wait for the account to be synced
169+
await driver.waitUntil(
170+
async () => {
171+
return (
172+
userStorageMockttpController.paths.get(
173+
USER_STORAGE_FEATURE_NAMES.accounts,
174+
)?.response.length === 3
175+
);
176+
},
177+
{
178+
timeout: 5000,
179+
interval: 500,
180+
},
181+
);
170182

171183
// Set SRP to use for retreival
172184
const headerNavbar = new HeaderNavbar(driver);

test/e2e/tests/identity/account-syncing/sync-after-adding-account.spec.ts

+28-4
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,20 @@ describe('Account syncing - Add Account', function () {
8888
accountType: ACCOUNT_TYPE.Ethereum,
8989
accountName: customNameAccount3,
9090
});
91-
// Add a delay to allow the account to sync, this can be long for MV2
92-
await driver.delay(2000);
91+
// Wait for the account to be synced
92+
await driver.waitUntil(
93+
async () => {
94+
return (
95+
userStorageMockttpController.paths.get(
96+
USER_STORAGE_FEATURE_NAMES.accounts,
97+
)?.response.length === 3
98+
);
99+
},
100+
{
101+
timeout: 5000,
102+
interval: 500,
103+
},
104+
);
93105
},
94106
);
95107

@@ -184,8 +196,20 @@ describe('Account syncing - Add Account', function () {
184196
await accountListPage.addAccount({
185197
accountType: ACCOUNT_TYPE.Ethereum,
186198
});
187-
// Add a delay to allow the account to sync, this can be long for MV2
188-
await driver.delay(2000);
199+
// Wait for the account to be synced
200+
await driver.waitUntil(
201+
async () => {
202+
return (
203+
userStorageMockttpController.paths.get(
204+
USER_STORAGE_FEATURE_NAMES.accounts,
205+
)?.response.length === 3
206+
);
207+
},
208+
{
209+
timeout: 5000,
210+
interval: 500,
211+
},
212+
);
189213
},
190214
);
191215

test/e2e/tests/identity/account-syncing/sync-with-account-balances.spec.ts

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Mockttp } from 'mockttp';
2+
import { USER_STORAGE_FEATURE_NAMES } from '@metamask/profile-sync-controller/sdk';
23
import { unlockWallet, withFixtures } from '../../../helpers';
34
import FixtureBuilder from '../../../fixture-builder';
45
import { mockInfuraAndAccountSync } from '../mocks';
@@ -135,8 +136,20 @@ describe('Account syncing - User already has balances on multiple accounts', fun
135136
await accountListPage.addAccount({
136137
accountType: ACCOUNT_TYPE.Ethereum,
137138
});
138-
// Add a delay to allow the account to sync, this can be long for MV2
139-
await driver.delay(2000);
139+
// Wait for the account to be synced
140+
await driver.waitUntil(
141+
async () => {
142+
return (
143+
userStorageMockttpController.paths.get(
144+
USER_STORAGE_FEATURE_NAMES.accounts,
145+
)?.response.length === 5
146+
);
147+
},
148+
{
149+
timeout: 5000,
150+
interval: 500,
151+
},
152+
);
140153

141154
accountsToMockBalances = [
142155
...INITIAL_ACCOUNTS,

0 commit comments

Comments
 (0)