From f87553c2aa17feeffd32c5c139fbe25ff918307c Mon Sep 17 00:00:00 2001 From: Adil Rakhaliyev <67043367+Bayheck@users.noreply.github.com> Date: Fri, 29 Mar 2024 11:52:15 +0500 Subject: [PATCH] testing test-functional-docker workflow (#8151) ## Purpose closes https://github.com/DevExpress/testcafe-private/issues/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 --- .../dedicated/chrome/build-chrome-args.js | 6 ++++-- .../built-in/dedicated/chrome/local-chrome.js | 2 +- .../testcafe-fixtures/maximize-window-test.js | 17 +++++++++++++++-- .../es-next/request-hooks/common/mock-routes.js | 10 ++++++---- .../testcafe-fixtures/request-mock/basic.js | 8 ++++---- .../request-mock/respond-error.js | 4 ++-- .../fixtures/regression/gh-3456/test.js | 4 ++-- 7 files changed, 34 insertions(+), 17 deletions(-) diff --git a/src/browser/provider/built-in/dedicated/chrome/build-chrome-args.js b/src/browser/provider/built-in/dedicated/chrome/build-chrome-args.js index d3b53b23660..ef232706c19 100644 --- a/src/browser/provider/built-in/dedicated/chrome/build-chrome-args.js +++ b/src/browser/provider/built-in/dedicated/chrome/build-chrome-args.js @@ -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'] : [], diff --git a/src/browser/provider/built-in/dedicated/chrome/local-chrome.js b/src/browser/provider/built-in/dedicated/chrome/local-chrome.js index 15ee404c627..957c597d76e 100644 --- a/src/browser/provider/built-in/dedicated/chrome/local-chrome.js +++ b/src/browser/provider/built-in/dedicated/chrome/local-chrome.js @@ -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); } diff --git a/test/functional/fixtures/api/es-next/maximize-window/testcafe-fixtures/maximize-window-test.js b/test/functional/fixtures/api/es-next/maximize-window/testcafe-fixtures/maximize-window-test.js index ce24b4e467c..d53cca46c8b 100644 --- a/test/functional/fixtures/api/es-next/maximize-window/testcafe-fixtures/maximize-window-test.js +++ b/test/functional/fixtures/api/es-next/maximize-window/testcafe-fixtures/maximize-window-test.js @@ -14,6 +14,10 @@ const getWindowDimensionsInfo = ClientFunction(() => { }; }); +const isHeadlessChrome = ClientFunction(() => { + return /HeadlessChrome/.test(window.navigator.userAgent); +}); + const INITIAL_SIZE = 500; fixture `Maximize Window` @@ -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); + } }); diff --git a/test/functional/fixtures/api/es-next/request-hooks/common/mock-routes.js b/test/functional/fixtures/api/es-next/request-hooks/common/mock-routes.js index b72efd03b74..0e8c86a518a 100644 --- a/test/functional/fixtures/api/es-next/request-hooks/common/mock-routes.js +++ b/test/functional/fixtures/api/es-next/request-hooks/common/mock-routes.js @@ -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; diff --git a/test/functional/fixtures/api/es-next/request-hooks/testcafe-fixtures/request-mock/basic.js b/test/functional/fixtures/api/es-next/request-hooks/testcafe-fixtures/request-mock/basic.js index ecd28359d46..a016cd2aad2 100644 --- a/test/functional/fixtures/api/es-next/request-hooks/testcafe-fixtures/request-mock/basic.js +++ b/test/functional/fixtures/api/es-next/request-hooks/testcafe-fixtures/request-mock/basic.js @@ -9,7 +9,7 @@ const testPageMarkup = `