Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/ppdsc 2854 flaky tests #680

Merged
merged 7 commits into from
Mar 2, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions scripts/percy_local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ if [[ $BRANCH_NAME == "main" ]]; then
exit 1
fi
echo "Running on main, so baseline images will be updated"
read -p "Are you sure you want to update the baselines? (y/n)" updateBaselinesRes
if [[ "$updateBaselinesRes" != "y" ]]; then
exit 1
fi
else
export PERCY_BRANCH="local run by ${USERNAME}"
fi

echo "PERCY_BRANCH=$PERCY_BRANCH"

# ask the user to input their API key
read -p "Enter the API key for the 'newskit-$1' project (you can find this in the Percy UI): " apiKey

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1255,10 +1255,15 @@ describe('Audio Player Composable', () => {
'audio-player-time-display',
) as HTMLParagraphElement;

fireEvent.durationChange(audioElement, {
target: {
duration: 60,
},
});
const seekBar = getByTestId('audio-slider-track') as HTMLDivElement;
fireEvent.timeUpdate(audioElement);
expect(audioElement.currentTime).toEqual(50);
expect(audioTimeLabel.innerHTML).toEqual('00:50/00:00 ');
expect(audioTimeLabel.innerHTML).toEqual('00:50/01:00 ');
expect(seekBar.getAttribute('values')).toEqual('50');
});
});
Expand Down
4 changes: 2 additions & 2 deletions src/audio-player-composable/audio-player-composable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ export const AudioPlayerComposable = ({
// On render onTimeUpdate will be fired and initialTime will be set as a value for currentTime state.
// I can't set this one to the setCurrentTime state directly as the audioElement time
// will still be 0, currentTime will be overridden to 0 and the audio will start from 0
if (audioRef && audioRef.current) {
if (audioRef && audioRef.current && duration) {
audioRef.current.currentTime = initialTime;
}
setCurrentTime(0);
setDisplayDuration(0);
}, [src, initialTime]);
}, [src, initialTime, duration]);

const {
audioEvents,
Expand Down