From f985b2406af66b5d51d92690fc3063de0a30f0e7 Mon Sep 17 00:00:00 2001 From: kirillzyusko Date: Wed, 5 Jun 2024 10:38:14 +0200 Subject: [PATCH] chore: changes after review --- src/libs/E2E/client.ts | 3 ++- src/libs/E2E/tests/appStartTimeTest.e2e.ts | 2 -- src/libs/E2E/tests/chatOpeningTest.e2e.ts | 11 ++++------- src/libs/E2E/tests/linkingTest.e2e.ts | 2 -- src/libs/E2E/tests/openChatFinderPageTest.e2e.ts | 11 ++++------- src/libs/E2E/tests/reportTypingTest.e2e.ts | 5 +---- 6 files changed, 11 insertions(+), 23 deletions(-) diff --git a/src/libs/E2E/client.ts b/src/libs/E2E/client.ts index 5aa999267ead..7a0259de7eef 100644 --- a/src/libs/E2E/client.ts +++ b/src/libs/E2E/client.ts @@ -1,6 +1,7 @@ import Config from '../../../tests/e2e/config'; import Routes from '../../../tests/e2e/server/routes'; import type {NetworkCacheMap, TestConfig, TestResult} from './types'; +import {waitForActiveRequestsToBeEmpty} from './utils/NetworkInterceptor'; type NativeCommandPayload = { text: string; @@ -57,7 +58,7 @@ const submitTestResults = (testResult: TestResult): Promise => { }); }; -const submitTestDone = () => fetch(`${SERVER_ADDRESS}${Routes.testDone}`, defaultRequestInit); +const submitTestDone = () => waitForActiveRequestsToBeEmpty().then(() => fetch(`${SERVER_ADDRESS}${Routes.testDone}`, defaultRequestInit)); let currentActiveTestConfig: TestConfig | null = null; diff --git a/src/libs/E2E/tests/appStartTimeTest.e2e.ts b/src/libs/E2E/tests/appStartTimeTest.e2e.ts index 456c62b24ac9..321fc3773d51 100644 --- a/src/libs/E2E/tests/appStartTimeTest.e2e.ts +++ b/src/libs/E2E/tests/appStartTimeTest.e2e.ts @@ -3,7 +3,6 @@ import type {PerformanceEntry} from 'react-native-performance'; import E2ELogin from '@libs/E2E/actions/e2eLogin'; import waitForAppLoaded from '@libs/E2E/actions/waitForAppLoaded'; import E2EClient from '@libs/E2E/client'; -import {waitForActiveRequestsToBeEmpty} from '@libs/E2E/utils/NetworkInterceptor'; import Performance from '@libs/Performance'; const test = () => { @@ -31,7 +30,6 @@ const test = () => { }), ), ) - .then(waitForActiveRequestsToBeEmpty) .then(() => { console.debug('[E2E] Done, exiting…'); E2EClient.submitTestDone(); diff --git a/src/libs/E2E/tests/chatOpeningTest.e2e.ts b/src/libs/E2E/tests/chatOpeningTest.e2e.ts index c8887cab535d..8e43c4ece564 100644 --- a/src/libs/E2E/tests/chatOpeningTest.e2e.ts +++ b/src/libs/E2E/tests/chatOpeningTest.e2e.ts @@ -5,7 +5,6 @@ import waitForAppLoaded from '@libs/E2E/actions/waitForAppLoaded'; import E2EClient from '@libs/E2E/client'; import getConfigValueOrThrow from '@libs/E2E/utils/getConfigValueOrThrow'; import getPromiseWithResolve from '@libs/E2E/utils/getPromiseWithResolve'; -import {waitForActiveRequestsToBeEmpty} from '@libs/E2E/utils/NetworkInterceptor'; import Navigation from '@libs/Navigation/Navigation'; import Performance from '@libs/Performance'; import CONST from '@src/CONST'; @@ -30,13 +29,11 @@ const test = (config: NativeConfig) => { const [renderChatPromise, renderChatResolve] = getPromiseWithResolve(); const [chatTTIPromise, chatTTIResolve] = getPromiseWithResolve(); - Promise.all([renderChatPromise, chatTTIPromise]) - .then(waitForActiveRequestsToBeEmpty) - .then(() => { - console.debug(`[E2E] Submitting!`); + Promise.all([renderChatPromise, chatTTIPromise]).then(() => { + console.debug(`[E2E] Submitting!`); - E2EClient.submitTestDone(); - }); + E2EClient.submitTestDone(); + }); Performance.subscribeToMeasurements((entry) => { if (entry.name === CONST.TIMING.SIDEBAR_LOADED) { diff --git a/src/libs/E2E/tests/linkingTest.e2e.ts b/src/libs/E2E/tests/linkingTest.e2e.ts index 8a1980a8b28a..c48ffb5a8057 100644 --- a/src/libs/E2E/tests/linkingTest.e2e.ts +++ b/src/libs/E2E/tests/linkingTest.e2e.ts @@ -6,7 +6,6 @@ import E2ELogin from '@libs/E2E/actions/e2eLogin'; import waitForAppLoaded from '@libs/E2E/actions/waitForAppLoaded'; import E2EClient from '@libs/E2E/client'; import getConfigValueOrThrow from '@libs/E2E/utils/getConfigValueOrThrow'; -import {waitForActiveRequestsToBeEmpty} from '@libs/E2E/utils/NetworkInterceptor'; import Navigation from '@libs/Navigation/Navigation'; import Performance from '@libs/Performance'; import CONST from '@src/CONST'; @@ -52,7 +51,6 @@ const test = (config: NativeConfig) => { name: 'Comment linking', duration: entry.duration, }) - .then(waitForActiveRequestsToBeEmpty) .then(() => { console.debug('[E2E] Test completed successfully, exiting…'); E2EClient.submitTestDone(); diff --git a/src/libs/E2E/tests/openChatFinderPageTest.e2e.ts b/src/libs/E2E/tests/openChatFinderPageTest.e2e.ts index 1837d31f7110..4ac7995b914f 100644 --- a/src/libs/E2E/tests/openChatFinderPageTest.e2e.ts +++ b/src/libs/E2E/tests/openChatFinderPageTest.e2e.ts @@ -3,7 +3,6 @@ import E2ELogin from '@libs/E2E/actions/e2eLogin'; import waitForAppLoaded from '@libs/E2E/actions/waitForAppLoaded'; import E2EClient from '@libs/E2E/client'; import getPromiseWithResolve from '@libs/E2E/utils/getPromiseWithResolve'; -import {waitForActiveRequestsToBeEmpty} from '@libs/E2E/utils/NetworkInterceptor'; import Navigation from '@libs/Navigation/Navigation'; import Performance from '@libs/Performance'; import CONST from '@src/CONST'; @@ -26,13 +25,11 @@ const test = () => { const [openSearchPagePromise, openSearchPageResolve] = getPromiseWithResolve(); const [loadSearchOptionsPromise, loadSearchOptionsResolve] = getPromiseWithResolve(); - Promise.all([openSearchPagePromise, loadSearchOptionsPromise]) - .then(waitForActiveRequestsToBeEmpty) - .then(() => { - console.debug(`[E2E] Submitting!`); + Promise.all([openSearchPagePromise, loadSearchOptionsPromise]).then(() => { + console.debug(`[E2E] Submitting!`); - E2EClient.submitTestDone(); - }); + E2EClient.submitTestDone(); + }); Performance.subscribeToMeasurements((entry) => { if (entry.name === CONST.TIMING.SIDEBAR_LOADED) { diff --git a/src/libs/E2E/tests/reportTypingTest.e2e.ts b/src/libs/E2E/tests/reportTypingTest.e2e.ts index fec5daa246fe..817bda941611 100644 --- a/src/libs/E2E/tests/reportTypingTest.e2e.ts +++ b/src/libs/E2E/tests/reportTypingTest.e2e.ts @@ -5,7 +5,6 @@ import waitForAppLoaded from '@libs/E2E/actions/waitForAppLoaded'; import waitForKeyboard from '@libs/E2E/actions/waitForKeyboard'; import E2EClient from '@libs/E2E/client'; import getConfigValueOrThrow from '@libs/E2E/utils/getConfigValueOrThrow'; -import {waitForActiveRequestsToBeEmpty} from '@libs/E2E/utils/NetworkInterceptor'; import Navigation from '@libs/Navigation/Navigation'; import Performance from '@libs/Performance'; import {getRerenderCount, resetRerenderCount} from '@pages/home/report/ReportActionCompose/ComposerWithSuggestions/index.e2e'; @@ -55,9 +54,7 @@ const test = (config: NativeConfig) => { branch: Config.E2E_BRANCH, name: 'Composer typing rerender count', renderCount: rerenderCount, - }) - .then(waitForActiveRequestsToBeEmpty) - .then(E2EClient.submitTestDone); + }).then(E2EClient.submitTestDone); }, 3000); }) .catch((error) => {