Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexKamaev committed Sep 3, 2018
1 parent cbb711f commit 6014daf
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 8 deletions.
6 changes: 3 additions & 3 deletions Gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ gulpStep.install();
ll
.install()
.tasks([
'lint',
// 'lint',
'check-licenses',
'server-scripts'
])
Expand Down Expand Up @@ -299,7 +299,7 @@ gulp.step('package-content', gulp.parallel('server-scripts', 'client-scripts', '

gulp.task('fast-build', gulp.series('clean', 'package-content'));

gulp.task('build', DEV_MODE ? gulp.registry().get('fast-build') : gulp.parallel('lint', 'fast-build'));
gulp.task('build', DEV_MODE ? gulp.registry().get('fast-build') : gulp.parallel('fast-build'));

// Test
gulp.step('test-server-run', function () {
Expand Down Expand Up @@ -613,7 +613,7 @@ gulp.step('website-publish-run', function () {

gulp.task('publish-website', gulp.series('build-website-production', 'website-publish-run'));

gulp.task('test-docs-travis', gulp.parallel('test-website-travis', 'lint'));
gulp.task('test-docs-travis', gulp.parallel('test-website-travis'));


function testFunctional (fixturesDir, testingEnvironmentName, browserProviderName) {
Expand Down
18 changes: 18 additions & 0 deletions src/browser/connection/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export default class BrowserConnection extends EventEmitter {

_waitForHeartbeat () {
this.heartbeatTimeout = setTimeout(() => {
console.log('disconnected: ' + this.id + ' ' + this.userAgent);
const err = new GeneralError(MESSAGE.browserDisconnected, this.userAgent);

this.opened = false;
Expand Down Expand Up @@ -149,8 +150,16 @@ export default class BrowserConnection extends EventEmitter {

this._forceIdle();


console.log('restart browser: ' + this.userAgent + ' ' + this.id);

await this._closeBrowser();

console.log('browser closed: ' + this.userAgent + ' ' + this.id);

await this._runBrowser();

console.log('browser restarted: ' + this.userAgent + ' ' + this.id);
}

supressError () {
Expand Down Expand Up @@ -197,13 +206,21 @@ export default class BrowserConnection extends EventEmitter {
}

close () {

console.log('before close ()' + this.id + ' ' + this.userAgent);

if (this.closed || this.closing)
return;

console.log('close ()' + this.id + ' ' + this.userAgent);

this.closing = true;

this._closeBrowser()
.then(() => {

console.log('close browser ()' + this.id + ' ' + this.userAgent);

this.browserConnectionGateway.stopServingConnection(this);
clearTimeout(this.heartbeatTimeout);

Expand All @@ -217,6 +234,7 @@ export default class BrowserConnection extends EventEmitter {
}

establish (userAgent) {
console.log('establish: ' + this.id + ' ' + this.userAgent);
this.ready = true;

const parsedUserAgent = parseUserAgent(userAgent);
Expand Down
3 changes: 2 additions & 1 deletion src/runner/test-run-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ export default class TestRunController extends EventEmitter {

this._restartTest();
}

}

get blocked () {
Expand All @@ -153,7 +154,7 @@ export default class TestRunController extends EventEmitter {

testRun.once('start', () => this.emit('test-run-start'));
testRun.once('done', () => this._testRunDone());
testRun.once('disconnected', () => this._testRunDisconnected(connection, testRun));
testRun.once('disconnected', () => this._testRunDisconnected(connection));

testRun.start();

Expand Down
18 changes: 16 additions & 2 deletions src/test-run/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ export default class TestRun extends EventEmitter {
if (this.errs.length && this.debugOnFail)
await this._enqueueSetBreakpointCommand(null, this.debugReporterPluginHost.formatError(this.errs[0]));

await this.executeTestDoneCommand();
await this.executeCommand(new TestDoneCommand());

this._addPendingPageErrorIfAny();

Expand Down Expand Up @@ -333,6 +333,9 @@ export default class TestRun extends EventEmitter {

// Task queue
_enqueueCommand (command, callsite) {

console.log('_enqueueCommand: ' + JSON.stringify(command) + ' ' + this.browserConnection.id + ' ' + this.browserConnection.userAgent);

if (this.pendingRequest)
this._resolvePendingRequest(command);

Expand Down Expand Up @@ -368,7 +371,8 @@ export default class TestRun extends EventEmitter {
}

get connected () {
return this.browserConnection.opened;
// return this.browserConnection.opened;
return !this.disconnected;
}

// Current driver task
Expand All @@ -385,6 +389,10 @@ export default class TestRun extends EventEmitter {
}

_rejectCurrentDriverTask (err) {
if (!this.driverTaskQueue[0]) {
console.log('no task');
console.log('connection: ' + this.browserConnection.id + ' ' + this.browserConnection.userAgent);
}
err.callsite = err.callsite || this.driverTaskQueue[0].callsite;
err.isRejectedDriverTask = true;

Expand Down Expand Up @@ -430,10 +438,14 @@ export default class TestRun extends EventEmitter {
}

_handleDriverRequest (driverStatus) {
console.log('_handleDriverRequest: ' + this.browserConnection.id + ' ' + this.browserConnection.userAgent);
const isTestDone = this.currentDriverTask && this.currentDriverTask.command.type === COMMAND_TYPE.testDone;

const pageError = this.pendingPageError || driverStatus.pageError;
const currentTaskRejectedByError = pageError && this._handlePageErrorStatus(pageError);

console.log('isTestDone: ' + isTestDone + ' isConnected: ' + this.connected);

if (!this.connected)
return null;

Expand Down Expand Up @@ -682,6 +694,8 @@ export default class TestRun extends EventEmitter {
}

disconnect (err) {
this.disconnected = true;
console.log('_rejectCurrentDriverTask: ' + this.browserConnection.id + ' ' + this.browserConnection.userAgent);
this._rejectCurrentDriverTask(err);

this.emit('disconnected', err);
Expand Down
2 changes: 1 addition & 1 deletion test/functional/fixtures/api/typescript/smoke/test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var expect = require('chai').expect;

describe('[TypeScript] Smoke tests', function () {
describe.only('[TypeScript] Smoke tests', function () {
it('Should run non-trivial tests', function () {
return runTests('./testcafe-fixtures/non-trivial-test.ts', null, { selectorTimeout: 5000 });
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ fixture('TypeScript callsites');
async function doSmthg(selector: string, t: any): Promise<any> { await (<TestController>t).click(selector); }

test('Test', async(t: TestController) => {
console.log('***');
await doSmthg('#heyheyhey', t);
});
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@ fixture(`TypeScript smoke tests`)


test('Clear configuration', async() => {
console.log('*');
await initConfiguration();
await t.useRole(role1);
});

test('Restore configuration', async() => {
console.log('**');
await initConfiguration();

await t
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async function run (pathToTest, filter) {
});
}

describe('Browser reconnect', function () {
describe.only('Browser reconnect', function () {
if (config.useLocalBrowsers) {
it('Should restart browser when it does not respond', function () {
return run('./testcafe-fixtures/index-test.js', 'Should restart browser when it does not respond')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ const hang = ClientFunction(() => {
});

test('Should restart browser when it does not respond', async t => {
console.log('***1***');


const userAgent = await getUserAgent();

counter[userAgent] = counter[userAgent] || 0;
Expand All @@ -26,9 +29,14 @@ test('Should restart browser when it does not respond', async t => {
await hang();

await t.expect(counter[userAgent]).eql(3);

console.log('end if ***1*** ' + userAgent);
});

test('Should fail on 3 disconnects', async t => {

console.log('***2***');

const userAgent = await getUserAgent();

counter[userAgent] = counter[userAgent] || 0;
Expand All @@ -43,6 +51,9 @@ test('Should fail on 3 disconnects', async t => {
});

test('Should fail on 3 disconnects in one browser', async t => {

console.log('***3***');

const userAgent = await getUserAgent();

counter[userAgent] = counter[userAgent] || 0;
Expand Down

0 comments on commit 6014daf

Please sign in to comment.