From 907ab2bd25db41d5ce31c73000fb4a547d8f47cd Mon Sep 17 00:00:00 2001 From: arun ganeshan Date: Fri, 5 Apr 2019 14:49:22 -0400 Subject: [PATCH] fix: automation test --- .../plugin-meetings/src/common/collection.js | 2 + .../src/meeting-info/collection.js | 19 ---- .../plugin-meetings/src/meeting-info/index.js | 2 +- .../plugin-meetings/src/meeting/state.js | 2 + .../plugin-meetings/src/meeting/util.js | 12 +-- .../src/meetings/collection.js | 34 +------ .../test/unit/spec/integration/index.js | 5 +- .../unit/spec/integration/space-meeting.js | 90 ++++++++----------- 8 files changed, 47 insertions(+), 119 deletions(-) diff --git a/packages/node_modules/@webex/plugin-meetings/src/common/collection.js b/packages/node_modules/@webex/plugin-meetings/src/common/collection.js index 34d0b398257..1ddd8893a3a 100644 --- a/packages/node_modules/@webex/plugin-meetings/src/common/collection.js +++ b/packages/node_modules/@webex/plugin-meetings/src/common/collection.js @@ -53,6 +53,7 @@ export default class Collection { */ set(id, value) { this[this.propertyName][id] = value; + return this.get(id); } @@ -84,6 +85,7 @@ export default class Collection { */ setAll(set) { this[this.propertyName] = set; + return this.getAll(); } } diff --git a/packages/node_modules/@webex/plugin-meetings/src/meeting-info/collection.js b/packages/node_modules/@webex/plugin-meetings/src/meeting-info/collection.js index 061660179bf..4f64224ddaa 100644 --- a/packages/node_modules/@webex/plugin-meetings/src/meeting-info/collection.js +++ b/packages/node_modules/@webex/plugin-meetings/src/meeting-info/collection.js @@ -34,23 +34,4 @@ export default class MeetingInfoCollection extends Collection { (info) => info.sipUrl === id || info.locusId === id || info.userId === id || info.meetingLink === id ); } - - /** - * - * @param {String} id the id of the meeting info instance to add to the collection - * @param {Object} info the full meeting info object - * @returns {MeetingInfo} returns the meeting info instance that was added to the collection - */ - set(id, info) { - this.meetingInfos[id] = info; - - return this.meetingInfos[id]; - } - - /** - * @returns {Object} returns an object map of MeetingInfo instances - */ - getAll() { - return this.meetingInfos; - } } diff --git a/packages/node_modules/@webex/plugin-meetings/src/meeting-info/index.js b/packages/node_modules/@webex/plugin-meetings/src/meeting-info/index.js index 011a693dbe6..676e29f7c1c 100644 --- a/packages/node_modules/@webex/plugin-meetings/src/meeting-info/index.js +++ b/packages/node_modules/@webex/plugin-meetings/src/meeting-info/index.js @@ -61,7 +61,7 @@ export default class MeetingInfo extends StatelessSparkPlugin { requestFetchInfo(options) { return this.meetingInfoRequest.fetchMeetingInfo(options).then((info) => { if (info && info.body) { - this.setMeetingInfo(info.body.sipMeetingUri, info.body); + this.setMeetingInfo(info.body.sipMeetingUri || info.body.meetingLink, info.body); } return info; diff --git a/packages/node_modules/@webex/plugin-meetings/src/meeting/state.js b/packages/node_modules/@webex/plugin-meetings/src/meeting/state.js index df535f0203c..cf737002d22 100644 --- a/packages/node_modules/@webex/plugin-meetings/src/meeting/state.js +++ b/packages/node_modules/@webex/plugin-meetings/src/meeting/state.js @@ -13,6 +13,7 @@ const MeetingStateMachine = { if (!meetingRef) { throw new Error('You must initialize the meeting state machine with a meeting reference.'); } + return new StateMachine({ init: MEETING_STATE_MACHINE.STATES.IDLE, transitions: [ @@ -42,6 +43,7 @@ const MeetingStateMachine = { if (remote.remoteDeclined) { return MEETING_STATE_MACHINE.STATES.DECLINED; } + // default return MEETING_STATE_MACHINE.STATES.ERROR; } diff --git a/packages/node_modules/@webex/plugin-meetings/src/meeting/util.js b/packages/node_modules/@webex/plugin-meetings/src/meeting/util.js index 75c1d2a383d..fc877ebf29c 100644 --- a/packages/node_modules/@webex/plugin-meetings/src/meeting/util.js +++ b/packages/node_modules/@webex/plugin-meetings/src/meeting/util.js @@ -1,8 +1,7 @@ import {isEmpty} from 'lodash'; import Media from '../media'; -import Events from '../common/events'; -import {INTENT_TO_JOIN, MODERATOR_TRUE, MODERATOR_FALSE, EVENTS} from '../constants'; +import {INTENT_TO_JOIN, MODERATOR_TRUE, MODERATOR_FALSE} from '../constants'; import IntentToJoinError from '../common/errors/intent-to-join'; import JoinMeetingError from '../common/errors/join-meeting'; @@ -162,15 +161,6 @@ MeetingUtil.declineMeeting = (meeting, reason) => meeting.meetingRequest locusUrl: meeting.locusUrl, deviceUrl: meeting.deviceUrl, reason - }) - .then((response) => { - Events.emit(EVENTS.DESTROY_MEETING, { - meeting, - response, - type: EVENTS.DESTROY_MEETING - }); - - return Promise.resolve(); }); MeetingUtil.joinMeetingOptions = (meeting, options) => { diff --git a/packages/node_modules/@webex/plugin-meetings/src/meetings/collection.js b/packages/node_modules/@webex/plugin-meetings/src/meetings/collection.js index a72ba9c6ef9..a948af5d746 100644 --- a/packages/node_modules/@webex/plugin-meetings/src/meetings/collection.js +++ b/packages/node_modules/@webex/plugin-meetings/src/meetings/collection.js @@ -1,4 +1,4 @@ -import {pickBy, find} from 'lodash'; +import {find} from 'lodash'; import Collection from '../common/collection'; /** @@ -21,38 +21,6 @@ export default class MeetingCollection extends Collection { return this.meetings[meeting.id]; } - /** - * remove the meeting at the id - * @param {String} meetingId ID of the meeting you wish to remove from the collection - * @returns {Meeting} returns the meeting that was removed - * @public - * @memberOf - */ - remove(meetingId) { - const deleted = this.meetings[meetingId]; - - this.meetings[meetingId] = null; - delete this.meetings[meetingId]; - - return deleted; - } - - /** - * get all the meetings with optional filters - * @param {Object} options An object containg properties to filter by - * @param {Boolean} options.active Only return active meetings - * @returns {Meeting} returns an object map of Meeting instances - * @public - * @memberof MeetingCollection - */ - getAll(options = {active: false}) { - if (options.active) { - return pickBy(this.meetings, (value) => value.active); - } - - return this.meetings; - } - /** * get a specific meeting searching for key diff --git a/packages/node_modules/@webex/plugin-meetings/test/unit/spec/integration/index.js b/packages/node_modules/@webex/plugin-meetings/test/unit/spec/integration/index.js index 04354456d04..0bc6e9141ef 100644 --- a/packages/node_modules/@webex/plugin-meetings/test/unit/spec/integration/index.js +++ b/packages/node_modules/@webex/plugin-meetings/test/unit/spec/integration/index.js @@ -62,9 +62,8 @@ describe('plugin-meeting', () => { assert.exists(alice.meeting.partner); }) .then(function bobDeclinedCall() { - bob.meeting.acknowledge('INCOMING'); - - return bob.meeting.decline('BUSY') + return bob.meeting.acknowledge('INCOMING') + .then(() => bob.meeting.decline('BUSY')) .then(() => testUtils.waitForStateChange(bob.meeting, 'DECLINED')) .catch((e) => { console.error('Bob decline call not successful', e); throw e; }); }) diff --git a/packages/node_modules/@webex/plugin-meetings/test/unit/spec/integration/space-meeting.js b/packages/node_modules/@webex/plugin-meetings/test/unit/spec/integration/space-meeting.js index 2db22d74cf8..177ad7c6f25 100644 --- a/packages/node_modules/@webex/plugin-meetings/test/unit/spec/integration/space-meeting.js +++ b/packages/node_modules/@webex/plugin-meetings/test/unit/spec/integration/space-meeting.js @@ -1,6 +1,5 @@ import {assert} from '@ciscospark/test-helper-chai'; -import sinon from 'sinon'; import CMR from './cmr'; import testUtils from './testUtils'; @@ -11,58 +10,44 @@ const sparkTestUsers = require('./sparkTestUsers.js'); let userSet, alice, bob, chris; -xdescribe('plugin-meeting-space-meeting', () => { - before(() => sparkTestUsers.generateTestUsers({count: 3}) - .then((users) => { - userSet = users; - alice = userSet[0]; - bob = userSet[1]; - chris = userSet[2]; - alice.name = 'alice'; - bob.name = 'bob'; - }) - .then(() => Promise.all([testUtils.syncAndEndMeeting(alice), - testUtils.syncAndEndMeeting(bob)])) - .catch((error) => { - console.log(error); - })); - - after(() => { - const promise = []; - - userSet.forEach((user) => { - promise.push(user.spark.internal.mercury.disconnect()); +describe('plugin-meetings-automation', () => { + describe('plugin-meeting-space-meeting', () => { + before(() => sparkTestUsers.generateTestUsers({count: 3}) + .then((users) => { + userSet = users; + alice = userSet[0]; + bob = userSet[1]; + chris = userSet[2]; + alice.name = 'alice'; + bob.name = 'bob'; + }) + .then(() => Promise.all([testUtils.syncAndEndMeeting(alice), + testUtils.syncAndEndMeeting(bob)])) + .catch((error) => { + console.log(error); + })); + + after(() => { + const promise = []; + + userSet.forEach((user) => { + promise.push(user.spark.internal.mercury.disconnect()); + }); + + return Promise.all(promise) + .then(() => sparkTestUsers.remove(userSet)); + // TODO: end is not a function on browser object }); - }); - describe('Space meeting', () => { - let space = null; - const aliceMeetingAdded = sinon.spy(); - const bobMeetingAdded = sinon.spy(); - const chrisMeetingAdded = sinon.spy(); - - it('Alice creates a space', () => alice.spark.internal.conversation.create({participants: [bob, chris]}) - .then((conversation) => { - assert.lengthOf(conversation.participants.items, 3); - assert.lengthOf(conversation.activities.items, 1); - console.log('CONVERSATION', conversation); - space = conversation; - })); - it('alice starts a space meeting', () => { - chris.spark.meetings.on('meeting:added', chrisMeetingAdded); - bob.spark.meetings.on('meeting:added', bobMeetingAdded); - alice.spark.meetings.on('meeting:added', aliceMeetingAdded); - - return alice.spark.meetings.create(space.id) - .then((m) => m.join() - .then(() => testUtils.waitForSpy(aliceMeetingAdded, 'meeting:added')) - .then((m) => { - console.log('ALICE meeting ', m); - alice.meeting = m.meeting; - })) - .then(() => testUtils.waitForSpy(bobMeetingAdded, 'meeting:added')) - .then((m) => { - bob.meeting = m.meeting; + describe('Space meeting', () => { + let space = null; + + it('Alice starts a space meeting', () => alice.spark.internal.conversation.create({participants: [bob, chris]}) + .then((conversation) => { + assert.lengthOf(conversation.participants.items, 3); + assert.lengthOf(conversation.activities.items, 1); + console.log('CONVERSATION', conversation); + space = conversation; }) .then(function aliceStartsMeeting() { return Promise.all([ @@ -82,7 +67,7 @@ xdescribe('plugin-meeting-space-meeting', () => { .then(() => bob.meeting.join()) .then(() => chris.meeting.join()) .then(() => testUtils.waitForStateChange(bob.meeting, 'JOINED')) - .then(() => testUtils.waitForStateChange(chris.meeting, 'JOINED')); + .then(() => testUtils.waitForStateChange(chris.meeting, 'JOINED'))); // it('check the members event', () => { @@ -96,6 +81,7 @@ xdescribe('plugin-meeting-space-meeting', () => { }); }); + describe('Unclaimed PMR', () => { before(() => sparkTestUsers.generateTestUsers({count: 3}) .then((users) => {