-
Notifications
You must be signed in to change notification settings - Fork 675
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: resize and maximize window with
disableMultipleWindows
option …
…in NA mode (#8135) <!-- Thank you for your contribution. Before making a PR, please read our contributing guidelines at https://github.com/DevExpress/testcafe/blob/master/CONTRIBUTING.md#code-contribution We recommend creating a *draft* PR, so that you can mark it as 'ready for review' when you are done. --> ## Purpose ## Approach ## References closes #8117 ## Pre-Merge TODO - [ ] Write tests for your proposed changes - [ ] Make sure that existing tests do not fail
- Loading branch information
1 parent
876db34
commit 93b3ccb
Showing
6 changed files
with
99 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Resize window</title> | ||
</head> | ||
<body> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
const { onlyInNativeAutomation } = require('../../../utils/skip-in'); | ||
const path = require('path'); | ||
const createTestCafe = require('../../../../../lib'); | ||
const { createReporter } = require('../../../utils/reporter'); | ||
const { expect } = require('chai'); | ||
|
||
let testCafe = null; | ||
let runner = null; | ||
let errors = null; | ||
|
||
const reporter = createReporter({ | ||
reportTestDone (_, testRunInfo) { | ||
errors = testRunInfo.errs; | ||
}, | ||
}); | ||
|
||
const run = (pathToTest, concurrency) => { | ||
const src = path.join(__dirname, pathToTest); | ||
|
||
return createTestCafe('127.0.0.1', 1335, 1336) | ||
.then(tc => { | ||
testCafe = tc; | ||
}) | ||
.then(() => { | ||
runner = testCafe.createRunner(); | ||
return runner | ||
.src(src) | ||
.browsers(`chrome`) | ||
.reporter(reporter) | ||
.concurrency(concurrency) | ||
.run({ disableMultipleWindows: true }); | ||
}) | ||
.then(() => { | ||
testCafe.close(); | ||
}); | ||
}; | ||
|
||
describe('[Regression](GH-8117)', function () { | ||
onlyInNativeAutomation('Should resize and maximize window in native automation mode with disableMultipleWindows option', function () { | ||
return run('testcafe-fixtures/maximize.js') | ||
.then(() => expect(errors.length).eql(0)); | ||
}); | ||
onlyInNativeAutomation('Should resize window in native automation mode with disableMultipleWindows option', function () { | ||
return run('testcafe-fixtures/resize.js') | ||
.then(() => expect(errors.length).eql(0)); | ||
}); | ||
}); |
25 changes: 25 additions & 0 deletions
25
test/functional/fixtures/regression/gh-8117/testcafe-fixtures/maximize.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { expect } from 'chai'; | ||
import { ClientFunction } from 'testcafe'; | ||
|
||
const getWindowDimensionsInfo = ClientFunction(() => { | ||
return { | ||
innerWidth: window.innerWidth, | ||
innerHeight: window.innerHeight, | ||
outerWidth: window.outerWidth, | ||
outerHeight: window.outerHeight, | ||
availableHeight: screen.availHeight, | ||
availableWidth: screen.availWidth, | ||
}; | ||
}); | ||
|
||
fixture `Maximize Window` | ||
.page `http://localhost:3000/fixtures/regression/gh-8117/pages/index.html`; | ||
|
||
test('Maximize window', async t => { | ||
await t.maximizeWindow(); | ||
|
||
const dimensions = await getWindowDimensionsInfo(); | ||
|
||
expect(dimensions.outerWidth).to.be.at.least(dimensions.availableWidth); | ||
expect(dimensions.outerHeight).to.be.at.least(dimensions.availableHeight); | ||
}); |
15 changes: 15 additions & 0 deletions
15
test/functional/fixtures/regression/gh-8117/testcafe-fixtures/resize.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { expect } from 'chai'; | ||
import { getWindowHeight, getWindowWidth } from '../../../../esm-utils/window-helpers.js'; | ||
|
||
fixture `Resize window` | ||
.page `http://localhost:3000/fixtures/regression/gh-8117/pages/index.html`; | ||
|
||
test('Resize window', async t => { | ||
const newWidth = 500; | ||
const newHeight = 500; | ||
|
||
await t.resizeWindow(newWidth, newHeight); | ||
|
||
expect(await getWindowWidth()).equals(newWidth); | ||
expect(await getWindowHeight()).equals(newHeight); | ||
}); |