From 00d8bf06af36c6f5ad301ebf206fc64b80fb61b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hanno=20J=2E=20G=C3=B6decke?= Date: Fri, 6 Dec 2024 16:18:11 +0100 Subject: [PATCH 1/4] Skip calling specific APIs in the E2E tests --- src/libs/E2E/client.ts | 6 ------ src/libs/E2E/utils/NetworkInterceptor.ts | 7 +++++++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/libs/E2E/client.ts b/src/libs/E2E/client.ts index 3088f280038c..b9965b7da0cb 100644 --- a/src/libs/E2E/client.ts +++ b/src/libs/E2E/client.ts @@ -24,12 +24,6 @@ const defaultRequestInit: RequestInit = { }; const sendRequest = (url: string, data: Record): Promise => { - // Don't process these specific API commands because running them over and over again in the tests hammers the server in a bad way. - if (url.includes('command=OptInToPushNotifications') || url.includes('command=OptOutOfPushNotifications')) { - console.debug('Skipping request to opt in or out of push notifications'); - return Promise.resolve(new Response()); - } - return fetch(url, { method: 'POST', headers: { diff --git a/src/libs/E2E/utils/NetworkInterceptor.ts b/src/libs/E2E/utils/NetworkInterceptor.ts index 511c8014f0cd..cf5348ce1dd0 100644 --- a/src/libs/E2E/utils/NetworkInterceptor.ts +++ b/src/libs/E2E/utils/NetworkInterceptor.ts @@ -155,6 +155,13 @@ export default function installNetworkInterceptor( const options = fetchArgsGetRequestInit(args); const headers = getFetchRequestHeadersAsObject(options); const url = fetchArgsGetUrl(args); + + // Don't process these specific API commands because running them over and over again in the tests hammers the server in a bad way. + if (url.includes('command=OptInToPushNotifications') || url.includes('command=OptOutOfPushNotifications')) { + console.debug('Skipping request to opt in or out of push notifications'); + return Promise.resolve(new Response()); + } + // Check if headers contain any of the ignored headers, or if react native metro server: if (IGNORE_REQUEST_HEADERS.some((header) => headers[header] != null) || url.includes('8081')) { return originalFetch(...args); From cf34d9e33fc40bf94a7f7952881a20e68c46f384 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hanno=20J=2E=20G=C3=B6decke?= Date: Fri, 6 Dec 2024 16:36:06 +0100 Subject: [PATCH 2/4] remove the commands part --- src/libs/E2E/utils/NetworkInterceptor.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/E2E/utils/NetworkInterceptor.ts b/src/libs/E2E/utils/NetworkInterceptor.ts index cf5348ce1dd0..0e453e250f77 100644 --- a/src/libs/E2E/utils/NetworkInterceptor.ts +++ b/src/libs/E2E/utils/NetworkInterceptor.ts @@ -157,7 +157,7 @@ export default function installNetworkInterceptor( const url = fetchArgsGetUrl(args); // Don't process these specific API commands because running them over and over again in the tests hammers the server in a bad way. - if (url.includes('command=OptInToPushNotifications') || url.includes('command=OptOutOfPushNotifications')) { + if (url.includes('OptInToPushNotifications') || url.includes('OptOutOfPushNotifications')) { console.debug('Skipping request to opt in or out of push notifications'); return Promise.resolve(new Response()); } From a97a7c174ec840133ed981a19bbed8702483a3e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hanno=20J=2E=20G=C3=B6decke?= Date: Fri, 6 Dec 2024 16:40:00 +0100 Subject: [PATCH 3/4] Update src/libs/E2E/utils/NetworkInterceptor.ts Co-authored-by: Tim Golen --- src/libs/E2E/utils/NetworkInterceptor.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/E2E/utils/NetworkInterceptor.ts b/src/libs/E2E/utils/NetworkInterceptor.ts index 0e453e250f77..8a29925e288e 100644 --- a/src/libs/E2E/utils/NetworkInterceptor.ts +++ b/src/libs/E2E/utils/NetworkInterceptor.ts @@ -156,7 +156,7 @@ export default function installNetworkInterceptor( const headers = getFetchRequestHeadersAsObject(options); const url = fetchArgsGetUrl(args); - // Don't process these specific API commands because running them over and over again in the tests hammers the server in a bad way. + // Don't process these specific API commands because running them over and over again in the tests increases the size of the notificationPreferences NVP on the server to an infinite size. This is due to the NVP storing this setting once for each user's device, and since the E2E tests use AWS device farm, the user ends up with thousands of different devices, unlike normal users that might only ever have about a dozen. We found the NVP was over 2.5mb in size and that slows down database replication. if (url.includes('OptInToPushNotifications') || url.includes('OptOutOfPushNotifications')) { console.debug('Skipping request to opt in or out of push notifications'); return Promise.resolve(new Response()); From a09de66a6137f27d83e3912d9715882067e93d7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hanno=20J=2E=20G=C3=B6decke?= Date: Fri, 6 Dec 2024 16:42:24 +0100 Subject: [PATCH 4/4] break lines --- src/libs/E2E/utils/NetworkInterceptor.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libs/E2E/utils/NetworkInterceptor.ts b/src/libs/E2E/utils/NetworkInterceptor.ts index 8a29925e288e..efa4c3c7e780 100644 --- a/src/libs/E2E/utils/NetworkInterceptor.ts +++ b/src/libs/E2E/utils/NetworkInterceptor.ts @@ -156,7 +156,9 @@ export default function installNetworkInterceptor( const headers = getFetchRequestHeadersAsObject(options); const url = fetchArgsGetUrl(args); - // Don't process these specific API commands because running them over and over again in the tests increases the size of the notificationPreferences NVP on the server to an infinite size. This is due to the NVP storing this setting once for each user's device, and since the E2E tests use AWS device farm, the user ends up with thousands of different devices, unlike normal users that might only ever have about a dozen. We found the NVP was over 2.5mb in size and that slows down database replication. + // Don't process these specific API commands because running them over and over again in the tests increases the size of the notificationPreferences NVP on the server to an infinite size. + // This is due to the NVP storing this setting once for each user's device, and since the E2E tests use AWS device farm, the user ends up with thousands of different devices, + // unlike normal users that might only ever have about a dozen. We found the NVP was over 2.5mb in size and that slows down database replication. if (url.includes('OptInToPushNotifications') || url.includes('OptOutOfPushNotifications')) { console.debug('Skipping request to opt in or out of push notifications'); return Promise.resolve(new Response());