Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@
request: Pick<CompletedRequest, 'path' | 'headers'>,
statusCode: number = 200,
) => {
// #region agent log
console.log(`[SYNC_DEBUG:onGet] path=${path}, url=${request.path}`);
// #endregion
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug console.log statements accidentally committed

Low Severity

Multiple console.log statements with [SYNC_DEBUG:...] prefixes wrapped in // #region agent log comments have been added across several files. These appear to be temporary debugging statements used during development that were not removed before committing. The coding guidelines specify to remove console.logs before committing.

Additional Locations (2)

Fix in Cursor Fix in Web

const srpIdentifier = getSrpIdentifierFromHeaders(request.headers);
const internalPathData = this.paths.get(path);

Expand Down Expand Up @@ -154,6 +157,9 @@
request: Pick<CompletedRequest, 'path' | 'body' | 'headers'>,
statusCode: number = 204,
) => {
// #region agent log
console.log(`[SYNC_DEBUG:onPut] path=${path}, url=${request.path}`);
// #endregion
const srpIdentifier = getSrpIdentifierFromHeaders(request.headers);
const isFeatureEntry = determineIfFeatureEntryFromURL(request.path);

Expand Down Expand Up @@ -330,6 +336,15 @@
},
) => {
const previouslySetupPath = this.paths.get(path);
// #region agent log
const hadPreviousData = !!previouslySetupPath;

Check failure on line 340 in test/e2e/helpers/identity/user-storage/userStorageMockttpController.ts

View workflow job for this annotation

GitHub Actions / test-lint / Test lint

use `Boolean(previouslySetupPath)` instead
const previousResponseCount = previouslySetupPath?.response?.length ?? 0;
const newResponseCount =
overrides?.getResponse?.length ?? previousResponseCount;
console.log(
`[SYNC_DEBUG:setupPath] path=${path}, hadPreviousData=${hadPreviousData}, previousResponseCount=${previousResponseCount}, newResponseCount=${newResponseCount}`,
);
// #endregion

this.paths.set(path, {
response: overrides?.getResponse || previouslySetupPath?.response || [],
Expand Down Expand Up @@ -357,5 +372,8 @@
.thenCallback((request) =>
this.onDelete(path, request, overrides?.deleteStatusCode),
);
// #region agent log
console.log(`[SYNC_DEBUG:setupPath] Handlers registered for path=${path}`);
// #endregion
};
}
17 changes: 17 additions & 0 deletions test/e2e/page-objects/pages/home/homepage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -453,9 +453,26 @@ class HomePage {
);
await this.driver.delay(POST_UNLOCK_DELAY);
console.log('Check if account syncing has synced at least once');
// #region agent log
let pollCount = 0;
// #endregion
await this.driver.waitUntil(
async () => {
const uiState = await getCleanAppState(this.driver);
// #region agent log
pollCount += 1;
const syncState =
uiState?.metamask?.hasAccountTreeSyncingSyncedAtLeastOnce;
const isSignedIn = uiState?.metamask?.isSignedIn;
const isUnlocked = uiState?.metamask?.isUnlocked;
const isBackupAndSyncEnabled =
uiState?.metamask?.isBackupAndSyncEnabled;
const isAccountSyncingEnabled =
uiState?.metamask?.isAccountSyncingEnabled;
console.log(
`[SYNC_DEBUG:poll#${pollCount}] syncState=${syncState}, isSignedIn=${isSignedIn}, isUnlocked=${isUnlocked}, isBackupAndSyncEnabled=${isBackupAndSyncEnabled}, isAccountSyncingEnabled=${isAccountSyncingEnabled}`,
);
// #endregion
// Check for nullish, as the state we might seems to be `null` sometimes.
return (
uiState?.metamask?.hasAccountTreeSyncingSyncedAtLeastOnce === true
Expand Down
69 changes: 17 additions & 52 deletions test/e2e/tests/identity/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,46 +31,22 @@ export async function mockIdentityServices(
mockAPICall(server, AuthMocks.getMockAuthAccessTokenResponse());

// Storage
if (
!userStorageMockttpControllerInstance?.paths.get(
USER_STORAGE_FEATURE_NAMES.accounts,
)
) {
userStorageMockttpControllerInstance.setupPath(
USER_STORAGE_FEATURE_NAMES.accounts,
server,
);
}
if (
!userStorageMockttpControllerInstance?.paths.get(
USER_STORAGE_FEATURE_NAMES.addressBook,
)
) {
userStorageMockttpControllerInstance.setupPath(
USER_STORAGE_FEATURE_NAMES.addressBook,
server,
);
}
if (
!userStorageMockttpControllerInstance?.paths.get(
USER_STORAGE_WALLETS_FEATURE_KEY,
)
) {
userStorageMockttpControllerInstance.setupPath(
USER_STORAGE_WALLETS_FEATURE_KEY,
server,
);
}
if (
!userStorageMockttpControllerInstance?.paths.get(
USER_STORAGE_GROUPS_FEATURE_KEY,
)
) {
userStorageMockttpControllerInstance.setupPath(
USER_STORAGE_GROUPS_FEATURE_KEY,
server,
);
}
userStorageMockttpControllerInstance.setupPath(
USER_STORAGE_FEATURE_NAMES.accounts,
server,
);
userStorageMockttpControllerInstance.setupPath(
USER_STORAGE_FEATURE_NAMES.addressBook,
server,
);
userStorageMockttpControllerInstance.setupPath(
USER_STORAGE_WALLETS_FEATURE_KEY,
server,
);
userStorageMockttpControllerInstance.setupPath(
USER_STORAGE_GROUPS_FEATURE_KEY,
server,
);
}

export const MOCK_SRP_E2E_IDENTIFIER_BASE_KEY = 'MOCK_SRP_IDENTIFIER';
Expand Down Expand Up @@ -163,17 +139,6 @@ export async function mockInfuraAndAccountSync(
): Promise<void> {
const accounts = options.accountsToMockBalances ?? [];

// Set up User Storage / Account Sync mock
userStorageMockttpController.setupPath(
USER_STORAGE_WALLETS_FEATURE_KEY,
mockServer,
);

userStorageMockttpController.setupPath(
USER_STORAGE_GROUPS_FEATURE_KEY,
mockServer,
);

// Account Balances
if (accounts.length > 0) {
accounts.forEach((account) => {
Expand All @@ -195,7 +160,7 @@ export async function mockInfuraAndAccountSync(
});
}

mockIdentityServices(mockServer, userStorageMockttpController);
await mockIdentityServices(mockServer, userStorageMockttpController);
}

/**
Expand Down
Loading