From a53dd3a8947ec31c9d01be91fcfee349f23b8c38 Mon Sep 17 00:00:00 2001 From: pauliusguzas Date: Mon, 8 Jul 2024 11:24:36 +0300 Subject: [PATCH 1/8] chore: add harness e2e coverage of test cases for ios, android, web --- packages/app-harness/src/app/index.tsx | 28 ++++-- .../CastButton/index.android.mobile.tsx | 8 +- .../src/components/CastButton/index.tsx | 7 +- .../NewModuleButton/index.native.tsx | 7 +- .../src/components/NewModuleButton/index.tsx | 7 +- .../PhotoEditor/index.mobile.native.tsx | 8 +- .../src/components/PhotoEditor/index.tsx | 7 +- packages/app-harness/test/specs/e2e.cjs | 99 ++++++++++++++++++- 8 files changed, 152 insertions(+), 19 deletions(-) diff --git a/packages/app-harness/src/app/index.tsx b/packages/app-harness/src/app/index.tsx index 3d846517b..405c9fbe9 100644 --- a/packages/app-harness/src/app/index.tsx +++ b/packages/app-harness/src/app/index.tsx @@ -148,7 +148,7 @@ const AppContent = () => { }} > - {`hermes: ${ + {`hermes: ${ typeof HermesInternal === 'object' && HermesInternal !== null ? 'yes' : 'no' }`} @@ -182,13 +182,17 @@ const AppContent = () => { onFocus={() => setFocusedIndex(1)} onBlur={() => setFocusedIndex(null)} > - Toggle Video + + Toggle Video + {showVideo && ( - Landscape video goes here + + Landscape video goes here + )} @@ -205,11 +209,20 @@ const AppContent = () => { onFocus={() => setFocusedIndex(2)} onBlur={() => setFocusedIndex(null)} > - Request permissions + + Request permissions + - + @@ -235,7 +248,9 @@ const AppContent = () => { onFocus={() => setFocusedIndex(3)} onBlur={() => setFocusedIndex(null)} > - Show SplashScreen + + Show SplashScreen + @@ -278,6 +293,7 @@ const AppContent = () => { { paddingHorizontal: 25 }, idx === logs.length - 1 && { paddingBottom: 80 }, ]} + {...testProps(`app-harness-home-screen-logs-text-${idx}`)} > {it} diff --git a/packages/app-harness/src/components/CastButton/index.android.mobile.tsx b/packages/app-harness/src/components/CastButton/index.android.mobile.tsx index 9f8dd5342..75d35849e 100644 --- a/packages/app-harness/src/components/CastButton/index.android.mobile.tsx +++ b/packages/app-harness/src/components/CastButton/index.android.mobile.tsx @@ -1,5 +1,6 @@ import React, { useEffect } from 'react'; import { CastButton, useRemoteMediaClient } from 'react-native-google-cast'; +import { testProps } from '../../config'; export function CastComponent() { const client = useRemoteMediaClient(); @@ -15,5 +16,10 @@ export function CastComponent() { } }, [client]); - return ; + return ( + + ); } diff --git a/packages/app-harness/src/components/CastButton/index.tsx b/packages/app-harness/src/components/CastButton/index.tsx index 6643211d7..ca210de5b 100644 --- a/packages/app-harness/src/components/CastButton/index.tsx +++ b/packages/app-harness/src/components/CastButton/index.tsx @@ -1,5 +1,10 @@ import { Text } from 'react-native'; +import { testProps } from '../../config'; export const CastComponent = () => { - return Not supported; + return ( + + Not supported + + ); }; diff --git a/packages/app-harness/src/components/NewModuleButton/index.native.tsx b/packages/app-harness/src/components/NewModuleButton/index.native.tsx index 9840b9a6a..0972fdb83 100644 --- a/packages/app-harness/src/components/NewModuleButton/index.native.tsx +++ b/packages/app-harness/src/components/NewModuleButton/index.native.tsx @@ -2,8 +2,9 @@ import React, { forwardRef } from 'react'; import { NativeModules, TouchableOpacityProps, TouchableOpacity, Text } from 'react-native'; import { useLoggerContext } from '../../context'; import styles from '../../styles'; +import { testProps } from '../../config'; -interface ButtonProps extends TouchableOpacityProps {} +type ButtonProps = TouchableOpacityProps; export const NewModuleButton = forwardRef(({ onBlur, onFocus, style }, ref) => { const { TestNativeModule } = NativeModules; const { logDebug } = useLoggerContext(); @@ -23,7 +24,9 @@ export const NewModuleButton = forwardRef(({ onBl }; return ( - Click to invoke native module! + + Click to invoke native module! + ); }); diff --git a/packages/app-harness/src/components/NewModuleButton/index.tsx b/packages/app-harness/src/components/NewModuleButton/index.tsx index 6d24a9da1..bdd630159 100644 --- a/packages/app-harness/src/components/NewModuleButton/index.tsx +++ b/packages/app-harness/src/components/NewModuleButton/index.tsx @@ -2,8 +2,9 @@ import React, { forwardRef } from 'react'; import { TouchableOpacityProps, TouchableOpacity, Text } from 'react-native'; import { useLoggerContext } from '../../context'; import styles from '../../styles'; +import { testProps } from '../../config'; -interface ButtonProps extends TouchableOpacityProps {} +type ButtonProps = TouchableOpacityProps; export const NewModuleButton = forwardRef(({ onBlur, onFocus, style }, ref) => { const { logDebug } = useLoggerContext(); const onPress = () => { @@ -11,7 +12,9 @@ export const NewModuleButton = forwardRef(({ onBl }; return ( - Click to invoke native module! + + Click to invoke native module! + ); }); diff --git a/packages/app-harness/src/components/PhotoEditor/index.mobile.native.tsx b/packages/app-harness/src/components/PhotoEditor/index.mobile.native.tsx index 4176413bf..57488e5fa 100644 --- a/packages/app-harness/src/components/PhotoEditor/index.mobile.native.tsx +++ b/packages/app-harness/src/components/PhotoEditor/index.mobile.native.tsx @@ -4,10 +4,10 @@ import { RNPhotoEditor } from 'react-native-photo-editor'; import RNFS from 'react-native-fs'; import RNFetchBlob from 'rn-fetch-blob'; import { useLoggerContext } from '../../context'; -import { ICON_LOGO } from '../../config'; +import { ICON_LOGO, testProps } from '../../config'; import styles from '../../styles'; -interface ButtonProps extends TouchableOpacityProps {} +type ButtonProps = TouchableOpacityProps; export const PhotoEditorButton = forwardRef(({ onBlur, onFocus, style }, ref) => { const { logDebug } = useLoggerContext(); const photoPath = RNFS.DocumentDirectoryPath + ICON_LOGO; @@ -40,7 +40,9 @@ export const PhotoEditorButton = forwardRef(({ on }; return ( - Show PhotoEditor + + Show PhotoEditor + ); }); diff --git a/packages/app-harness/src/components/PhotoEditor/index.tsx b/packages/app-harness/src/components/PhotoEditor/index.tsx index ce5a1c877..5f91015df 100644 --- a/packages/app-harness/src/components/PhotoEditor/index.tsx +++ b/packages/app-harness/src/components/PhotoEditor/index.tsx @@ -2,8 +2,9 @@ import React, { forwardRef } from 'react'; import { useLoggerContext } from '../../context'; import { Text, TouchableOpacity, TouchableOpacityProps } from 'react-native'; import styles from '../../styles'; +import { testProps } from '../../config'; -interface ButtonProps extends TouchableOpacityProps {} +type ButtonProps = TouchableOpacityProps; export const PhotoEditorButton = forwardRef(({ onBlur, onFocus, style }, ref) => { const { logDebug } = useLoggerContext(); const handlePhotoEditor = () => { @@ -12,7 +13,9 @@ export const PhotoEditorButton = forwardRef(({ on return ( - Show PhotoEditor + + Show PhotoEditor + ); }); diff --git a/packages/app-harness/test/specs/e2e.cjs b/packages/app-harness/test/specs/e2e.cjs index 04d4e695a..3ba5351e9 100644 --- a/packages/app-harness/test/specs/e2e.cjs +++ b/packages/app-harness/test/specs/e2e.cjs @@ -5,7 +5,102 @@ describe('Test App Harness', () => { FlexnRunner.launchApp(); }); - it('--> check if ReNative logo is displayed in Home Page', async () => { - await FlexnRunner.expectToBeDisplayedById('app-harness-home-screen-renative-image'); + // done + it('--> Hermes support ', async () => { + await FlexnRunner.waitForDisplayedById('app-harness-home-screen-renative-image'); + if (process.env.PLATFORM === 'web') { + await FlexnRunner.expectToHaveTextById('app-harness-home-screen-harmes-text', 'hermes: no'); + } else { + await FlexnRunner.expectToHaveTextById('app-harness-home-screen-harmes-text', 'hermes: yes'); + } }); + + // done + it('--> Native call', async () => { + await FlexnRunner.clickById('app-harness-home-screen-native-call-button'); + if (process.env.PLATFORM === 'web') { + await FlexnRunner.expectToHaveTextById( + 'app-harness-home-screen-logs-text-2', + 'NativeModules not supported in web' + ); + } else if (process.env.PLATFORM === 'android') { + await FlexnRunner.expectToHaveTextById( + 'app-harness-home-screen-logs-text-3', + 'Event called with name: testName and location: testLocation' + ); + } else if (process.env.PLATFORM === 'ios') { + await FlexnRunner.expectToHaveTextById( + 'app-harness-home-screen-logs-text-3', + 'NativeModules not supported for this platform' + ); + } + }); + + // done + it('--> Request permissions', async () => { + await FlexnRunner.clickById('app-harness-home-request-permissions-button'); + if (process.env.PLATFORM === 'web') { + await FlexnRunner.expectToHaveTextById( + 'app-harness-home-screen-logs-text-3', + 'Permissions: requestPermissions not supported on this platform' + ); + } else if (process.env.PLATFORM === 'ios') { + await FlexnRunner.clickByText('Allow'); + await FlexnRunner.expectToHaveTextById('app-harness-home-screen-logs-text-4', 'Permissions: granted'); + } else if (process.env.PLATFORM === 'android') { + await FlexnRunner.clickByText('ALLOW'); + await FlexnRunner.expectToHaveTextById('app-harness-home-screen-logs-text-4', 'Permissions: granted'); + } + }); + + // done + it('--> Orientation support ', async () => { + await FlexnRunner.clickById('app-harness-home-toggle-video-button'); + if (process.env.PLATFORM !== 'web') { + await FlexnRunner.scrollById( + 'app-harness-home-landscape-video', + 'down', + 'app-harness-home-screen-harmes-text' + ); + } + await FlexnRunner.expectToBeDisplayedById('app-harness-home-landscape-video'); + await FlexnRunner.clickById('app-harness-home-toggle-video-button'); + }); + + // done + it('--> Image Support ', async () => { + await FlexnRunner.expectToBeDisplayedById('app-harness-home-image-support'); + }); + + // done + it('--> Cast support ', async () => { + if (process.env.PLATFORM === 'web' || process.env.PLATFORM === 'ios') { + await FlexnRunner.expectToHaveTextById('app-harness-home-cast-support', 'Not supported'); + } else if (process.env.PLATFORM === 'android') { + await FlexnRunner.clickById('app-harness-home-cast-button'); + await FlexnRunner.expectToBeDisplayedByText('Cast to'); + await FlexnRunner.waitForDisplayedByText('OK'); + await FlexnRunner.expectToBeDisplayedByText('OK'); + } + }); + + if (process.env.PLATFORM === 'web') { + it('--> Splash Screen', async () => { + await FlexnRunner.clickById('app-harness-home-splash-screen-button'); + await FlexnRunner.expectToHaveTextById( + 'app-harness-home-screen-logs-text-4', + 'SplashScreen.show not supported on this platform' + ); + }); + } + + if (process.env.PLATFORM === 'web') { + it('--> PhotoEditor', async () => { + await FlexnRunner.clickById('app-harness-home-request-photo-editor-button'); + await FlexnRunner.expectToHaveTextById( + 'app-harness-home-screen-logs-text-5', + 'PhotoEditor not supported on this platform' + ); + }); + } }); From 59d69497387c969830193fb735652a912400a9d8 Mon Sep 17 00:00:00 2001 From: pauliusguzas Date: Mon, 8 Jul 2024 11:39:11 +0300 Subject: [PATCH 2/8] chore: remove unused test id --- packages/app-harness/src/app/index.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/app-harness/src/app/index.tsx b/packages/app-harness/src/app/index.tsx index 405c9fbe9..980f4b949 100644 --- a/packages/app-harness/src/app/index.tsx +++ b/packages/app-harness/src/app/index.tsx @@ -126,9 +126,7 @@ const AppContent = () => { source={ICON_LOGO} {...testProps('app-harness-home-screen-renative-image')} /> - - ReNative Harness - + ReNative Harness {`v${config.version}, platform: ${Api.platform}, factor: ${Api.formFactor}, engine: ${Api.engine}`} From a5c13a862bb48b38a81465d2bbec6566ecbf8c81 Mon Sep 17 00:00:00 2001 From: RicardasN Date: Mon, 8 Jul 2024 14:40:32 +0300 Subject: [PATCH 3/8] fix(Android:SplashScreen): Hide splash screen after 3 seconds of showing it --- packages/app-harness/src/app/index.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/app-harness/src/app/index.tsx b/packages/app-harness/src/app/index.tsx index 980f4b949..46589764f 100644 --- a/packages/app-harness/src/app/index.tsx +++ b/packages/app-harness/src/app/index.tsx @@ -237,7 +237,10 @@ const AppContent = () => { )} SplashScreen.show()} + onPress={() => { + SplashScreen.show(); + setTimeout(() => SplashScreen.hide(), 3000); + }} style={[ styles.button, focusedIndex === 3 && styles.buttonFocused, From 4dc67aefaf402c733df858c535e9608d370a819d Mon Sep 17 00:00:00 2001 From: pauliusguzas Date: Mon, 8 Jul 2024 15:05:27 +0300 Subject: [PATCH 4/8] test --- packages/app-harness/test/specs/e2e.cjs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/app-harness/test/specs/e2e.cjs b/packages/app-harness/test/specs/e2e.cjs index 3ba5351e9..ce82b3596 100644 --- a/packages/app-harness/test/specs/e2e.cjs +++ b/packages/app-harness/test/specs/e2e.cjs @@ -5,6 +5,11 @@ describe('Test App Harness', () => { FlexnRunner.launchApp(); }); + // done + it('--> Hfffermes support ', async () => { + await FlexnRunner.pause(10000); + }); + // done it('--> Hermes support ', async () => { await FlexnRunner.waitForDisplayedById('app-harness-home-screen-renative-image'); @@ -48,7 +53,7 @@ describe('Test App Harness', () => { await FlexnRunner.clickByText('Allow'); await FlexnRunner.expectToHaveTextById('app-harness-home-screen-logs-text-4', 'Permissions: granted'); } else if (process.env.PLATFORM === 'android') { - await FlexnRunner.clickByText('ALLOW'); + await FlexnRunner.clickByText('Allow'); await FlexnRunner.expectToHaveTextById('app-harness-home-screen-logs-text-4', 'Permissions: granted'); } }); From bd86da49ed02b30f94fa8560e94cb0cd6beed333 Mon Sep 17 00:00:00 2001 From: pauliusguzas Date: Thu, 26 Sep 2024 17:39:37 +0300 Subject: [PATCH 5/8] chore: clean up --- packages/app-harness/next-env.d.ts | 2 +- packages/app-harness/src/app/index.tsx | 16 +-- .../CastButton/index.android.mobile.tsx | 2 +- .../src/components/CastButton/index.tsx | 2 +- .../NewModuleButton/index.native.tsx | 2 +- .../src/components/NewModuleButton/index.tsx | 2 +- .../PhotoEditor/index.mobile.native.tsx | 2 +- .../src/components/PhotoEditor/index.tsx | 2 +- packages/app-harness/test/specs/e2e.cjs | 108 +++++++++--------- 9 files changed, 64 insertions(+), 74 deletions(-) diff --git a/packages/app-harness/next-env.d.ts b/packages/app-harness/next-env.d.ts index 53e1f3374..a8465e5a5 100644 --- a/packages/app-harness/next-env.d.ts +++ b/packages/app-harness/next-env.d.ts @@ -2,4 +2,4 @@ /// // NOTE: This file should not be edited -// see https://nextjs.org/docs/basic-features/typescript for more information. +// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information. diff --git a/packages/app-harness/src/app/index.tsx b/packages/app-harness/src/app/index.tsx index ea3c24150..537692b5e 100644 --- a/packages/app-harness/src/app/index.tsx +++ b/packages/app-harness/src/app/index.tsx @@ -122,11 +122,7 @@ const AppContent = () => { return ( - + ReNative Harness @@ -147,7 +143,7 @@ const AppContent = () => { }} > - {`hermes: ${ + {`hermes: ${ typeof HermesInternal === 'object' && HermesInternal !== null ? 'yes' : 'no' }`} @@ -191,7 +187,7 @@ const AppContent = () => { - + Landscape video goes here @@ -222,7 +218,7 @@ const AppContent = () => { @@ -242,7 +238,7 @@ const AppContent = () => { ref={splashBtnRef} onPress={() => { SplashScreen.show(); - setTimeout(() => SplashScreen.hide(), 3000); + setTimeout(() => SplashScreen.hide(), 60000); }} style={[ styles.button, @@ -300,7 +296,7 @@ const AppContent = () => { { paddingHorizontal: 25 }, idx === logs.length - 1 && { paddingBottom: 80 }, ]} - {...testProps(`app-harness-home-screen-logs-text-${idx}`)} + {...testProps(`app-harness-home-logs-text-${idx}`)} > {it} diff --git a/packages/app-harness/src/components/CastButton/index.android.mobile.tsx b/packages/app-harness/src/components/CastButton/index.android.mobile.tsx index 75d35849e..f2632e181 100644 --- a/packages/app-harness/src/components/CastButton/index.android.mobile.tsx +++ b/packages/app-harness/src/components/CastButton/index.android.mobile.tsx @@ -18,7 +18,7 @@ export function CastComponent() { return ( ); diff --git a/packages/app-harness/src/components/CastButton/index.tsx b/packages/app-harness/src/components/CastButton/index.tsx index ca210de5b..6e9632601 100644 --- a/packages/app-harness/src/components/CastButton/index.tsx +++ b/packages/app-harness/src/components/CastButton/index.tsx @@ -3,7 +3,7 @@ import { testProps } from '../../config'; export const CastComponent = () => { return ( - + Not supported ); diff --git a/packages/app-harness/src/components/NewModuleButton/index.native.tsx b/packages/app-harness/src/components/NewModuleButton/index.native.tsx index 0972fdb83..f87c971aa 100644 --- a/packages/app-harness/src/components/NewModuleButton/index.native.tsx +++ b/packages/app-harness/src/components/NewModuleButton/index.native.tsx @@ -24,7 +24,7 @@ export const NewModuleButton = forwardRef(({ onBl }; return ( - + Click to invoke native module! diff --git a/packages/app-harness/src/components/NewModuleButton/index.tsx b/packages/app-harness/src/components/NewModuleButton/index.tsx index bdd630159..2b6ca85bf 100644 --- a/packages/app-harness/src/components/NewModuleButton/index.tsx +++ b/packages/app-harness/src/components/NewModuleButton/index.tsx @@ -12,7 +12,7 @@ export const NewModuleButton = forwardRef(({ onBl }; return ( - + Click to invoke native module! diff --git a/packages/app-harness/src/components/PhotoEditor/index.mobile.native.tsx b/packages/app-harness/src/components/PhotoEditor/index.mobile.native.tsx index 57488e5fa..02898765a 100644 --- a/packages/app-harness/src/components/PhotoEditor/index.mobile.native.tsx +++ b/packages/app-harness/src/components/PhotoEditor/index.mobile.native.tsx @@ -40,7 +40,7 @@ export const PhotoEditorButton = forwardRef(({ on }; return ( - + Show PhotoEditor diff --git a/packages/app-harness/src/components/PhotoEditor/index.tsx b/packages/app-harness/src/components/PhotoEditor/index.tsx index 5f91015df..4ac953a53 100644 --- a/packages/app-harness/src/components/PhotoEditor/index.tsx +++ b/packages/app-harness/src/components/PhotoEditor/index.tsx @@ -13,7 +13,7 @@ export const PhotoEditorButton = forwardRef(({ on return ( - + Show PhotoEditor diff --git a/packages/app-harness/test/specs/e2e.cjs b/packages/app-harness/test/specs/e2e.cjs index ce82b3596..d97c99601 100644 --- a/packages/app-harness/test/specs/e2e.cjs +++ b/packages/app-harness/test/specs/e2e.cjs @@ -5,107 +5,101 @@ describe('Test App Harness', () => { FlexnRunner.launchApp(); }); - // done - it('--> Hfffermes support ', async () => { - await FlexnRunner.pause(10000); - }); - - // done - it('--> Hermes support ', async () => { - await FlexnRunner.waitForDisplayedById('app-harness-home-screen-renative-image'); + it('--> Hermes Support ', async () => { + await FlexnRunner.waitForDisplayedById('app-harness-home-renative-image'); if (process.env.PLATFORM === 'web') { - await FlexnRunner.expectToHaveTextById('app-harness-home-screen-harmes-text', 'hermes: no'); + await FlexnRunner.expectToHaveTextById('app-harness-home-hermes-support-text', 'hermes: no'); } else { - await FlexnRunner.expectToHaveTextById('app-harness-home-screen-harmes-text', 'hermes: yes'); + await FlexnRunner.expectToHaveTextById('app-harness-home-hermes-support-text', 'hermes: yes'); } }); - // done - it('--> Native call', async () => { - await FlexnRunner.clickById('app-harness-home-screen-native-call-button'); + it('--> Native Call', async () => { + await FlexnRunner.clickById('app-harness-home-native-call-button'); if (process.env.PLATFORM === 'web') { await FlexnRunner.expectToHaveTextById( - 'app-harness-home-screen-logs-text-2', + 'app-harness-home-logs-text-2', 'NativeModules not supported in web' ); } else if (process.env.PLATFORM === 'android') { await FlexnRunner.expectToHaveTextById( - 'app-harness-home-screen-logs-text-3', + 'app-harness-home-logs-text-3', 'Event called with name: testName and location: testLocation' ); } else if (process.env.PLATFORM === 'ios') { await FlexnRunner.expectToHaveTextById( - 'app-harness-home-screen-logs-text-3', + 'app-harness-home-logs-text-3', 'NativeModules not supported for this platform' ); } }); - // done - it('--> Request permissions', async () => { - await FlexnRunner.clickById('app-harness-home-request-permissions-button'); - if (process.env.PLATFORM === 'web') { - await FlexnRunner.expectToHaveTextById( - 'app-harness-home-screen-logs-text-3', - 'Permissions: requestPermissions not supported on this platform' - ); - } else if (process.env.PLATFORM === 'ios') { - await FlexnRunner.clickByText('Allow'); - await FlexnRunner.expectToHaveTextById('app-harness-home-screen-logs-text-4', 'Permissions: granted'); - } else if (process.env.PLATFORM === 'android') { - await FlexnRunner.clickByText('Allow'); - await FlexnRunner.expectToHaveTextById('app-harness-home-screen-logs-text-4', 'Permissions: granted'); - } - }); + // TODO + // it('--> Request permissions', async () => { + // await FlexnRunner.clickById('app-harness-home-request-permissions-button'); + // if (process.env.PLATFORM === 'web') { + // await FlexnRunner.expectToHaveTextById( + // 'app-harness-home-logs-text-3', + // 'Permissions: requestPermissions not supported on this platform' + // ); + // } else if (process.env.PLATFORM === 'ios') { + // await FlexnRunner.clickByText('Allow'); + // await FlexnRunner.expectToHaveTextById('app-harness-home-logs-text-4', 'Permissions: granted'); + // } else if (process.env.PLATFORM === 'android') { + // await FlexnRunner.clickByText('Allow'); + // await FlexnRunner.expectToHaveTextById('app-harness-home-logs-text-4', 'Permissions: granted'); + // } + // }); - // done it('--> Orientation support ', async () => { await FlexnRunner.clickById('app-harness-home-toggle-video-button'); if (process.env.PLATFORM !== 'web') { await FlexnRunner.scrollById( - 'app-harness-home-landscape-video', + 'app-harness-home-landscape-video-text', 'down', - 'app-harness-home-screen-harmes-text' + 'app-harness-home-hermes-support-text' ); } - await FlexnRunner.expectToBeDisplayedById('app-harness-home-landscape-video'); + await FlexnRunner.expectToBeDisplayedById('app-harness-home-landscape-video-text'); await FlexnRunner.clickById('app-harness-home-toggle-video-button'); }); - // done it('--> Image Support ', async () => { - await FlexnRunner.expectToBeDisplayedById('app-harness-home-image-support'); + await FlexnRunner.expectToBeDisplayedById('app-harness-home-image-support-image'); }); - // done - it('--> Cast support ', async () => { + it('--> Cast Support ', async () => { if (process.env.PLATFORM === 'web' || process.env.PLATFORM === 'ios') { - await FlexnRunner.expectToHaveTextById('app-harness-home-cast-support', 'Not supported'); + await FlexnRunner.expectToHaveTextById('app-harness-home-cast-support-text', 'Not supported'); } else if (process.env.PLATFORM === 'android') { - await FlexnRunner.clickById('app-harness-home-cast-button'); + await FlexnRunner.clickById('app-harness-home-cast-support-button'); await FlexnRunner.expectToBeDisplayedByText('Cast to'); await FlexnRunner.waitForDisplayedByText('OK'); await FlexnRunner.expectToBeDisplayedByText('OK'); } }); - if (process.env.PLATFORM === 'web') { - it('--> Splash Screen', async () => { - await FlexnRunner.clickById('app-harness-home-splash-screen-button'); + // IN PROGRESS + it('--> Splash Screen', async () => { + await FlexnRunner.clickById('app-harness-home-splash-screen-button'); + if (process.env.PLATFORM === 'web') { await FlexnRunner.expectToHaveTextById( - 'app-harness-home-screen-logs-text-4', + 'app-harness-home-logs-text-3', 'SplashScreen.show not supported on this platform' ); - }); - } + } else { + await FlexnRunner.expectToBeDisplayedById(''); + } + }); - if (process.env.PLATFORM === 'web') { - it('--> PhotoEditor', async () => { - await FlexnRunner.clickById('app-harness-home-request-photo-editor-button'); - await FlexnRunner.expectToHaveTextById( - 'app-harness-home-screen-logs-text-5', - 'PhotoEditor not supported on this platform' - ); - }); - } + // TODO + // if (process.env.PLATFORM === 'web') { + // it('--> PhotoEditor', async () => { + // await FlexnRunner.clickById('app-harness-home-photo-editor-button'); + // await FlexnRunner.expectToHaveTextById( + // 'app-harness-home-logs-text-5', + // 'PhotoEditor not supported on this platform' + // ); + // }); + // } }); From 7a2f8bd61211f2db8415f66806a9a114f8df55bc Mon Sep 17 00:00:00 2001 From: pauliusguzas Date: Thu, 26 Sep 2024 19:04:40 +0300 Subject: [PATCH 6/8] chore: test --- .../PhotoEditor/index.mobile.native.tsx | 6 +- .../src/components/PhotoEditor/index.tsx | 5 +- packages/app-harness/test/specs/e2e.cjs | 60 ++++++++----------- 3 files changed, 27 insertions(+), 44 deletions(-) diff --git a/packages/app-harness/src/components/PhotoEditor/index.mobile.native.tsx b/packages/app-harness/src/components/PhotoEditor/index.mobile.native.tsx index 02898765a..047e1cc9d 100644 --- a/packages/app-harness/src/components/PhotoEditor/index.mobile.native.tsx +++ b/packages/app-harness/src/components/PhotoEditor/index.mobile.native.tsx @@ -4,7 +4,7 @@ import { RNPhotoEditor } from 'react-native-photo-editor'; import RNFS from 'react-native-fs'; import RNFetchBlob from 'rn-fetch-blob'; import { useLoggerContext } from '../../context'; -import { ICON_LOGO, testProps } from '../../config'; +import { ICON_LOGO } from '../../config'; import styles from '../../styles'; type ButtonProps = TouchableOpacityProps; @@ -40,9 +40,7 @@ export const PhotoEditorButton = forwardRef(({ on }; return ( - - Show PhotoEditor - + Show PhotoEditor ); }); diff --git a/packages/app-harness/src/components/PhotoEditor/index.tsx b/packages/app-harness/src/components/PhotoEditor/index.tsx index 4ac953a53..9787dd12b 100644 --- a/packages/app-harness/src/components/PhotoEditor/index.tsx +++ b/packages/app-harness/src/components/PhotoEditor/index.tsx @@ -2,7 +2,6 @@ import React, { forwardRef } from 'react'; import { useLoggerContext } from '../../context'; import { Text, TouchableOpacity, TouchableOpacityProps } from 'react-native'; import styles from '../../styles'; -import { testProps } from '../../config'; type ButtonProps = TouchableOpacityProps; export const PhotoEditorButton = forwardRef(({ onBlur, onFocus, style }, ref) => { @@ -13,9 +12,7 @@ export const PhotoEditorButton = forwardRef(({ on return ( - - Show PhotoEditor - + Show PhotoEditor ); }); diff --git a/packages/app-harness/test/specs/e2e.cjs b/packages/app-harness/test/specs/e2e.cjs index d97c99601..fc47db054 100644 --- a/packages/app-harness/test/specs/e2e.cjs +++ b/packages/app-harness/test/specs/e2e.cjs @@ -34,22 +34,21 @@ describe('Test App Harness', () => { } }); - // TODO - // it('--> Request permissions', async () => { - // await FlexnRunner.clickById('app-harness-home-request-permissions-button'); - // if (process.env.PLATFORM === 'web') { - // await FlexnRunner.expectToHaveTextById( - // 'app-harness-home-logs-text-3', - // 'Permissions: requestPermissions not supported on this platform' - // ); - // } else if (process.env.PLATFORM === 'ios') { - // await FlexnRunner.clickByText('Allow'); - // await FlexnRunner.expectToHaveTextById('app-harness-home-logs-text-4', 'Permissions: granted'); - // } else if (process.env.PLATFORM === 'android') { - // await FlexnRunner.clickByText('Allow'); - // await FlexnRunner.expectToHaveTextById('app-harness-home-logs-text-4', 'Permissions: granted'); - // } - // }); + it('--> Request permissions', async () => { + await FlexnRunner.clickById('app-harness-home-request-permissions-button'); + if (process.env.PLATFORM === 'web') { + await FlexnRunner.expectToHaveTextById( + 'app-harness-home-logs-text-3', + 'Permissions: requestPermissions not supported on this platform' + ); + } else if (process.env.PLATFORM === 'ios') { + await FlexnRunner.clickByText('Allow'); + await FlexnRunner.expectToHaveTextById('app-harness-home-logs-text-4', 'Permissions: granted'); + } else if (process.env.PLATFORM === 'android') { + await FlexnRunner.clickByText('Allow'); + await FlexnRunner.expectToHaveTextById('app-harness-home-logs-text-4', 'Permissions: granted'); + } + }); it('--> Orientation support ', async () => { await FlexnRunner.clickById('app-harness-home-toggle-video-button'); @@ -80,26 +79,15 @@ describe('Test App Harness', () => { }); // IN PROGRESS - it('--> Splash Screen', async () => { - await FlexnRunner.clickById('app-harness-home-splash-screen-button'); - if (process.env.PLATFORM === 'web') { - await FlexnRunner.expectToHaveTextById( - 'app-harness-home-logs-text-3', - 'SplashScreen.show not supported on this platform' - ); - } else { - await FlexnRunner.expectToBeDisplayedById(''); - } - }); - - // TODO - // if (process.env.PLATFORM === 'web') { - // it('--> PhotoEditor', async () => { - // await FlexnRunner.clickById('app-harness-home-photo-editor-button'); + // it('--> Splash Screen', async () => { + // await FlexnRunner.clickById('app-harness-home-splash-screen-button'); + // if (process.env.PLATFORM === 'web') { // await FlexnRunner.expectToHaveTextById( - // 'app-harness-home-logs-text-5', - // 'PhotoEditor not supported on this platform' + // 'app-harness-home-logs-text-3', + // 'SplashScreen.show not supported on this platform' // ); - // }); - // } + // } else { + // await FlexnRunner.expectToBeDisplayedById(''); + // } + // }); }); From 0348f3654857affa754b50c120509ef32195a288 Mon Sep 17 00:00:00 2001 From: pauliusguzas Date: Thu, 26 Sep 2024 19:36:16 +0300 Subject: [PATCH 7/8] chore:clean up --- packages/app-harness/src/app/index.tsx | 13 +++-------- packages/app-harness/test/specs/e2e.cjs | 29 ------------------------- 2 files changed, 3 insertions(+), 39 deletions(-) diff --git a/packages/app-harness/src/app/index.tsx b/packages/app-harness/src/app/index.tsx index 537692b5e..bf2658db3 100644 --- a/packages/app-harness/src/app/index.tsx +++ b/packages/app-harness/src/app/index.tsx @@ -206,12 +206,7 @@ const AppContent = () => { onFocus={() => setFocusedIndex(2)} onBlur={() => setFocusedIndex((prev) => (prev === 2 ? null : prev))} > - - Request permissions - + Request permissions @@ -238,7 +233,7 @@ const AppContent = () => { ref={splashBtnRef} onPress={() => { SplashScreen.show(); - setTimeout(() => SplashScreen.hide(), 60000); + setTimeout(() => SplashScreen.hide(), 3000); }} style={[ styles.button, @@ -248,9 +243,7 @@ const AppContent = () => { onFocus={() => setFocusedIndex(3)} onBlur={() => setFocusedIndex((prev) => (prev === 3 ? null : prev))} > - - Show SplashScreen - + Show SplashScreen diff --git a/packages/app-harness/test/specs/e2e.cjs b/packages/app-harness/test/specs/e2e.cjs index fc47db054..d3fde2772 100644 --- a/packages/app-harness/test/specs/e2e.cjs +++ b/packages/app-harness/test/specs/e2e.cjs @@ -34,22 +34,6 @@ describe('Test App Harness', () => { } }); - it('--> Request permissions', async () => { - await FlexnRunner.clickById('app-harness-home-request-permissions-button'); - if (process.env.PLATFORM === 'web') { - await FlexnRunner.expectToHaveTextById( - 'app-harness-home-logs-text-3', - 'Permissions: requestPermissions not supported on this platform' - ); - } else if (process.env.PLATFORM === 'ios') { - await FlexnRunner.clickByText('Allow'); - await FlexnRunner.expectToHaveTextById('app-harness-home-logs-text-4', 'Permissions: granted'); - } else if (process.env.PLATFORM === 'android') { - await FlexnRunner.clickByText('Allow'); - await FlexnRunner.expectToHaveTextById('app-harness-home-logs-text-4', 'Permissions: granted'); - } - }); - it('--> Orientation support ', async () => { await FlexnRunner.clickById('app-harness-home-toggle-video-button'); if (process.env.PLATFORM !== 'web') { @@ -77,17 +61,4 @@ describe('Test App Harness', () => { await FlexnRunner.expectToBeDisplayedByText('OK'); } }); - - // IN PROGRESS - // it('--> Splash Screen', async () => { - // await FlexnRunner.clickById('app-harness-home-splash-screen-button'); - // if (process.env.PLATFORM === 'web') { - // await FlexnRunner.expectToHaveTextById( - // 'app-harness-home-logs-text-3', - // 'SplashScreen.show not supported on this platform' - // ); - // } else { - // await FlexnRunner.expectToBeDisplayedById(''); - // } - // }); }); From 79d6d4366ccd363eed892fdafbe2035559edfba2 Mon Sep 17 00:00:00 2001 From: pauliusguzas Date: Thu, 26 Sep 2024 20:22:51 +0300 Subject: [PATCH 8/8] chore: add tv tests --- packages/app-harness/test/specs/e2e.cjs | 27 +++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/packages/app-harness/test/specs/e2e.cjs b/packages/app-harness/test/specs/e2e.cjs index d3fde2772..39df2c418 100644 --- a/packages/app-harness/test/specs/e2e.cjs +++ b/packages/app-harness/test/specs/e2e.cjs @@ -16,6 +16,11 @@ describe('Test App Harness', () => { it('--> Native Call', async () => { await FlexnRunner.clickById('app-harness-home-native-call-button'); + // https://github.com/flexn-io/renative/issues/1733 + if (process.env.PLATFORM === 'androidtv') { + await FlexnRunner.pressButtonDown(2); + } + await FlexnRunner.pressButtonSelect(1); if (process.env.PLATFORM === 'web') { await FlexnRunner.expectToHaveTextById( 'app-harness-home-logs-text-2', @@ -31,12 +36,24 @@ describe('Test App Harness', () => { 'app-harness-home-logs-text-3', 'NativeModules not supported for this platform' ); + } else if (process.env.PLATFORM === 'androidtv') { + await FlexnRunner.expectToHaveTextById( + 'app-harness-home-logs-text-1', + 'NativeModules not supported for this platform' + ); + } else if (process.env.PLATFORM === 'tvos') { + await FlexnRunner.expectToHaveTextById( + 'app-harness-home-logs-text-2', + 'NativeModules not supported for this platform' + ); } }); it('--> Orientation support ', async () => { await FlexnRunner.clickById('app-harness-home-toggle-video-button'); - if (process.env.PLATFORM !== 'web') { + await FlexnRunner.pressButtonDown(1); + await FlexnRunner.pressButtonSelect(1); + if (process.env.PLATFORM === 'ios' || process.env.PLATFORM === 'android') { await FlexnRunner.scrollById( 'app-harness-home-landscape-video-text', 'down', @@ -45,20 +62,22 @@ describe('Test App Harness', () => { } await FlexnRunner.expectToBeDisplayedById('app-harness-home-landscape-video-text'); await FlexnRunner.clickById('app-harness-home-toggle-video-button'); + await FlexnRunner.pressButtonSelect(1); }); it('--> Image Support ', async () => { + await FlexnRunner.pressButtonDown(2); await FlexnRunner.expectToBeDisplayedById('app-harness-home-image-support-image'); }); it('--> Cast Support ', async () => { - if (process.env.PLATFORM === 'web' || process.env.PLATFORM === 'ios') { - await FlexnRunner.expectToHaveTextById('app-harness-home-cast-support-text', 'Not supported'); - } else if (process.env.PLATFORM === 'android') { + if (process.env.PLATFORM === 'android') { await FlexnRunner.clickById('app-harness-home-cast-support-button'); await FlexnRunner.expectToBeDisplayedByText('Cast to'); await FlexnRunner.waitForDisplayedByText('OK'); await FlexnRunner.expectToBeDisplayedByText('OK'); + } else { + await FlexnRunner.expectToHaveTextById('app-harness-home-cast-support-text', 'Not supported'); } }); });