From 15782d9bd5021a449dfaca95aee990310f3d8202 Mon Sep 17 00:00:00 2001 From: Tom Van Laerhoven Date: Tue, 5 Nov 2024 14:14:49 +0100 Subject: [PATCH 1/4] Fix waiting for player to be ready --- e2e/src/components/TestableTHEOplayerView.tsx | 34 +++++++++++++++---- e2e/src/tests/Basic.spec.ts | 2 +- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/e2e/src/components/TestableTHEOplayerView.tsx b/e2e/src/components/TestableTHEOplayerView.tsx index ac17ec766..1e3691c3a 100644 --- a/e2e/src/components/TestableTHEOplayerView.tsx +++ b/e2e/src/components/TestableTHEOplayerView.tsx @@ -1,23 +1,45 @@ import { useCavy } from 'cavy'; import { THEOplayer, THEOplayerView, THEOplayerViewProps } from 'react-native-theoplayer'; import React, { useCallback } from 'react'; -import { PromiseController } from '../utils/PromiseController'; -let playerController = new PromiseController(); +let testPlayer: THEOplayer | undefined = undefined; -export const getTestPlayer = async (): Promise => { - return playerController.promise_; +/** + * Wait until the player is ready. + * + * @param timeout Delay after rejecting the player. + * @param poll Delay before trying again. + */ +export const getTestPlayer = async (timeout = 5000, poll = 200): Promise => { + return new Promise((resolve, reject) => { + const start = Date.now(); + const checkPlayer = () => { + setTimeout(() => { + if (testPlayer) { + // Player is ready. + resolve(testPlayer); + } else if (Date.now() - start > timeout) { + // Too late. + reject('Player not ready'); + } else { + // Wait & try again. + checkPlayer(); + } + }, poll); + }; + checkPlayer(); + }); }; export const TestableTHEOplayerView = (props: THEOplayerViewProps) => { const generateTestHook = useCavy(); const onPlayerReady = useCallback((player: THEOplayer) => { - playerController.resolve_(player); + testPlayer = player; props.onPlayerReady?.(player); }, []); const onPlayerDestroy = useCallback(() => { - playerController = new PromiseController(); + testPlayer = undefined; }, []); return ; diff --git a/e2e/src/tests/Basic.spec.ts b/e2e/src/tests/Basic.spec.ts index 6de3f00fc..c21c2346c 100644 --- a/e2e/src/tests/Basic.spec.ts +++ b/e2e/src/tests/Basic.spec.ts @@ -6,7 +6,7 @@ import hls from '../res/hls.json'; import mp4 from '../res/mp4.json'; import { expect, preparePlayerWithSource, waitForPlayerEventType, waitForPlayerEventTypes } from '../utils/Actions'; -const SEEK_THRESHOLD = 1e-1; +const SEEK_THRESHOLD = 250; function testBasicPlayout(spec: TestScope, title: string, source: SourceDescription) { spec.describe(title, function () { From 18d9cb3204bdafcd238b6b773e60d2088d1422a2 Mon Sep 17 00:00:00 2001 From: Tom Van Laerhoven Date: Tue, 5 Nov 2024 16:43:49 +0100 Subject: [PATCH 2/4] Change test order --- e2e/src/tests/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/src/tests/index.ts b/e2e/src/tests/index.ts index 441b24a0f..6e26987e2 100644 --- a/e2e/src/tests/index.ts +++ b/e2e/src/tests/index.ts @@ -4,4 +4,4 @@ import Connector from './Connector.spec'; import PresentationMode from './PresentationMode.spec'; import Version from './Version.spec'; -export default [Basic, Ads, Connector, PresentationMode, Version]; +export default [Version, Basic, Ads, Connector, PresentationMode]; From be0c63a4ba6212d051ddba0463966a8a96a1d82e Mon Sep 17 00:00:00 2001 From: Tom Van Laerhoven Date: Tue, 5 Nov 2024 20:38:15 +0100 Subject: [PATCH 3/4] Add cavy log patch --- e2e/patches/cavy+4.0.2.patch | 55 ++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 e2e/patches/cavy+4.0.2.patch diff --git a/e2e/patches/cavy+4.0.2.patch b/e2e/patches/cavy+4.0.2.patch new file mode 100644 index 000000000..d43bf5dc2 --- /dev/null +++ b/e2e/patches/cavy+4.0.2.patch @@ -0,0 +1,55 @@ +diff --git a/node_modules/cavy/src/Reporter.js b/node_modules/cavy/src/Reporter.js +index 1cdeb38..f7e9e35 100644 +--- a/node_modules/cavy/src/Reporter.js ++++ b/node_modules/cavy/src/Reporter.js +@@ -9,7 +9,15 @@ export default class Reporter { + // Internal: Creates a websocket connection to the cavy-cli server. + onStart() { + const url = 'ws://127.0.0.1:8082/'; ++ console.debug('Creating websocket'); + this.ws = new WebSocket(url); ++ this.ws.onerror = console.error ++ this.ws.onopen = () => { ++ console.debug('Successfully opened websocket'); ++ } ++ this.ws.onclose = () => { ++ console.debug('Closing websocket'); ++ } + } + + // Internal: Send a single test result to cavy-cli over the websocket connection. +@@ -34,7 +42,6 @@ export default class Reporter { + console.log(message); + } + } +- + // Private: Determines whether data can be sent over the websocket. + websocketReady() { + // WebSocket.readyState 1 means the web socket connection is OPEN. +diff --git a/node_modules/cavy/src/Tester.js b/node_modules/cavy/src/Tester.js +index c61e31a..8d222ae 100644 +--- a/node_modules/cavy/src/Tester.js ++++ b/node_modules/cavy/src/Tester.js +@@ -57,20 +57,8 @@ export default class Tester extends Component { + key: Math.random() + }; + this.testHookStore = props.store; +- // Default to sending a test report to cavy-cli if no custom reporter is +- // supplied. +- if (props.reporter instanceof Function) { +- const message = 'Deprecation warning: support for custom function' + +- 'reporters will soon be deprecated. Cavy supports custom ' + +- 'class based reporters. For more info, see the ' + +- 'documentation here: ' + +- 'https://cavy.app/docs/guides/writing-custom-reporters'; +- console.warn(message); +- this.reporter = props.reporter; +- } else { +- reporterClass = props.reporter || Reporter; +- this.reporter = new reporterClass; +- } ++ reporterClass = props.reporter || Reporter; ++ this.reporter = new reporterClass; + } + + componentDidMount() { From 019bb05c147d2ce8fdefd958e07780ad3d8e4955 Mon Sep 17 00:00:00 2001 From: Tom Van Laerhoven Date: Thu, 14 Nov 2024 09:15:41 +0100 Subject: [PATCH 4/4] Update iOS workflow --- .github/workflows/pr_ios.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pr_ios.yml b/.github/workflows/pr_ios.yml index c731e21d7..c4cc5d867 100644 --- a/.github/workflows/pr_ios.yml +++ b/.github/workflows/pr_ios.yml @@ -8,8 +8,8 @@ jobs: build: strategy: matrix: - xcode_version: [ '15.2' ] - runs-on: macos-14 + xcode_version: [ '15.4.0' ] + runs-on: macos-latest steps: - name: Checkout repository uses: actions/checkout@v4 @@ -17,7 +17,7 @@ jobs: - name: Select Xcode ${{ matrix.xcode_version }} uses: maxim-lobanov/setup-xcode@v1 with: - xcode-version: ${{ matrix.xcode_version }} # Check versions: https://github.com/actions/runner-images/blob/main/images/macos/macos-14-Readme.md + xcode-version: ${{ matrix.xcode_version }} - name: Setup Node uses: actions/setup-node@v4 @@ -50,10 +50,10 @@ jobs: pod update - name: Start iOS simulator - uses: futureware-tech/simulator-action@v3 + uses: futureware-tech/simulator-action@v4 with: - model: 'iPhone 14' - os_version: '>=16.0' + model: 'iPhone 15' + os_version: '>=14.0' - name: Run e2e tests working-directory: e2e