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

Media player component in story book is broken #231

Open
pietrop opened this issue Apr 23, 2020 · 1 comment
Open

Media player component in story book is broken #231

pietrop opened this issue Apr 23, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@pietrop
Copy link
Contributor

pietrop commented Apr 23, 2020

Media player in story book is broken

https://bbc.github.io/react-transcript-editor/?path=/story/mediaplayer--default

Screen Shot 2020-04-23 at 4 36 40 PM

This is the fix in /packages/components/media-player/index.js

 getProgressBarMax = () => {
   if( this.props.videoRef && this.props.videoRef.current && this.props.videoRef.current.duration){
    return parseInt(this.props.videoRef.current.duration).toString()
   } else{
     return 0
   }
  }
    
  getProgressBarValue = () => {
   if(this.props.videoRef && this.props.videoRef.current && this.props.videoRef.current.currentTime){
    return parseInt(this.props.videoRef.current.currentTime).toString()
   } else{
     return 0
   }
  }

  getMediaCurrentTime = () => {
    if(this.props.videoRef && this.props.videoRef.current && this.props.videoRef.current.currentTime){
      return secondsToTimecode(this.props.videoRef.current.currentTime + this.state.timecodeOffset)
    } else{
      return '00:00:00:00'
    }
  }

also storybook needs to be changed to

/packages/components/media-player/index.test.js

import React from 'react';
import { render, cleanup } from 'react-testing-library';
import { shallow } from 'enzyme';

import MediaPlayer from './index.js';

afterEach(cleanup);

videoRef = React.createRef();

const fakeUrl = "https://storage.googleapis.com/coverr-main/mp4/Pigeon-Impossible.mp4";
const fakeVideoUrl = <video ref={ videoRef } src={url}></video>;

xtest('GIVEN a chapter title I expect that WHEN the Video component is rendered THEN the correct title is displayed', () => {
  const { container } = render(<MediaPlayer videoRef={videoRef} mediaUrl={ fakeUrl } />);

  expect(container.innerHTML).toContain('videoSection');
});

xtest("GIVEN a video as a chapter with src video url THEN the video is rendered fakeUrl it's source url", () => {
  const { getByTestId } = render(<MediaPlayer videoRef={videoRef} mediaUrl={ fakeVideoUrl } />);

  expect(getByTestId('media-player-id').attributes.src.value).toBe(fakeUrl);
});
xtest('WHEN the Video component is rendered THEN a video element is displayed', () => {
  const wrapper = shallow(<MediaPlayer videoRef={videoRef} mediaUrl={ fakeUrl } />);
  expect(wrapper.find('video').type()).toBe('video');
});

after the fix

Screen Shot 2020-04-23 at 4 38 29 PM

@pietrop pietrop added the bug Something isn't working label Apr 23, 2020
@pietrop
Copy link
Contributor Author

pietrop commented Apr 23, 2020

integrating this change in pietrop#13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant