@@ -17,7 +17,10 @@ import {
1717} from "../utils/testReactions" ;
1818import { ReactionsAudioRenderer } from "./ReactionAudioRenderer" ;
1919import { GenericReaction , ReactionSet } from "../reactions" ;
20- import { playReactionsSound } from "../settings/settings" ;
20+ import {
21+ playReactionsSound ,
22+ soundEffectVolumeSetting ,
23+ } from "../settings/settings" ;
2124
2225const memberUserIdAlice = "@alice:example.org" ;
2326const memberUserIdBob = "@bob:example.org" ;
@@ -49,6 +52,7 @@ function TestComponent({
4952const originalPlayFn = window . HTMLMediaElement . prototype . play ;
5053afterAll ( ( ) => {
5154 playReactionsSound . setValue ( playReactionsSound . defaultValue ) ;
55+ soundEffectVolumeSetting . setValue ( soundEffectVolumeSetting . defaultValue ) ;
5256 window . HTMLMediaElement . prototype . play = originalPlayFn ;
5357} ) ;
5458
@@ -125,6 +129,28 @@ test("will play the generic audio sound when there is soundless reaction", () =>
125129 expect ( audioIsPlaying [ 0 ] ) . toContain ( GenericReaction . sound ?. ogg ) ;
126130} ) ;
127131
132+ test ( "will play an audio sound with the correct volume" , ( ) => {
133+ playReactionsSound . setValue ( true ) ;
134+ soundEffectVolumeSetting . setValue ( 0.5 ) ;
135+ const room = new MockRoom ( memberUserIdAlice ) ;
136+ const rtcSession = new MockRTCSession ( room , membership ) ;
137+ const { getByTestId } = render ( < TestComponent rtcSession = { rtcSession } /> ) ;
138+
139+ // Find the first reaction with a sound effect
140+ const chosenReaction = ReactionSet . find ( ( r ) => ! ! r . sound ) ;
141+ if ( ! chosenReaction ) {
142+ throw Error (
143+ "No reactions have sounds configured, this test cannot succeed" ,
144+ ) ;
145+ }
146+ act ( ( ) => {
147+ room . testSendReaction ( memberEventAlice , chosenReaction , membership ) ;
148+ } ) ;
149+ expect ( ( getByTestId ( chosenReaction . name ) as HTMLAudioElement ) . volume ) . toEqual (
150+ 0.5 ,
151+ ) ;
152+ } ) ;
153+
128154test ( "will play multiple audio sounds when there are multiple different reactions" , ( ) => {
129155 const audioIsPlaying : string [ ] = [ ] ;
130156 window . HTMLMediaElement . prototype . play = async function ( ) : Promise < void > {
0 commit comments