Skip to content

Commit

Permalink
skip safari for flaky video test
Browse files Browse the repository at this point in the history
  • Loading branch information
William Chou committed Jul 5, 2017
1 parent 2006ed0 commit 1852b0f
Showing 1 changed file with 25 additions and 24 deletions.
49 changes: 25 additions & 24 deletions test/integration/test-video-players-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export function runVideoPlayerIntegrationTests(

it('should support mute, play, pause, unmute actions', function() {
return getVideoPlayer({outsideView: false, autoplay: false}).then(r => {
// Create a action buttons
// Create a action buttons
const playButton = createButton(r, 'play');
const pauseButton = createButton(r, 'pause');
const muteButton = createButton(r, 'mute');
Expand Down Expand Up @@ -92,15 +92,15 @@ export function runVideoPlayerIntegrationTests(
return button;
}

// Although these tests are not about autoplay, we can ony run them in
// browsers that do support autoplay, this is because a synthetic click
// event will not be considered a user-action and mobile browsers that
// don't support muted autoplay will block it. In real life, the click
// would be considered a user-initiated action, but no way to do that in a
// scripted test environment.
// Although these tests are not about autoplay, we can ony run them in
// browsers that do support autoplay, this is because a synthetic click
// event will not be considered a user-action and mobile browsers that
// don't support muted autoplay will block it. In real life, the click
// would be considered a user-initiated action, but no way to do that in a
// scripted test environment.
before(function() {
this.timeout(TIMEOUT);
// Skip autoplay tests if browser does not support autoplay.
// Skip autoplay tests if browser does not support autoplay.
return supportsAutoplay(window, false).then(supportsAutoplay => {
if (!supportsAutoplay) {
this.skip();
Expand All @@ -113,6 +113,7 @@ export function runVideoPlayerIntegrationTests(

describe.configure().retryOnSaucelabs().run('Autoplay', function() {
this.timeout(TIMEOUT);

describe('play/pause', () => {
it('should play when in view port initially', () => {
return getVideoPlayer({outsideView: false, autoplay: true}).then(r => {
Expand All @@ -126,24 +127,26 @@ export function runVideoPlayerIntegrationTests(
const p = listenOncePromise(r.video, VideoEvents.PLAY).then(() => {
return Promise.reject('should not have autoplayed');
});
// we have to wait to ensure play is NOT called.
// we have to wait to ensure play is NOT called.
return Promise.race([timer.promise(1000), p]);
});
});

it('should play/pause when video enters/exists viewport', () => {
// TODO(aghassemi, #9379): Flaky on Safari 9.
it.configure().skipSafari().run(
'should play/pause when video enters/exits viewport', () => {
let video;
let viewport;
return getVideoPlayer({outsideView: true, autoplay: true}).then(r => {
video = r.video;
viewport = video.implementation_.getViewport();

// scroll to the bottom, make video fully visible
// scroll to the bottom, make video fully visible
const p = listenOncePromise(video, VideoEvents.PLAY);
viewport.scrollIntoView(video);
return p;
}).then(() => {
// scroll back to top, make video not visible
// scroll back to top, make video not visible
const p = listenOncePromise(video, VideoEvents.PAUSE);
viewport.setScrollTop(0);
return p;
Expand All @@ -152,7 +155,7 @@ export function runVideoPlayerIntegrationTests(
});

describe('Animated Icon', () => {
// TODO(amphtml): Unskip when #8385 is fixed.
// TODO(amphtml): Unskip when #9379 is fixed.
it.skip('should create an animated icon overlay', () => {
let video;
let viewport;
Expand All @@ -165,11 +168,11 @@ export function runVideoPlayerIntegrationTests(
}).then(() => {
icon = video.querySelector('i-amphtml-video-eq');
expect(icon).to.exist;
// animation should be paused since video is not played yet
// animation should be paused since video is not played yet
expect(isAnimationPaused(icon)).to.be.true;

viewport = video.implementation_.getViewport();
// scroll to the bottom, make video fully visible so it autoplays
// scroll to the bottom, make video fully visible so it autoplays
viewport.scrollIntoView(video);

return waitForAnimationPlay(icon).then(() => {
Expand All @@ -180,14 +183,12 @@ export function runVideoPlayerIntegrationTests(
function isAnimationPaused(iconElement) {
const animElement = iconElement.querySelector('.amp-video-eq-1-1');
const win = iconElement.ownerDocument.defaultView;
const computedStyle = win.getComputedStyle(animElement);
const cs = win.getComputedStyle(animElement);
const isPaused =
(computedStyle.getPropertyValue('animation-play-state') == 'paused'
|| computedStyle.getPropertyValue('-webkit-animation-play-state') ==
'paused'
|| computedStyle.getPropertyValue('animation-name') == 'none'
|| computedStyle.getPropertyValue('-webkit-animation-name') ==
'none');
cs.getPropertyValue('animation-play-state') == 'paused' ||
cs.getPropertyValue('-webkit-animation-play-state') == 'paused' ||
cs.getPropertyValue('animation-name') == 'none' ||
cs.getPropertyValue('-webkit-animation-name') == 'none';
return isPaused;
}

Expand All @@ -201,7 +202,7 @@ export function runVideoPlayerIntegrationTests(

before(function() {
this.timeout(TIMEOUT);
// Skip autoplay tests if browser does not support autoplay.
// Skip autoplay tests if browser does not support autoplay.
return supportsAutoplay(window, false).then(supportsAutoplay => {
if (!supportsAutoplay) {
this.skip();
Expand Down Expand Up @@ -248,7 +249,7 @@ export function runVideoPlayerIntegrationTests(
videoGlobal = video;
return poll('video built', () => {
return video.implementation_ && video.implementation_.play;
},undefined, 5000).then(() => {
}, /* opt_onError */ undefined, /* opt_timeout */ 5000).then(() => {
return {video, fixture};
});
});
Expand Down

0 comments on commit 1852b0f

Please sign in to comment.