diff --git a/src/libs/E2E/client.ts b/src/libs/E2E/client.ts index f76bdf2ed9a5..4c0e572cc9b2 100644 --- a/src/libs/E2E/client.ts +++ b/src/libs/E2E/client.ts @@ -1,23 +1,6 @@ import Config from '../../../tests/e2e/config'; import Routes from '../../../tests/e2e/server/routes'; -import type {NetworkCacheMap, TestConfig} from './types'; - -type TestResult = { - /** Name of the test */ - name: string; - - /** The branch where test were running */ - branch?: string; - - /** Duration in milliseconds */ - duration?: number; - - /** Optional, if set indicates that the test run failed and has no valid results. */ - error?: string; - - /** Render count */ - renderCount?: number; -}; +import type {NetworkCacheMap, TestConfig, TestResult} from './types'; type NativeCommandPayload = { text: string; diff --git a/src/libs/E2E/types.ts b/src/libs/E2E/types.ts index cb5bae9ee4b3..3c4d4680c77e 100644 --- a/src/libs/E2E/types.ts +++ b/src/libs/E2E/types.ts @@ -24,10 +24,19 @@ type TestConfig = { }; type TestResult = { + /** Name of the test */ name: string; + + /** The branch where test were running */ branch?: string; + + /** Duration in milliseconds */ duration?: number; + + /** Optional, if set indicates that the test run failed and has no valid results. */ error?: string; + + /** Render count */ renderCount?: number; }; diff --git a/tests/e2e/config.dev.ts b/tests/e2e/config.dev.ts index a930c2e21f06..cdd7bce756c8 100644 --- a/tests/e2e/config.dev.ts +++ b/tests/e2e/config.dev.ts @@ -1,8 +1,8 @@ +import type {Config} from './config.local'; + const packageName = 'com.expensify.chat.dev'; const appPath = './android/app/build/outputs/apk/development/debug/app-development-debug.apk'; -type Config = Record; - const config: Config = { MAIN_APP_PACKAGE: packageName, DELTA_APP_PACKAGE: packageName, diff --git a/tests/e2e/config.local.ts b/tests/e2e/config.local.ts index 40f7afde3985..8e90da9d3423 100644 --- a/tests/e2e/config.local.ts +++ b/tests/e2e/config.local.ts @@ -10,3 +10,4 @@ const config: Config = { }; export default config; +export type {Config}; diff --git a/tests/e2e/testRunner.ts b/tests/e2e/testRunner.ts index d82dc9263f7c..5d81dceee531 100644 --- a/tests/e2e/testRunner.ts +++ b/tests/e2e/testRunner.ts @@ -85,24 +85,24 @@ const runTests = async (): Promise => { const server = createServerInstance(); await server.start(); + type Result = Record; // Create a dict in which we will store the run durations for all tests - const results: Record> = {}; + const results: Record = {}; // Collect results while tests are being executed - // server.addTestResultListener((testResult) => { server.addTestResultListener((testResult) => { if (testResult?.error != null) { throw new Error(`Test '${testResult.name}' failed with error: ${testResult.error}`); } - let result: number | undefined = 0; + let result = 0; - if (testResult?.duration) { + if (testResult?.duration !== undefined) { if (testResult.duration < 0) { return; } result = testResult.duration; } - if (testResult?.renderCount) { + if (testResult?.renderCount !== undefined) { result = testResult.renderCount; } diff --git a/tests/ui/UnreadIndicatorsTest.tsx b/tests/ui/UnreadIndicatorsTest.tsx index 9394db8a021c..9a84ba31410a 100644 --- a/tests/ui/UnreadIndicatorsTest.tsx +++ b/tests/ui/UnreadIndicatorsTest.tsx @@ -7,6 +7,7 @@ import React from 'react'; import {AppState, DeviceEventEmitter, Linking} from 'react-native'; import type {OnyxEntry} from 'react-native-onyx'; import Onyx from 'react-native-onyx'; +import type Animated from 'react-native-reanimated'; import * as CollectionUtils from '@libs/CollectionUtils'; import DateUtils from '@libs/DateUtils'; import * as Localize from '@libs/Localize'; @@ -44,9 +45,8 @@ jest.mock('react-native/Libraries/LogBox/LogBox', () => ({ }, })); -// eslint-disable-next-line @typescript-eslint/no-unsafe-return jest.mock('react-native-reanimated', () => ({ - ...jest.requireActual('react-native-reanimated/mock'), + ...jest.requireActual('react-native-reanimated/mock'), createAnimatedPropAdapter: jest.fn, useReducedMotion: jest.fn, })); @@ -54,7 +54,7 @@ jest.mock('react-native-reanimated', () => ({ /** * We need to keep track of the transitionEnd callback so we can trigger it in our tests */ -let transitionEndCB: () => void | undefined; +let transitionEndCB: () => void; type ListenerMock = { triggerTransitionEnd: () => void; @@ -119,7 +119,8 @@ beforeAll(() => { // fetch() never gets called so it does not need mocking) or we might have fetch throw an error to test error handling // behavior. But here we just want to treat all API requests as a generic "success" and in the cases where we need to // simulate data arriving we will just set it into Onyx directly with Onyx.merge() or Onyx.set() etc. - global.fetch = TestHelper.getGlobalFetchMock() as typeof global.fetch; + // @ts-expect-error -- TODO: Remove this once TestHelper (https://github.com/Expensify/App/issues/25318) is migrated + global.fetch = TestHelper.getGlobalFetchMock(); Linking.setInitialURL('https://new.expensify.com/'); appSetup(); @@ -315,7 +316,7 @@ describe('Unread Indicators', () => { const newMessageLineIndicatorHintText = Localize.translateLocal('accessibilityHints.newMessageLineIndicator'); const unreadIndicator = screen.queryAllByLabelText(newMessageLineIndicatorHintText); expect(unreadIndicator).toHaveLength(1); - const reportActionID = unreadIndicator?.[0]?.props?.['data-action-id']; + const reportActionID = unreadIndicator[0]?.props?.['data-action-id']; expect(reportActionID).toBe('4'); // Scroll up and verify that the "New messages" badge appears scrollUpToRevealNewMessagesBadge(); @@ -457,10 +458,10 @@ describe('Unread Indicators', () => { const hintText = Localize.translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNameTexts = screen.queryAllByLabelText(hintText); expect(displayNameTexts).toHaveLength(2); - expect(displayNameTexts?.[0]?.props?.style?.fontWeight).toBe(undefined); - expect(displayNameTexts?.[0]?.props?.children?.[0]).toBe('C User'); - expect(displayNameTexts?.[1]?.props?.style?.fontWeight).toBe(FontUtils.fontWeight.bold); - expect(displayNameTexts?.[1]?.props?.children?.[0]).toBe('B User'); + expect(displayNameTexts[0]?.props?.style?.fontWeight).toBe(undefined); + expect(displayNameTexts[0]?.props?.children?.[0]).toBe('C User'); + expect(displayNameTexts[1]?.props?.style?.fontWeight).toBe(FontUtils.fontWeight.bold); + expect(displayNameTexts[1]?.props?.children?.[0]).toBe('B User'); })); xit('Manually marking a chat message as unread shows the new line indicator and updates the LHN', () => @@ -478,7 +479,7 @@ describe('Unread Indicators', () => { const newMessageLineIndicatorHintText = Localize.translateLocal('accessibilityHints.newMessageLineIndicator'); const unreadIndicator = screen.queryAllByLabelText(newMessageLineIndicatorHintText); expect(unreadIndicator).toHaveLength(1); - const reportActionID = unreadIndicator?.[0]?.props?.['data-action-id']; + const reportActionID = unreadIndicator[0]?.props?.['data-action-id']; expect(reportActionID).toBe('3'); // Scroll up and verify the new messages badge appears scrollUpToRevealNewMessagesBadge(); @@ -491,8 +492,8 @@ describe('Unread Indicators', () => { const hintText = Localize.translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNameTexts = screen.queryAllByLabelText(hintText); expect(displayNameTexts).toHaveLength(1); - expect(displayNameTexts?.[0]?.props?.style?.fontWeight).toBe(FontUtils.fontWeight.bold); - expect(displayNameTexts?.[0]?.props?.children?.[0]).toBe('B User'); + expect(displayNameTexts[0]?.props?.style?.fontWeight).toBe(FontUtils.fontWeight.bold); + expect(displayNameTexts[0]?.props?.children?.[0]).toBe('B User'); // Navigate to the report again and back to the sidebar return navigateToSidebarOption(0); @@ -503,8 +504,8 @@ describe('Unread Indicators', () => { const hintText = Localize.translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNameTexts = screen.queryAllByLabelText(hintText); expect(displayNameTexts).toHaveLength(1); - expect(displayNameTexts?.[0]?.props?.style?.fontWeight).toBe(undefined); - expect(displayNameTexts?.[0]?.props?.children?.[0]).toBe('B User'); + expect(displayNameTexts[0]?.props?.style?.fontWeight).toBe(undefined); + expect(displayNameTexts[0]?.props?.children?.[0]).toBe('B User'); // Navigate to the report again and verify the new line indicator is missing return navigateToSidebarOption(0); @@ -586,7 +587,6 @@ describe('Unread Indicators', () => { })); it('Displays the correct chat message preview in the LHN when a comment is added then deleted', () => { - // let reportActions: Record; let reportActions: OnyxEntry; let lastReportAction: ReportAction | undefined; Onyx.connect({