Skip to content

Commit

Permalink
Skip calling specific APIs in the E2E tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hannojg committed Dec 6, 2024
1 parent 73942b5 commit 00d8bf0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 0 additions & 6 deletions src/libs/E2E/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@ const defaultRequestInit: RequestInit = {
};

const sendRequest = (url: string, data: Record<string, unknown>): Promise<Response> => {
// 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: {
Expand Down
7 changes: 7 additions & 0 deletions src/libs/E2E/utils/NetworkInterceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 00d8bf0

Please sign in to comment.