Skip to content

Commit

Permalink
Server now returns a loginSuccess, and tester is now syncronized on l…
Browse files Browse the repository at this point in the history
…ogin as well
  • Loading branch information
rotemmiz committed Jul 9, 2017
1 parent febf554 commit 1733894
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
3 changes: 3 additions & 0 deletions detox-server/src/DetoxServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ class DetoxServer {
role = action.params.role;
log.log('wss', `${now()}:`, `role=${role} login (sessionId=${sessionId})`);
_.set(this.sessions, [sessionId, role], ws);
action.type = 'loginSuccess';
this.sendAction(ws, action);
log.log('wss', `${now()}:`, `role=${role} action=${action.type} (sessionId=${sessionId})`);
}
} else if (sessionId && role) {
log.log('wss', `${now()}:`, `role=${role} action=${action.type} (sessionId=${sessionId})`);
Expand Down
13 changes: 4 additions & 9 deletions detox/src/Detox.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,8 @@ class Detox {
}

const deviceConfig = await this._getDeviceConfig();
if (!deviceConfig.binaryPath) {
configuration.throwOnEmptyBinaryPath();
}

if (!deviceConfig.name) {
configuration.throwOnEmptyName();
if (!deviceConfig.type) {
configuration.throwOnEmptyType();
}

const [sessionConfig, shouldStartServer] = await this._chooseSession(deviceConfig);
Expand All @@ -53,19 +49,18 @@ class Detox {
}

this.client = new Client(sessionConfig);
this.client.connect();
await this.client.connect();

const deviceClass = DEVICE_CLASSES[deviceConfig.type];
if (!deviceClass) {
throw new Error('only simulator is supported currently');
throw new Error(`'${deviceConfig.type}' is not supported`);
}
await this._setDevice(sessionConfig, deviceClass, deviceConfig, this.client);
}

async _setDevice(sessionConfig, deviceClass, deviceConfig, client) {
const deviceDriver = new deviceClass(client);
this.device = new Device(deviceConfig, sessionConfig, deviceDriver);

await this.device.prepare();
global.device = this.device;
}
Expand Down
2 changes: 1 addition & 1 deletion detox/src/client/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Client {

async connect() {
await this.ws.open();
this.sendAction(new actions.Login(this.configuration.sessionId));
await this.sendAction(new actions.Login(this.configuration.sessionId));
}

async reloadReactNative() {
Expand Down

0 comments on commit 1733894

Please sign in to comment.