Skip to content

Commit

Permalink
Chore: improve functional test reliability by unhiding controls (#777)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanDeMicco authored Apr 23, 2018
1 parent 95f9fd4 commit 67d8e8c
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 22 deletions.
3 changes: 3 additions & 0 deletions functional-tests/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ exports.SELECTOR_BOX_PREVIEW_PAGE_NUM_WRAPPER = '.bp-page-num-wrapper';
exports.SELECTOR_BOX_PREVIEW_ERROR = '.bp-error';
exports.SELECTOR_BOX_PREVIEW_NAV_VISIBLE = '.bp-is-navigation-visible';

exports.CLASS_CONTAINER = '.bp-container';
exports.CLASS_CONTROLS_CONTAINER = '.bp-media-controls-container';
exports.CLASS_CONTROLS_WRAPPER = '.bp-controls-wrapper';
exports.CLASS_BOX_PREVIEW_LOADING_WRAPPER = '.bp-loading-wrapper';

exports.TEXT_1080P = '1080p';
Expand Down
8 changes: 4 additions & 4 deletions functional-tests/controls_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const {
} = require('./constants');
const assert = require('assert');

const { makeNavAppear, zoom, getIsFullscreen, showPreview } = require('./helpers');
const { makeNavAppear, zoom, getIsFullscreen, showPreview, showDocumentControls } = require('./helpers');

const { CI } = process.env;

Expand Down Expand Up @@ -50,7 +50,7 @@ Scenario('Check document preview zoom @ci @chrome @firefox @edge @ie @safari @an
Scenario('Check document preview navigation @ci @chrome @firefox @edge @ie @safari @android @ios', function*(I) {
const FIRST_PAGE = '#bp-page-1';
const SECOND_PAGE = '#bp-page-2';

showDocumentControls(I);
makeNavAppear(I);

// go to page 2
Expand Down Expand Up @@ -86,7 +86,7 @@ Scenario('Check document preview navigation @ci @chrome @firefox @edge @ie @safa
});

Scenario('Check document preview fullscreen @ci @chrome @firefox @edge @ie @safari @android @ios', function*(I) {
makeNavAppear(I);
showDocumentControls(I);

// Enter fullscreem
I.waitForVisible(SELECTOR_BOX_PREVIEW_ENTER_FULLSCREEN_ICON);
Expand All @@ -97,7 +97,7 @@ Scenario('Check document preview fullscreen @ci @chrome @firefox @edge @ie @safa

assert.ok(isFullscreen);

makeNavAppear(I);
showDocumentControls(I);

// Exit fullscreem
I.waitForVisible(SELECTOR_BOX_PREVIEW_EXIT_FULLSCREEN_ICON);
Expand Down
16 changes: 8 additions & 8 deletions functional-tests/fileOptions_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const {
FILE_ID_MP3
} = require('./constants');

const { makeNavAppear, disableDash, showPreview } = require('./helpers');
const { showMediaControls, showDocumentControls, disableDash, showPreview } = require('./helpers');

const { CI } = process.env;
const DOC_START = '2';
Expand Down Expand Up @@ -50,29 +50,29 @@ Scenario(
// Document
showPreview(I, FILE_ID_DOC, { fileOptions });

makeNavAppear(I);
showDocumentControls(I);
I.waitForVisible(SELECTOR_DOC_CURRENT_PAGE);
I.seeTextEquals(DOC_START, SELECTOR_DOC_CURRENT_PAGE);

// Video (DASH)
showPreview(I, FILE_ID_VIDEO, { fileOptions });

makeNavAppear(I, SELECTOR_VIDEO);
showMediaControls(I, SELECTOR_VIDEO);
I.waitForVisible(SELECTOR_MEDIA_TIMESTAMP);
I.seeTextEquals(VIDEO_START, SELECTOR_MEDIA_TIMESTAMP);

// MP3
showPreview(I, FILE_ID_MP3, { fileOptions });

makeNavAppear(I);
showMediaControls(I);
I.waitForVisible(SELECTOR_MEDIA_TIMESTAMP);
I.seeTextEquals(MP3_START, SELECTOR_MEDIA_TIMESTAMP);

// Video (MP4)
disableDash(I);
showPreview(I, FILE_ID_VIDEO, { fileOptions });

makeNavAppear(I, SELECTOR_VIDEO);
showMediaControls(I, SELECTOR_VIDEO);
I.waitForVisible(SELECTOR_MEDIA_TIMESTAMP);
I.seeTextEquals(VIDEO_START, SELECTOR_MEDIA_TIMESTAMP);
}
Expand All @@ -83,22 +83,22 @@ Scenario('Check preview starts at correct spot for all file types @ci @ie', { re
// Video (DASH)
showPreview(I, FILE_ID_VIDEO, { fileOptions });

makeNavAppear(I, SELECTOR_VIDEO);
showMediaControls(I, SELECTOR_VIDEO);
I.waitForVisible(SELECTOR_MEDIA_TIMESTAMP);
I.seeTextEquals(VIDEO_START, SELECTOR_MEDIA_TIMESTAMP);

// Document
showPreview(I, FILE_ID_DOC, { fileOptions });

makeNavAppear(I);
showDocumentControls(I);
I.waitForVisible(SELECTOR_DOC_CURRENT_PAGE);
I.seeTextEquals(DOC_START, SELECTOR_DOC_CURRENT_PAGE);

// Video (MP4)
disableDash(I);
showPreview(I, FILE_ID_VIDEO, { fileOptions });

makeNavAppear(I, SELECTOR_VIDEO);
showMediaControls(I, SELECTOR_VIDEO);
I.waitForVisible(SELECTOR_MEDIA_TIMESTAMP);
I.seeTextEquals(VIDEO_START, SELECTOR_MEDIA_TIMESTAMP);
});
28 changes: 26 additions & 2 deletions functional-tests/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ const {
CLASS_BOX_PREVIEW_LOADING_WRAPPER,
SELECTOR_BOX_PREVIEW_LOADED,
SELECTOR_BOX_PREVIEW_NAV_VISIBLE,
FILE_ID_DOC
FILE_ID_DOC,
CLASS_CONTAINER,
CLASS_CONTROLS_WRAPPER,
CLASS_CONTROLS_CONTAINER
} = require('./constants');

const { BROWSER_PLATFORM } = process.env;
Expand Down Expand Up @@ -124,10 +127,31 @@ exports.showPreview = (I, fileId = FILE_ID_DOC, options = {}) => {

waitForLoad(I);
};
exports.showMediaControls = (I) => {
I.executeScript(function(containerClass) {
var container = document.querySelector(containerClass);
container.classList.add('bp-media-controls-is-visible');
}, CLASS_CONTAINER);
I.waitForVisible(CLASS_CONTROLS_CONTAINER);
};
/**
* Shows the document controls
* @param {Object} I - the codeceptjs I
*
* @return {void}
*/
function showDocumentControls(I) {
I.executeScript(function(containerClass) {
var container = document.querySelector(containerClass);
container.classList.add('box-show-preview-controls');
}, CLASS_CONTAINER);
I.waitForVisible(CLASS_CONTROLS_WRAPPER);
}
exports.showDocumentControls = showDocumentControls;
/* eslint-enable prefer-arrow-callback, no-var */

exports.zoom = (I, selector) => {
makeNavAppear(I);
showDocumentControls(I);
I.waitForVisible(selector);
I.click(selector);
};
16 changes: 8 additions & 8 deletions functional-tests/mediaControls_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const {
TEXT_1080P
} = require('./constants');

const { showPreview, makeNavAppear, disableDash } = require('./helpers');
const { showPreview, showMediaControls, disableDash } = require('./helpers');

const { CI } = process.env;
const DEFAULT_START = '0:00';
Expand All @@ -48,7 +48,7 @@ Scenario(
// Video (DASH)
showPreview(I, FILE_ID_VIDEO);

makeNavAppear(I, SELECTOR_VIDEO);
showMediaControls(I, SELECTOR_VIDEO);
I.waitForVisible(SELECTOR_MEDIA_TIMESTAMP);
I.seeTextEquals(DEFAULT_START, SELECTOR_MEDIA_TIMESTAMP);
I.seeTextEquals(VIDEO_DURATION, SELECTOR_MEDIA_DURATION);
Expand All @@ -57,7 +57,7 @@ Scenario(
showPreview(I, FILE_ID_VIDEO_SUBTITLES_TRACKS);

I.waitForElement(SELECTOR_BOX_PREVIEW_DASH);
makeNavAppear(I, SELECTOR_VIDEO);
showMediaControls(I, SELECTOR_VIDEO);
I.waitForVisible(SELECTOR_MEDIA_TIMESTAMP);
I.seeTextEquals(DEFAULT_START, SELECTOR_MEDIA_TIMESTAMP);
I.seeTextEquals(VIDEO_WITH_SUBTITLES_TRACKS_DURATION, SELECTOR_MEDIA_DURATION);
Expand All @@ -66,7 +66,7 @@ Scenario(
showPreview(I, FILE_ID_MP3);

I.waitForElement(SELECTOR_BOX_PREVIEW_MP3);
makeNavAppear(I);
showMediaControls(I);
I.waitForVisible(SELECTOR_MEDIA_TIMESTAMP);
I.seeTextEquals(DEFAULT_START, SELECTOR_MEDIA_TIMESTAMP);
I.seeTextEquals(AUDIO_DURATION, SELECTOR_MEDIA_DURATION);
Expand All @@ -77,7 +77,7 @@ Scenario(

I.waitForElement(CLASS_BOX_PREVIEW_LOADING_WRAPPER);
I.waitForElement(SELECTOR_BOX_PREVIEW_MP4);
makeNavAppear(I, SELECTOR_VIDEO);
showMediaControls(I, SELECTOR_VIDEO);
I.waitForVisible(SELECTOR_MEDIA_TIMESTAMP);
I.seeTextEquals(DEFAULT_START, SELECTOR_MEDIA_TIMESTAMP);
I.seeTextEquals(VIDEO_DURATION, SELECTOR_MEDIA_DURATION);
Expand All @@ -94,7 +94,7 @@ Scenario(
showPreview(I, FILE_ID_VIDEO);

I.waitForElement(SELECTOR_BOX_PREVIEW_DASH);
makeNavAppear(I, SELECTOR_VIDEO);
showMediaControls(I, SELECTOR_VIDEO);
I.waitForVisible(SELECTOR_MEDIA_CONTROLS_GEAR);
// Click on the Gear
I.click(SELECTOR_MEDIA_CONTROLS_GEAR);
Expand All @@ -112,7 +112,7 @@ Scenario(
showPreview(I, FILE_ID_VIDEO_SUBTITLES_TRACKS);

I.waitForElement(SELECTOR_BOX_PREVIEW_DASH);
makeNavAppear(I, SELECTOR_VIDEO);
showMediaControls(I, SELECTOR_VIDEO);
// Wait for the CC button to be visisble
I.waitForVisible(SELECTOR_MEDIA_CONTROLS_CC_ICON);
// Look for this class bp-media-settings-subtitles-on
Expand Down Expand Up @@ -142,7 +142,7 @@ Scenario(
showPreview(I, FILE_ID_VIDEO_SMALL);

I.waitForElement(SELECTOR_MEDIA_CONTAINER);
makeNavAppear(I, SELECTOR_VIDEO);
showMediaControls(I, SELECTOR_VIDEO);
// Click on the Gear
I.waitForVisible(SELECTOR_MEDIA_CONTROLS_GEAR);
I.click(SELECTOR_MEDIA_CONTROLS_GEAR);
Expand Down
Empty file modified functional-tests/run-all.js
100644 → 100755
Empty file.

0 comments on commit 67d8e8c

Please sign in to comment.