From 4ae6548a800ab497373290c56f11602f8d8f41b2 Mon Sep 17 00:00:00 2001 From: Tim Golen Date: Wed, 4 Dec 2024 14:22:22 -0700 Subject: [PATCH 1/3] Skip calling specific APIs in the E2E tests --- src/libs/E2E/client.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/libs/E2E/client.ts b/src/libs/E2E/client.ts index 7a0259de7eef..b7a27dff14b2 100644 --- a/src/libs/E2E/client.ts +++ b/src/libs/E2E/client.ts @@ -23,8 +23,13 @@ const defaultRequestInit: RequestInit = { headers: defaultHeaders, }; -const sendRequest = (url: string, data: Record): Promise => - fetch(url, { +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.indexOf('command=OptInToPushNotifications') > -1 || url.indexOf('command=OptOutOfPushNotifications') > -1) { + return Promise.resolve(new Response()); + } + + return fetch(url, { method: 'POST', headers: { // eslint-disable-next-line @typescript-eslint/naming-convention @@ -46,6 +51,7 @@ const sendRequest = (url: string, data: Record): Promise Date: Wed, 4 Dec 2024 14:27:06 -0700 Subject: [PATCH 2/3] Use includes --- src/libs/E2E/client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/E2E/client.ts b/src/libs/E2E/client.ts index b7a27dff14b2..97fa898828f8 100644 --- a/src/libs/E2E/client.ts +++ b/src/libs/E2E/client.ts @@ -25,7 +25,7 @@ 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.indexOf('command=OptInToPushNotifications') > -1 || url.indexOf('command=OptOutOfPushNotifications') > -1) { + if (url.includes('command=OptInToPushNotifications') || url.includes('command=OptOutOfPushNotifications')) { return Promise.resolve(new Response()); } From 95e7de945629a24ed9795756a7dfffe6b368f6ed Mon Sep 17 00:00:00 2001 From: Tim Golen Date: Wed, 4 Dec 2024 16:20:38 -0700 Subject: [PATCH 3/3] Add a log for when those APIs are skipped --- src/libs/E2E/client.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/E2E/client.ts b/src/libs/E2E/client.ts index 97fa898828f8..3088f280038c 100644 --- a/src/libs/E2E/client.ts +++ b/src/libs/E2E/client.ts @@ -26,6 +26,7 @@ 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()); }