From 74c1ee22252044d6a21d63547e200da68afc2e1d Mon Sep 17 00:00:00 2001 From: Prithpal Sooriya Date: Mon, 23 Sep 2024 19:27:37 +0100 Subject: [PATCH] feat: add user-storage to privacy snapshot and update user-storage mocks (#27292) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit note - we need to update our library to support generic paths and mock X-Sync data features ## **Description** This fixes the flaky test for updating the privacy snapshot for user-storage API. We also better mock the user-storage API to fail fast when testing Account-Syncing. NOTE - we need to update our library to support generic paths, and also have mock data for testing the X-Syncing features (account syncing, network syncing, notification syncing, asset syncing). [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/27292?quickstart=1) ## **Related issues** Fixes: ## **Manual testing steps** 1. Go to this page... 2. 3. ## **Screenshots/Recordings** ### **Before** ### **After** ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [x] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [x] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. --- privacy-snapshot.json | 3 ++- test/e2e/tests/notifications/mocks.ts | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/privacy-snapshot.json b/privacy-snapshot.json index 3b4ded67481c..48c96582cab0 100644 --- a/privacy-snapshot.json +++ b/privacy-snapshot.json @@ -58,5 +58,6 @@ "oidc.api.cx.metamask.io", "price.api.cx.metamask.io", "token.api.cx.metamask.io", - "client-side-detection.api.cx.metamask.io" + "client-side-detection.api.cx.metamask.io", + "user-storage.api.cx.metamask.io" ] diff --git a/test/e2e/tests/notifications/mocks.ts b/test/e2e/tests/notifications/mocks.ts index 5cceee276436..9161faf2967f 100644 --- a/test/e2e/tests/notifications/mocks.ts +++ b/test/e2e/tests/notifications/mocks.ts @@ -34,6 +34,19 @@ export async function mockNotificationServices(server: Mockttp) { mockAPICall(server, await StorageMocks.getMockUserStorageGetResponse()); mockAPICall(server, await StorageMocks.getMockUserStoragePutResponse()); + // TODO - add better mock responses for other Profile Sync features + // (Account Sync, Network Sync, ...) + server + .forGet(/https:\/\/user-storage\.api\.cx\.metamask\.io\/.*/gu) + ?.thenCallback(() => ({ + statusCode: 404, + })); + server + .forPut(/https:\/\/user-storage\.api\.cx\.metamask\.io\/.*/gu) + ?.thenCallback(() => ({ + statusCode: 204, + })); + // Notifications mockAPICall(server, NotificationMocks.getMockFeatureAnnouncementResponse()); mockAPICall(server, NotificationMocks.getMockBatchCreateTriggersResponse());