static/tests/frontend/specs/race_conditions.js
// We click mute an odd number of times and video-off an even number of times.
We click mute an odd number of times and video-off an even number of times.
We click mute an odd number of times and video - off an even number of times .
function testManyClicks(done) {
    const chrome$ = helper.padChrome$;
    function loop(i) {
      expect(chrome$('.audio-btn').hasClass('muted'))
          .to.equal(!audioTrack.enabled);
      expect(chrome$('.video-btn').hasClass('off'))
          .to.equal(!videoTrack.enabled);
      Promise.all([
        new Promise(((resolve) => { chrome$('.audio-btn').click(); resolve(); })),
        new Promise(((resolve) => { chrome$('.audio-btn').click(); resolve(); })),
        new Promise(((resolve) => { chrome$('.audio-btn').click(); resolve(); })),
        new Promise(((resolve) => { chrome$('.video-btn').click(); resolve(); })),
        new Promise(((resolve) => { chrome$('.video-btn').click(); resolve(); })),
      ]).then(() => {
        setTimeout(() => { 
          expect(chrome$('.audio-btn').hasClass('muted'))
              .to.equal(!audioTrack.enabled);
          expect(chrome$('.video-btn').hasClass('off'))
              .to.equal(!videoTrack.enabled);
          if (i > 0) {
            loop(i - 1);
          } else {
            done();
          }
        }, 100);
      });
    }
    loop(10);
  }
function testManyClicks ( done ) { const chrome$ = helper . padChrome$ ; function loop ( i ) { expect ( chrome$ ( '.audio-btn' ) . hasClass ( 'muted' ) ) . to . equal ( ! audioTrack . enabled ) ; expect ( chrome$ ( '.video-btn' ) . hasClass ( 'off' ) ) . to . equal ( ! videoTrack . enabled ) ; Promise . all ( [ new Promise ( ( ( resolve ) => { chrome$ ( '.audio-btn' ) . click ( ) ; resolve ( ) ; } ) ) , new Promise ( ( ( resolve ) => { chrome$ ( '.audio-btn' ) . click ( ) ; resolve ( ) ; } ) ) , new Promise ( ( ( resolve ) => { chrome$ ( '.audio-btn' ) . click ( ) ; resolve ( ) ; } ) ) , new Promise ( ( ( resolve ) => { chrome$ ( '.video-btn' ) . click ( ) ; resolve ( ) ; } ) ) , new Promise ( ( ( resolve ) => { chrome$ ( '.video-btn' ) . click ( ) ; resolve ( ) ; } ) ) , ] ) . then ( ( ) => { setTimeout ( ( ) => { expect ( chrome$ ( '.audio-btn' ) . hasClass ( 'muted' ) ) . to . equal ( ! audioTrack . enabled ) ; expect ( chrome$ ( '.video-btn' ) . hasClass ( 'off' ) ) . to . equal ( ! videoTrack . enabled ) ; if ( i > 0 ) { loop ( i - 1 ) ; } else { done ( ) ; } } , 100 ) ; } ) ; } loop ( 10 ) ; }
We click mute an odd number of times and video-off an even number of times.
We click mute an odd number of times and video - off an even number of times .
// wait to make sure it's settled