Skip to content

Commit

Permalink
Merge bc14a95 into 4b6551f
Browse files Browse the repository at this point in the history
  • Loading branch information
LavrovArtem authored Jun 3, 2021
2 parents 4b6551f + bc14a95 commit 190dade
Show file tree
Hide file tree
Showing 33 changed files with 510 additions and 60 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy-to-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ jobs:
tasks.push('test-functional-local-firefox.yml');
tasks.push('test-functional-local-ie.yml');
tasks.push('test-functional-local-multiple-windows.yml');
tasks.push('test-functional-local-proxyless.yml');
tasks.push('test-functional-local-legacy.yml');
Expand Down
102 changes: 102 additions & 0 deletions .github/workflows/test-functional-local-proxyless.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Test Functional (Local Chrome proxyless)

on:
workflow_dispatch:
inputs:
sha:
desciption: 'The test commit SHA or ref'
required: true
default: 'master'
merged_sha:
description: 'The merge commit SHA'
deploy_run_id:
description: 'The ID of a deployment workspace run with artifacts'
jobs:
test:
runs-on: ubuntu-latest
environment: test-functional
env:
RETRY_FAILED_TESTS: true
steps:
- uses: actions/github-script@v3
with:
script: |
await github.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: context.payload.inputs.sha,
context: context.workflow,
state: 'pending',
target_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`
});
- uses: actions/checkout@v2
with:
ref: ${{github.event.inputs.merged_sha || github.event.inputs.sha}}

- uses: actions/setup-node@v2
with:
node-version: 12

- uses: actions/github-script@v3
with:
script: |
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
let artifacts = {};
for(let i = 0;i<36&&!artifacts.total_count;i++,await delay(5000)) {
try {
({ data: artifacts } = await github.actions.listWorkflowRunArtifacts({
repo: context.repo.repo,
owner: context.repo.owner,
run_id: context.payload.inputs.deploy_run_id
}));
}
catch (e) {
console.log(e);
}
}
const { data: artifact } = await github.request(artifacts.artifacts.find(artifact=> artifact.name === 'npm').archive_download_url);
require('fs').writeFileSync(require('path').join(process.env.GITHUB_WORKSPACE, 'package.zip'), Buffer.from(artifact))
- run: |
unzip package.zip
tar --strip-components=1 -xzf testcafe-*.tgz
- name: Get npm cache directory
id: npm-cache-dir
run: |
echo "::set-output name=dir::$(npm config get cache)"
- uses: actions/cache@v2
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm ci
- run: npx gulp test-functional-local-proxyless-run --steps-as-tasks
timeout-minutes: 60
- uses: actions/github-script@v3
with:
script: |
await github.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: context.payload.inputs.sha,
context: context.workflow,
state: 'success',
target_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`
});
- uses: actions/github-script@v3
if: failure() || cancelled()
with:
script: |
await github.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: context.payload.inputs.sha,
context: context.workflow,
state: 'failure',
target_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`
});
4 changes: 2 additions & 2 deletions @types/chrome-remote-interface/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ declare module 'chrome-remote-interface' {

interface ChromeRemoteInterface {
(options: chromeRemoteInterface.ConstructorOptions): Promise<chromeRemoteInterface.ProtocolApi>;
listTabs (options: chromeRemoteInterface.GenericConnectionOptions): Promise<chromeRemoteInterface.TargetInfo[]>;
closeTab (options: chromeRemoteInterface.CloseTabOptions): Promise<void>;
List (options: chromeRemoteInterface.GenericConnectionOptions): Promise<chromeRemoteInterface.TargetInfo[]>;
Close (options: chromeRemoteInterface.CloseTabOptions): Promise<void>;
}

const chromeRemoteInterface: ChromeRemoteInterface;
Expand Down
2 changes: 1 addition & 1 deletion @types/replicator/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ declare module 'replicator' {
}

interface ReplicatorConstructor {
new (): Replicator;
new (serializer?: { serialize: (val: unknown) => unknown, deserialize: (val: unknown) => unknown }): Replicator;
}

const Replicator: ReplicatorConstructor;
Expand Down
6 changes: 6 additions & 0 deletions Gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,12 @@ gulp.step('test-functional-local-compiler-service-run', () => {

gulp.task('test-functional-local-compiler-service', gulp.series('prepare-tests', 'test-functional-local-compiler-service-run'));

gulp.step('test-functional-local-proxyless-run', () => {
return testFunctional(TESTS_GLOB, functionalTestConfig.testingEnvironmentNames.localHeadlessChrome, { isProxyless: true });
});

gulp.task('test-functional-local-proxyless', gulp.series('prepare-tests', 'test-functional-local-proxyless-run'));

gulp.task('docker-build', done => {
childProcess.execSync('npm pack', { env: process.env }).toString();

Expand Down
5 changes: 4 additions & 1 deletion gulp/helpers/test-functional.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@ const SCREENSHOT_TESTS_GLOB = [
'test/functional/fixtures/screenshots-on-fails/test.js'
];

module.exports = function testFunctional (src, testingEnvironmentName, { experimentalCompilerService } = {}) {
module.exports = function testFunctional (src, testingEnvironmentName, { experimentalCompilerService, isProxyless } = {}) {
process.env.TESTING_ENVIRONMENT = testingEnvironmentName;
process.env.BROWSERSTACK_USE_AUTOMATE = 1;

if (experimentalCompilerService)
process.env.EXPERIMENTAL_COMPILER_SERVICE = 'true';

if (isProxyless)
process.env.PROXYLESS = 'true';

if (!process.env.BROWSERSTACK_NO_LOCAL)
process.env.BROWSERSTACK_NO_LOCAL = 1;

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"callsite-record": "^4.0.0",
"chai": "^4.1.2",
"chalk": "^2.3.0",
"chrome-remote-interface": "^0.25.3",
"chrome-remote-interface": "^0.30.0",
"coffeescript": "^2.3.1",
"commander": "^2.8.1",
"debug": "^4.3.1",
Expand Down
7 changes: 5 additions & 2 deletions src/browser/connection/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export default class BrowserConnection extends EventEmitter {
public permanent: boolean;
public previousActiveWindowId: string | null;
private readonly disableMultipleWindows: boolean;
private readonly isProxyless: boolean;
private readonly HEARTBEAT_TIMEOUT: number;
private readonly BROWSER_CLOSE_TIMEOUT: number;
private readonly BROWSER_RESTART_TIMEOUT: number;
Expand Down Expand Up @@ -107,7 +108,8 @@ export default class BrowserConnection extends EventEmitter {
gateway: BrowserConnectionGateway,
browserInfo: BrowserInfo,
permanent: boolean,
disableMultipleWindows = false) {
disableMultipleWindows = false,
isProxyless = false) {
super();

this.HEARTBEAT_TIMEOUT = HEARTBEAT_TIMEOUT;
Expand All @@ -134,6 +136,7 @@ export default class BrowserConnection extends EventEmitter {
this.heartbeatTimeout = null;
this.pendingTestRunUrl = null;
this.disableMultipleWindows = disableMultipleWindows;
this.isProxyless = isProxyless;

this.url = `${gateway.domain}/browser/connect/${this.id}`;
this.idleUrl = `${gateway.domain}/browser/idle/${this.id}`;
Expand Down Expand Up @@ -183,7 +186,7 @@ export default class BrowserConnection extends EventEmitter {

private async _runBrowser (): Promise<void> {
try {
await this.provider.openBrowser(this.id, this.url, this.browserInfo.browserName, this.disableMultipleWindows);
await this.provider.openBrowser(this.id, this.url, this.browserInfo.browserName, this.disableMultipleWindows, this.isProxyless);

if (this.status !== BrowserConnectionStatus.ready)
await promisifyEvent(this, 'ready');
Expand Down
21 changes: 21 additions & 0 deletions src/browser/provider/built-in/dedicated/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,26 @@ export default {
const maximumSize = getMaximizedHeadlessWindowSize();

await this.resizeWindow(browserId, maximumSize.width, maximumSize.height, maximumSize.width, maximumSize.height);
},

async executeClientFunction (browserId, command, callsite) {
const runtimeInfo = this.openedBrowsers[browserId];
const browserClient = this._getBrowserProtocolClient(runtimeInfo);

return browserClient.executeClientFunction(command, callsite);
},

async switchToIframe (browserId) {
const runtimeInfo = this.openedBrowsers[browserId];
const browserClient = this._getBrowserProtocolClient(runtimeInfo);

return browserClient.switchToIframe();
},

async switchToMainWindow (browserId) {
const runtimeInfo = this.openedBrowsers[browserId];
const browserClient = this._getBrowserProtocolClient(runtimeInfo);

return browserClient.switchToMainWindow();
}
};
Loading

0 comments on commit 190dade

Please sign in to comment.