Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Commit

Permalink
Revert "[terra-functional-testing] Set test page to the viewport size…
Browse files Browse the repository at this point in the history
… instead of the browser's window size (#673)"

This reverts commit 4ada1f5.
  • Loading branch information
Jaime Mackey committed Jun 21, 2021
1 parent 1acf1f9 commit 65d8a05
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 110 deletions.
1 change: 0 additions & 1 deletion packages/terra-functional-testing/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

* Fixed
* Updated screenshot cleaning to match nested snapshot directories
* Updated to size the test page to the viewport size instead of the browser's window size to correctly match the corresponding breakpoint. This change may affect the size of existing screenshots, particularly in IE and firefox. The affected screenshots may need to be regenerated.

* Added
* Added screenshot paths for each test result to the spec reporter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
const setViewport = require('./setViewport');
const setViewportSize = require('./setViewportSize');
const getViewportSize = require('./getViewportSize');

/**
* Mocha `describe` block to run tests through a defined list of viewports.
Expand All @@ -24,7 +22,7 @@ const describeViewports = (title, viewports, fn) => {
global.describe(`[${viewport}]`, () => {
global.before(() => {
// Store the original browser window size so it can be restored after the test has run.
previousViewportSize = getViewportSize();
previousViewportSize = global.browser.getWindowSize();

setViewport(viewport);
});
Expand All @@ -33,7 +31,7 @@ const describeViewports = (title, viewports, fn) => {

global.after(() => {
// Restore the browser window to the original size.
setViewportSize(previousViewportSize);
global.browser.setWindowSize(previousViewportSize.width, previousViewportSize.height);
});
});
});
Expand Down

This file was deleted.

4 changes: 0 additions & 4 deletions packages/terra-functional-testing/src/commands/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ const dispatchCustomEvent = require('./dispatchCustomEvent');
const downloadScreenshots = require('./downloadScreenshots');
const eventEmitter = require('./eventEmitter');
const getViewports = require('./getViewports');
const getViewportSize = require('./getViewportSize');
const hideInputCaret = require('./hideInputCaret');
const setApplicationLocale = require('./setApplicationLocale');
const setViewport = require('./setViewport');
const setViewportSize = require('./setViewportSize');

module.exports = {
cleanScreenshots,
Expand All @@ -19,9 +17,7 @@ module.exports = {
downloadScreenshots,
eventEmitter,
getViewports,
getViewportSize,
hideInputCaret,
setApplicationLocale,
setViewport,
setViewportSize,
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const { Logger } = require('@cerner/terra-cli');
const { TERRA_VIEWPORTS } = require('../../constants');
const setViewportSize = require('./setViewportSize');

const logger = new Logger({ prefix: '[terra-functional-testing:setViewport]' });

Expand All @@ -14,9 +13,9 @@ const setViewport = (viewport) => {
return;
}

const terraViewport = TERRA_VIEWPORTS[viewport];
const { height, width } = TERRA_VIEWPORTS[viewport];

setViewportSize(terraViewport);
global.browser.setWindowSize(width, height);
};

module.exports = setViewport;

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
/* global browser */

const { TERRA_VIEWPORTS } = require('../../../constants');
const { getViewportSize } = require('../../../commands/utils');

/**
* Determines the current viewport size.
*
* @returns {Object} - the current viewport size.
*/
function getViewportSize() {
// eslint-disable-next-line prefer-arrow-callback
const resolution = browser.execute(function getResolution() {
return {
screenWidth: Math.max(document.documentElement.clientWidth, window.innerWidth || 0),
screenHeight: Math.max(document.documentElement.clientHeight, window.innerHeight || 0),
};
});

return {
width: resolution.screenWidth,
height: resolution.screenHeight,
};
}

/**
* Determines the Terra form factor for the current viewport size.
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ const {
downloadScreenshots,
eventEmitter,
getViewports,
getViewportSize,
hideInputCaret,
setApplicationLocale,
setViewport,
setViewportSize,
} = require('../../../../src/commands/utils');

describe('index', () => {
Expand All @@ -22,10 +20,8 @@ describe('index', () => {
expect(downloadScreenshots).toBeDefined();
expect(eventEmitter).toBeDefined();
expect(getViewports).toBeDefined();
expect(getViewportSize).toBeDefined();
expect(hideInputCaret).toBeDefined();
expect(setApplicationLocale).toBeDefined();
expect(setViewport).toBeDefined();
expect(setViewportSize).toBeDefined();
});
});
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
const { setViewport, setViewportSize } = require('../../../../src/commands/utils');
const { setViewport } = require('../../../../src/commands/utils');
const { TERRA_VIEWPORTS } = require('../../../../src/constants');

jest.mock('../../../../src/commands/utils/setViewportSize');
const mockSetWindowSize = jest.fn();

global.browser = {
setWindowSize: mockSetWindowSize,
};

describe('setViewport', () => {
it('should set specified viewport', () => {
const tinyViewport = TERRA_VIEWPORTS.tiny;
const { width, height } = TERRA_VIEWPORTS.tiny;

setViewport('tiny');

expect(setViewportSize).toHaveBeenCalledWith(tinyViewport);
expect(global.browser.setWindowSize).toHaveBeenCalledWith(width, height);
});

it('should not set the window size for unsupported viewport', () => {
setViewport('unsupported-viewport');

expect(setViewportSize).not.toHaveBeenCalled();
expect(global.browser.setWindowSize).not.toHaveBeenCalled();
});
});

This file was deleted.

0 comments on commit 65d8a05

Please sign in to comment.