Skip to content

Commit f4f82c6

Browse files
committed
adding option to not resize the viewport for screenshotSelector so that we can set some viewport height if we want to
1 parent 25ca16f commit f4f82c6

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

tests/UI/specs/Menus_spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ describe("Menus", function () {
106106
});
107107

108108
it('should load the admin left menu correctly on mobile', async function() {
109-
await page.webpage.setViewport({ width: 815, height: 700 });
109+
await page.webpage.setViewport({ width: 815, height: 1650 });
110110
await page.goto("?module=CoreAdminHome&action=home");
111111
await page.waitForNetworkIdle();
112112
await page.click('[data-target="mobile-left-menu"]');
@@ -119,7 +119,7 @@ describe("Menus", function () {
119119
await page.click('ul#mobile-left-menu > li:nth-child(6) a');
120120
await page.waitForTimeout(500);
121121

122-
expect(await page.screenshotSelector('#mobile-left-menu')).to.matchImage('mobile_left_admin');
122+
expect(await page.screenshotSelector('#mobile-left-menu', false)).to.matchImage('mobile_left_admin');
123123
});
124124

125125
it('should load the admin top menu correctly on mobile', async function() {
@@ -135,7 +135,7 @@ describe("Menus", function () {
135135
});
136136

137137
it('should load the left reporting menu correctly on mobile', async function() {
138-
await page.webpage.setViewport({ width: 768, height: 500 });
138+
await page.webpage.setViewport({ width: 768, height: 1000 });
139139
await page.goto("?" + generalParams + "&module=CoreHome&action=index#?category=General_Visitors&subcategory=General_Overview");
140140
await page.waitForNetworkIdle();
141141
await page.evaluate(function(){
@@ -145,6 +145,6 @@ describe("Menus", function () {
145145
await (await page.jQuery('#mobile-left-menu>li>ul:contains(Goals)')).click();
146146
await page.waitForTimeout(500);
147147

148-
expect(await page.screenshotSelector('#mobile-left-menu')).to.matchImage('mobile_left');
148+
expect(await page.screenshotSelector('#mobile-left-menu', false)).to.matchImage('mobile_left');
149149
});
150150
});

tests/lib/screenshot-testing/support/page-renderer.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,12 @@ PageRenderer.prototype.resizeViewportToFullPage = async function () {
197197
await this.webpage.setViewport(JSON.parse(dims));
198198
};
199199

200-
PageRenderer.prototype.screenshotSelector = async function (selector) {
200+
PageRenderer.prototype.screenshotSelector = async function (selector, resizeViewportToFullPage = true) {
201201
await this.waitForFunction(() => !! window.$, { timeout: 60000 });
202202

203-
await this.resizeViewportToFullPage();
203+
if (resizeViewportToFullPage) {
204+
await this.resizeViewportToFullPage();
205+
}
204206

205207
const result = await this.webpage.evaluate(function (selector) {
206208
window.jQuery('html').addClass('uiTest');

0 commit comments

Comments
 (0)