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

video.js issue with an element not visible in the test suite #2050

Open
vlad-platformq opened this issue Jan 26, 2023 · 1 comment
Open

video.js issue with an element not visible in the test suite #2050

vlad-platformq opened this issue Jan 26, 2023 · 1 comment

Comments

@vlad-platformq
Copy link

vlad-platformq commented Jan 26, 2023

Missing elements from wrapper

We are using video.js and are pragmatically "hiding" elements if a condition passes. Apparently, one of the classes is not visible by the test suite.

Steps to reproduce

create a video component with this as the logic

    <template>
         <video
             ref="video"
             class="video-js vjs-big-play-centered"
             playsinline
          />
   </template>

<script lang="ts">
    @Ref('video') video!: HTMLVideoElement
   
   mounted() {
     this.player = videojs(this.video)
     const htmlPlayer = (this.player as any).el_
     htmlPlayer.getElementsByClassName('vjs-progress-control')[0].style.visibility = 'hidden'
      // this line will throw
      htmlPlayer.getElementsByClassName('vjs-picture-in-picture-control')[0].style.display = 'none'
   }
</script>

shallowMount the component in a unit test

Expected behaviour

The element should be visible in the test suite

Actual behaviour

When using wrapper.html() the element with that classname does not exist

in addition the test fails with this error

    TypeError: Cannot read property 'style' of undefined

      138 |     /* istanbul ignore next */
      139 |     if (this.disablePip === 'true') {
    > 140 |       htmlPlayer.getElementsByClassName('vjs-picture-in-picture-control')[0].style.display = 'none'
          | ^
      141 |     }

Possible Solution

I tried creating the element with that specified classname, but was unseccessful

@ebisbe
Copy link
Collaborator

ebisbe commented Jan 27, 2023

@vlad-platformq can you provide a proper reproduction link in a repository or codesandbox so we can have a look easier?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants