From 0de2a9a97ee2a34fb8cafaac54ab7d60facda70f Mon Sep 17 00:00:00 2001 From: Violet Caulfield <42452695+anultravioletaurora@users.noreply.github.com> Date: Sun, 20 Jul 2025 07:25:22 -0500 Subject: [PATCH] Seek to Beginning of Track if Playback has Finished (#448) --- .github/workflows/maestro-test.yml | 3 +-- maestro-tests/login.yaml | 8 ++------ maestro-tests/search.yaml | 3 ++- maestro-tests/settings.yaml | 2 +- scripts/maestro-android.js | 9 ++++----- src/providers/Player/index.tsx | 15 +++++++++++++-- 6 files changed, 23 insertions(+), 17 deletions(-) diff --git a/.github/workflows/maestro-test.yml b/.github/workflows/maestro-test.yml index 1ed59b94..1a4bf3b6 100644 --- a/.github/workflows/maestro-test.yml +++ b/.github/workflows/maestro-test.yml @@ -67,7 +67,6 @@ jobs: env: JELLYFIN_TEST_ADDRESS: ${{ secrets.JELLYFIN_TEST_URL }} JELLYFIN_TEST_USERNAME: ${{ secrets.JELLYFIN_TEST_USERNAME }} - JELLYFIN_TEST_PASSWORD: ${{ secrets.JELLYFIN_TEST_PASSWORD }} steps: - name: 🛒 Checkout @@ -122,7 +121,7 @@ jobs: disable-animations: false avd-name: e2e_emulator script: | - node scripts/maestro-android.js ${{ env.JELLYFIN_TEST_ADDRESS }} ${{ env.JELLYFIN_TEST_USERNAME }} ${{ env.JELLYFIN_TEST_PASSWORD }} + node scripts/maestro-android.js ${{ env.JELLYFIN_TEST_ADDRESS }} ${{ env.JELLYFIN_TEST_USERNAME }} - name: Store tests result uses: actions/upload-artifact@v4.3.4 if: always() diff --git a/maestro-tests/login.yaml b/maestro-tests/login.yaml index dc55000d..157bf2bb 100644 --- a/maestro-tests/login.yaml +++ b/maestro-tests/login.yaml @@ -13,20 +13,16 @@ appId: com.jellify - hideKeyboard - tapOn: id: "connect_button" -- assertVisible: "Sign in to Cosmonautical" +- assertVisible: "Sign in to Cassiopeia" - tapOn: id: "username_input" - inputText: "${username}" - hideKeyboard -- tapOn: - id: "password_input" -- inputText: "${password}" -- hideKeyboard - tapOn: id: "sign_in_button" - assertVisible: "Select Music Library" - tapOn: - text: "Music" + text: "Royalty Free Music" - tapOn: id: "let_s_go_button" # Close the app to ensure app is logged in diff --git a/maestro-tests/search.yaml b/maestro-tests/search.yaml index ac2f7f29..5d6f3c52 100644 --- a/maestro-tests/search.yaml +++ b/maestro-tests/search.yaml @@ -9,7 +9,8 @@ appId: com.jellify - tapOn: id: "search-input" -- inputText: "bbno$" +- inputText: "Otis McDonald" +- hideKeyboard - assertVisible: id: "artist-search-result-0" diff --git a/maestro-tests/settings.yaml b/maestro-tests/settings.yaml index ad73b8db..9e7e1e3d 100644 --- a/maestro-tests/settings.yaml +++ b/maestro-tests/settings.yaml @@ -72,7 +72,7 @@ appId: com.jellify - tapOn: text: "Sign Out" - assertVisible: - text: "Sign out of Cosmonautical?" + text: "Sign out of Cassiopeia?" - tapOn: text: "Cancel" diff --git a/scripts/maestro-android.js b/scripts/maestro-android.js index bf533f7b..e53378fe 100644 --- a/scripts/maestro-android.js +++ b/scripts/maestro-android.js @@ -3,10 +3,10 @@ const { execSync, exec, spawn } = require('child_process') const path = require('path') // Read arguments from CLI -const [, , serverAddress, username, password] = process.argv +const [, , serverAddress, username] = process.argv -if (!serverAddress || !username || !password) { - console.error('Usage: node runMaestro.js ') +if (!serverAddress || !username) { + console.error('Usage: node runMaestro.js ') process.exit(1) } @@ -53,8 +53,7 @@ async function stopRecording(pid) { const command = `${MAESTRO_PATH} test ${FLOW_PATH} \ --env server_address=${serverAddress} \ - --env username=${username} \ - --env password=${password}` + --env username=${username}` const output = execSync(command, { stdio: 'inherit', env: process.env }) console.log('✅ Maestro test completed') diff --git a/src/providers/Player/index.tsx b/src/providers/Player/index.tsx index 484d37ec..e4eb8a26 100644 --- a/src/providers/Player/index.tsx +++ b/src/providers/Player/index.tsx @@ -368,9 +368,20 @@ const PlayerContextInitializer = () => { const useTogglePlayback = useMutation({ mutationFn: async () => { trigger('impactMedium') - if ((await TrackPlayer.getPlaybackState()).state === State.Playing) + + const { state } = await TrackPlayer.getPlaybackState() + + if (state === State.Playing) { return TrackPlayer.pause() - else return TrackPlayer.play() + } + + const { duration, position } = await TrackPlayer.getProgress() + + // if the track has ended, seek to start and play + if (duration <= position) { + await TrackPlayer.seekTo(0) + } + return TrackPlayer.play() }, })