Skip to content

Commit

Permalink
testing test-functional-docker workflow (#8151)
Browse files Browse the repository at this point in the history
<!--
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
closes DevExpress/testcafe-private#225

## Approach
_Describe how your changes address the issue or implement the desired
functionality in as much detail as possible._

## References
_Provide a link to the existing issue(s), if any._

## Pre-Merge TODO
- [ ] Write tests for your proposed changes
- [ ] Make sure that existing tests do not fail

---------

Co-authored-by: Bayheck <adil.rakhaliyev@devexpress.com>
  • Loading branch information
Bayheck and Bayheck authored Mar 29, 2024
1 parent 48ba0f7 commit f87553c
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
export const CONTAINERIZED_CHROME_FLAGS = ['--no-sandbox', '--disable-dev-shm-usage'];

export function buildChromeArgs ({ config, cdpPort, platformArgs, tempProfileDir, isContainerized, isNativeAutomation }) {
export function buildChromeArgs ({ config, cdpPort, platformArgs, tempProfileDir, isContainerized, isNativeAutomation, browserName }) {
const headlessMode = ['chrome', 'chromium'].includes(browserName) ? '--headless=new' : '--headless';

let chromeArgs = []
.concat(
cdpPort ? [`--remote-debugging-port=${cdpPort}`] : [],
!config.userProfile ? [`--user-data-dir=${tempProfileDir.path}`] : [],
config.headless ? ['--headless'] : [],
config.headless ? [headlessMode] : [],
config.userArgs ? [config.userArgs] : [],
// NOTE: we need to prevent new window blocking for multiple windows in Native Automation
isNativeAutomation ? ['--disable-popup-blocking'] : [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export async function start (pageUrl, { browserName, config, cdpPort, tempProfil
const chromeInfo = await browserTools.getBrowserInfo(config.path || browserName);
const chromeOpenParameters = Object.assign({}, chromeInfo);

chromeOpenParameters.cmd = buildChromeArgs({ config, cdpPort, platformArgs: chromeOpenParameters.cmd, tempProfileDir, isContainerized, isNativeAutomation });
chromeOpenParameters.cmd = buildChromeArgs({ config, cdpPort, platformArgs: chromeOpenParameters.cmd, tempProfileDir, isContainerized, isNativeAutomation, browserName });

await browserStarter.startBrowser(chromeOpenParameters, pageUrl);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ const getWindowDimensionsInfo = ClientFunction(() => {
};
});

const isHeadlessChrome = ClientFunction(() => {
return /HeadlessChrome/.test(window.navigator.userAgent);
});

const INITIAL_SIZE = 500;

fixture `Maximize Window`
Expand All @@ -29,9 +33,18 @@ fixture `Maximize Window`

test('Maximize window', async t => {
await t.maximizeWindow();
const isHeadless = await isHeadlessChrome();

const dimensions = await getWindowDimensionsInfo();

expect(dimensions.outerWidth).to.be.at.least(dimensions.availableWidth);
expect(dimensions.outerHeight).to.be.at.least(dimensions.availableHeight);
// HACK: headless outerWidth/Height and availHeight/Width are random and different
// that is why we check with innerWidth/Height
if (isHeadless) {
expect(dimensions.innerWidth).to.be.at.least(dimensions.availableWidth);
expect(dimensions.innerHeight).to.be.at.least(dimensions.availableHeight);
}
else {
expect(dimensions.outerWidth).to.be.at.least(dimensions.availableWidth);
expect(dimensions.outerHeight).to.be.at.least(dimensions.availableHeight);
}
});
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
const routes = {
main: 'http://one-dummy-url.com',
get: 'http://one-dummy-url.com/get',
post: 'http://one-dummy-url.com/post',
another: 'https://another-dummy-url.com',
main: 'http://one-dummy-url.com',
get: 'http://one-dummy-url.com/get',
post: 'http://one-dummy-url.com/post',
another: 'https://another-dummy-url.com',
secureMain: 'https://secure-dummy-url.com',
secureGet: 'https://secure-dummy-url.com/get',
};

export default routes;
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const testPageMarkup = `
<button onclick="sendRequest()">Send request</button>
<script>
function sendRequest() {
fetch('${DUMMY_URLS.get}')
fetch('${DUMMY_URLS.secureGet}')
.then(res => {
return res.text();
})
Expand All @@ -23,9 +23,9 @@ const testPageMarkup = `
`;

const requestMock = RequestMock()
.onRequestTo(DUMMY_URLS.main)
.onRequestTo(DUMMY_URLS.secureMain)
.respond(testPageMarkup)
.onRequestTo(DUMMY_URLS.get)
.onRequestTo(DUMMY_URLS.secureGet)
.respond('Data from mocked fetch request')
.onRequestTo(DUMMY_URLS.another)
.respond();
Expand All @@ -36,7 +36,7 @@ test
.requestHooks(requestMock)
('Basic', async t => {
await t
.navigateTo(DUMMY_URLS.main)
.navigateTo(DUMMY_URLS.secureMain)
.expect(Selector('h1').textContent).eql('Mocked page')
.click('button')
.expect(Selector('h2').textContent).eql('Data from mocked fetch request')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { RequestMock } from 'testcafe';
import DUMMY_URLS from '../../common/mock-routes.js';

const mock = RequestMock()
.onRequestTo(DUMMY_URLS.get)
.onRequestTo(DUMMY_URLS.secureGet)
.respond(() => {
throw new Error('Error in the "respond" method');
});
Expand All @@ -11,5 +11,5 @@ fixture `Fixture`
.requestHooks(mock);

test('test', async t => {
await t.navigateTo(DUMMY_URLS.get);
await t.navigateTo(DUMMY_URLS.secureGet);
});
4 changes: 2 additions & 2 deletions test/functional/fixtures/regression/gh-3456/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ const assertionHelper = require('../../../assertion-helper.js');
const SCREENSHOTS_PATH = path.resolve(assertionHelper.SCREENSHOTS_PATH);

if (config.useLocalBrowsers) {
describe('[Regression](GH-3456) Should process --window-size arg in Headless mode ', function () {
describe.skip('[Regression](GH-3456) Should process --window-size arg in Headless mode ', function () {
it(':headless', () => {
const browsers = [
'chrome:headless --window-size=501,602',
'chrome --headless --window-size=501,602',
'chrome --headless=new --window-size=501,602',
];

return createTestCafe('127.0.0.1', 1335, 1336)
Expand Down

0 comments on commit f87553c

Please sign in to comment.