Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const serviceInfoBody = require('./data/serviceInfo');
const conferenceCallBody = require('./data/conferenceCall');
const numberParseBody = require('./data/numberParse');
const conferenceCallBringInBody = require('./data/conferenceCallBringIn');

const updateConferenceCallBody = require('./data/updateConference');
const mockServer = 'http://whatever';
export function createSDK(options = {}) {
const opts = {
Expand Down Expand Up @@ -475,7 +475,7 @@ export function updateConferenceCall(id, mockResponse = {}) {
mockApi({
path: `/restapi/v1.0/account/~/telephony/sessions/${id}`,
body: {
// ...conferenceCallBody,
//...conferenceCallBody,
...mockResponse,
},
isOnce: false
Expand Down Expand Up @@ -583,6 +583,7 @@ export function mockForLogin({
mockMessageSync = true,
mockConferencing = true,
mockActiveCalls = true,
mockUpdateConference = false,
...params,
} = {}) {
authentication();
Expand Down Expand Up @@ -620,4 +621,7 @@ export function mockForLogin({
activeCalls(params.activeCallsData);
}
numberParser(params.numberParseData);
if (mockUpdateConference) {
updateConferenceCall(updateConferenceCallBody.id, updateConferenceCallBody);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,25 @@ import CallAvatar from 'ringcentral-widgets/components/CallAvatar';
import DurationCounter from 'ringcentral-widgets/components/DurationCounter';
import calleeTypes from 'ringcentral-integration/enums/calleeTypes';
import sessionStatus from 'ringcentral-integration/modules/Webphone/sessionStatus';
import ActiveCallPad from 'ringcentral-widgets/components/ActiveCallPad/';
import ActiveCallButton from 'ringcentral-widgets/components/ActiveCallButton';
import CombinIcon from 'ringcentral-widgets/assets/images/Combine.svg';
import Answer from 'ringcentral-widgets/assets/images/Answer.svg';
import CircleButton from 'ringcentral-widgets/components/CircleButton';
import FromField from 'ringcentral-widgets/components/FromField';
import BackHeader from 'ringcentral-widgets/components/BackHeader';
import BackButton from 'ringcentral-widgets/components/BackButton';
import RecipientsInput from 'ringcentral-widgets/components/RecipientsInput';
import ContactDropdownList from 'ringcentral-widgets/components/ContactDropdownList';
import ContactItem from 'ringcentral-widgets/components/ContactItem';
import LinkLine from 'ringcentral-widgets/components/LinkLine';
import DropdownSelect from 'ringcentral-widgets/components/DropdownSelect';
import deviceBody from './data/device';
import activeCallsBody from './data/activeCalls';
import extensionListBody from './data/extension';
import conferenceCallBody from './data/conferenceCall';
import conferenceCallBringInBody from './data/conferenceCallBringIn';
import conferenceUpdate from './data/conferenceUpdate';
import incomingResponse from './data/incomingResponse';
import { getWrapper, timeout } from '../shared';
import {
mockGeneratePresenceApi,
Expand All @@ -24,7 +37,6 @@ let wrapper = null;
let phone = null;

beforeEach(async () => {
mock.reset();
jasmine.DEFAULT_TIMEOUT_INTERVAL = 64000;
wrapper = await getWrapper();
phone = wrapper.props().phone;
Expand All @@ -46,6 +58,9 @@ async function call({
await phone.dialerUI.call({ phoneNumber, fromNumber });
await timeout(500);
wrapper.update();
const currentSessionId = phone.webphone.activeSession.id;
const currentSession = await phone.webphone._sessions.get(currentSessionId);
currentSession.accept(incomingResponse);
}

async function mockSub(ttl = 100) {
Expand Down Expand Up @@ -87,7 +102,39 @@ async function mockContacts() {
mock.extensionList(extensionListBody);
await phone.accountExtension.fetchData();
}

async function mockStartConference() {
// HACK: `updateConference` should be mock at mockForLogin func.
// mock.updateConferenceCall(conferenceUpdate.id, conferenceUpdate);
mock.conferenceCallBringIn(conferenceCallBody.id);
mock.terminateConferenceCall(conferenceCallBody.id);
mock.conferenceCall();
let contactA;
let contactB;
await mockContacts();
contactA = phone.contacts.allContacts.find(item => item.type === 'company');
contactB = phone.contacts.allContacts.find(item => item.type === 'company');
await mockAddCall(contactA, contactB);
expect(phone.routerInteraction.currentPath).toEqual('/conferenceCall/mergeCtrl');
wrapper.update();
const callCtrlPage = wrapper.find(CallCtrlPage);
const sessionId = phone.webphone.activeSession.id;
callCtrlPage.props().onMerge(sessionId);
const fromSessionId = phone.conferenceCall.state.mergingPair.fromSessionId;
const fromSession = phone.webphone._sessions.get(fromSessionId);
const toSessionId = phone.conferenceCall.state.mergingPair.toSessionId;
const toSession = phone.webphone._sessions.get(toSessionId);
toSession.terminate();
fromSession.terminate();
await timeout(1000);
toSession.reject();
fromSession.reject();
await timeout(1000);
const conferenceSessionId = Object.values(phone.conferenceCall.conferences)[0].sessionId;
const conferenceSession = phone.webphone._sessions.get(conferenceSessionId);
conferenceSession.accept();
await timeout(2000);
wrapper.update();
}
describe('RCI-1071: simplified call control page #3', () => {
let contactA = null;
let contactB = null;
Expand Down Expand Up @@ -141,57 +188,104 @@ describe('RCI-1071: simplified call control page #3', () => {
expect(mergeInfo.find('.callee_name_active').text()).toEqual('Unknown');
expect(mergeInfo.find(DurationCounter)).toHaveLength(1);
});
// test('#3 && #4 user makes a conference call then make an outbound call, then hangup', async () => {
// // expect.assertions(1);
// await mockContacts();
// contactA = phone.contacts.allContacts.find(item => item.type === 'company');
// contactB = phone.contacts.allContacts.find(item => item.type === 'company');
// await mockAddCall(contactA, contactB);
// await mock.updateConferenceCall(conferenceCallBody.id, conferenceUpdate);
// await mock.conferenceCallBringIn(conferenceCallBody.id);
// await mock.terminateConferenceCall(conferenceCallBody.id);
// expect(phone.routerInteraction.currentPath).toEqual('/conferenceCall/mergeCtrl');
// await mock.conferenceCall();
// const callCtrlPage = wrapper.find(CallCtrlPage);
// const sessionId = phone.webphone.activeSession.id;
// callCtrlPage.props().onMerge(sessionId);
// const fromSessionId = phone.conferenceCall.state.mergingPair.fromSessionId;
// const fromSession = phone.webphone._sessions.get(fromSessionId);
// const toSessionId = phone.conferenceCall.state.mergingPair.toSessionId;
// const toSession = phone.webphone._sessions.get(toSessionId);
// toSession.terminate();
// fromSession.terminate();
// await timeout(1000);
// toSession.reject();
// fromSession.reject();
// await timeout(1000);
// const conferenceSessionId = Object.values(phone.conferenceCall.conferences)[0].sessionId;
// const conferenceSession = phone.webphone._sessions.get(conferenceSessionId);
// conferenceSession.accept();
// await timeout(2000);
// const conferenceId = Object.values(phone.conferenceCall.conferences)[0].conference.id;
// expect(phone.routerInteraction.currentPath).toEqual(`/calls/active/${conferenceSessionId}`);
// callCtrlPage.props().onAdd(conferenceSessionId);
// await timeout(500);
// expect(phone.routerInteraction.currentPath).toEqual(`/conferenceCall/dialer/${conferenceSession.fromNumber}`);
// call({
// phoneNumber: contactA.phoneNumbers[0].phoneNumber,
// });
// await timeout(1000);
// await mockSub(1000);
// await timeout(5000);
// expect(phone.routerInteraction.currentPath).toEqual('/conferenceCall/mergeCtrl');
// wrapper.update();
// const mergeInfo = wrapper.find(MergeInfo);
// expect(mergeInfo).toHaveLength(1);
// expect(mergeInfo.find('.callee_name').text()).toEqual('Conference Call');
// expect(mergeInfo.find('.callee_status').text()).toEqual('On Hold');
// await phone.webphone.hangup(conferenceSessionId);
// phone.webphone._updateSessions();
// await timeout(3000);
// wrapper.update();
// expect(mergeInfo.find('.callee_status').text()).toEqual('Disconnected');
// await timeout(2000);
// expect(phone.routerInteraction.currentPath).toEqual('/calls/active');
// });
test('#3 && #4 user makes a conference call then make an outbound call, then hangup', async () => {
await mockStartConference();
const conferenceSessionId = Object.values(phone.conferenceCall.conferences)[0].sessionId;
const conferenceSession = phone.webphone._sessions.get(conferenceSessionId);
const conferenceId = Object.values(phone.conferenceCall.conferences)[0].conference.id;
expect(phone.routerInteraction.currentPath).toEqual('/calls/active');
const callCtrlPage = wrapper.find(CallCtrlPage);
callCtrlPage.props().onAdd(conferenceSessionId);
await timeout(500);
wrapper.update();
expect(phone.routerInteraction.currentPath).toEqual(`/conferenceCall/dialer/${conferenceSession.fromNumber}`);
call({
phoneNumber: contactA.phoneNumbers[0].phoneNumber,
});
await timeout(1000);
await mockSub(1000);
await timeout(1000);
expect(phone.routerInteraction.currentPath).toEqual('/conferenceCall/mergeCtrl');
wrapper.update();
const mergeInfo = wrapper.find(MergeInfo);
expect(mergeInfo).toHaveLength(1);
expect(mergeInfo.find('.callee_name').text()).toEqual('Conference Call');
expect(mergeInfo.find('.callee_status').text()).toEqual('On Hold');
await phone.webphone.hangup(conferenceSessionId);
phone.webphone._updateSessions();
expect(mergeInfo.find('.callee_status').text()).toEqual('Disconnected');
});
});
describe('RCI-1710156: Call control add call flow', () => {
let contactA = null;
let contactB = null;
test('#5 User make an outbound call', async () => {
await mockContacts();
contactA = phone.contacts.allContacts.find(item => item.type === 'company' && item.hasProfileImage);
contactB = phone.contacts.allContacts.find(item => item.type === 'personal' && !item.hasProfileImage);
await mockAddCall(contactA, contactB);
expect(phone.routerInteraction.currentPath).toEqual('/conferenceCall/mergeCtrl');
const activeCallButtons = wrapper.find(ActiveCallPad).find(ActiveCallButton);
expect(activeCallButtons.at(0).props().title).toEqual('Mute');
expect(activeCallButtons.at(1).props().title).toEqual('Keypad');
expect(activeCallButtons.at(2).props().title).toEqual('Hold');
expect(activeCallButtons.at(3).props().title).toEqual('Merge');
const hangupBtn = wrapper.find('.stopButtonGroup').find(CircleButton);
expect(hangupBtn.props().className).toEqual('stopButton');
});
});
describe('RCI-1710156: Call control add call flow #6&#7', () => {
test('#6 && #7 User clicked Merge button then go to Settings ->Calling page', async () => {
await mockStartConference();
phone.routerInteraction.push('/settings/calling');
wrapper.update();
const calling = wrapper.find(DropdownSelect);
expect(calling.props().disabled).toBe(true);
});
});

describe('RCI-1710156: Call control add call flow', () => {
let contactA;
let contactB;
test('#1 User make an outbound call', async () => {
await mockContacts();
contactA = phone.contacts.allContacts.find(item => item.type === 'company' && item.hasProfileImage);
contactB = phone.contacts.allContacts.find(item => item.type === 'personal' && !item.hasProfileImage);
const phoneNumber = contactA.phoneNumbers[0].phoneNumber;
call({
phoneNumber,
});
await timeout(100);
await mockSub();
wrapper.update();
expect(phone.routerInteraction.currentPath).toEqual('/calls/active');
const activeCallPad = wrapper.find(ActiveCallPad);
expect(activeCallPad).toBeDefined();
const buttons = activeCallPad.find(ActiveCallButton);
const addButton = buttons.at(3);
const addCircleButton = addButton.find(CircleButton);
expect(addButton.find(CircleButton)).toHaveLength(1);
expect(addButton.find('.buttonTitle').text()).toEqual('Add');
// #2 user selected add button
await timeout(400);
addCircleButton.simulate('click');
wrapper.update();
const fromNumber = phone.webphone.activeSession.fromNumber;
expect(phone.routerInteraction.currentPath).toEqual(`/conferenceCall/dialer/${fromNumber}`);
expect(wrapper.find(FromField)).toHaveLength(0);
expect(wrapper.find(BackHeader)).toHaveLength(1);
expect(wrapper.find(BackButton).find('.backLabel').text()).toEqual('Active Call');
// #3 User input SfB/<$brand> contact name in To field
const toInput = wrapper.find(RecipientsInput).find("input[name='receiver']");
expect(toInput).toHaveLength(1);
toInput.props().onFocus();
await phone.contactSearch.search({ searchString: 'Something1 New1' });
toInput.props().onChange({ currentTarget: { value: 'Something1 New1' } });
await timeout(100);
wrapper.update();
const dropdownList = wrapper.find(ContactDropdownList);
expect(dropdownList.props().visibility).toBe(true);
expect(dropdownList.props().items[0].name).toEqual('Something1 New1');
// #4 TODO
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,53 @@
"uri" : "https://platform.ringcentral.com/restapi/v1.0/account/208594004/extension/208594004/profile-image",
"etag": "blob:http://localhost:8080/363d6075-6433-4a86-b1c4-e95030edc103"
}
}],
}, {
"uri" : "https://api-xmnup.lab.nordigy.ru/restapi/v1.0/account/160770006/extension/160772006",
"id" : 160772006,
"extensionNumber" : "102",
"contact" : {
"firstName" : "FirstName 102",
"lastName" : "LastName",
"email" : "mm1+1528852490321-2542433@dins.ru",
"emailAsLoginName" : true,
"pronouncedName" : {
"type" : "Default",
"text" : "FirstName 102 LastName"
}
},
"name" : "FirstName 102 LastName",
"type" : "User",
"status" : "Enabled",
"permissions" : {
"admin" : {
"enabled" : false
},
"internationalCalling" : {
"enabled" : true
}
},
"profileImage" : {
"uri" : "https://media-xmnup.lab.nordigy.ru/restapi/v1.0/account/160770006/extension/160772006/profile-image",
"etag" : "5fc8ebda856d6574b79b38618ed91724",
"contentType" : "image/png",
"lastModified" : "2018-06-13T01:14:58.760Z",
"scales" : [ {
"uri" : "https://media-xmnup.lab.nordigy.ru/restapi/v1.0/account/160770006/extension/160772006/profile-image/90x90"
}, {
"uri" : "https://media-xmnup.lab.nordigy.ru/restapi/v1.0/account/160770006/extension/160772006/profile-image/195x195"
}, {
"uri" : "https://media-xmnup.lab.nordigy.ru/restapi/v1.0/account/160770006/extension/160772006/profile-image/584x584"
} ]
},
"hidden" : false
} ],
"paging" : {
"page" : 1,
"totalPages" : 1,
"perPage" : 1000,
"totalElements" : 1,
"totalElements" : 2,
"pageStart" : 0,
"pageEnd" : 0
"pageEnd" : 1
},
"navigation" : {
"firstPage" : {
Expand All @@ -48,4 +87,4 @@
"uri" : "https://platform.ringcentral.com/restapi/v1.0/account/208594004/extension?page=1&perPage=max"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"body": "v=0o=- 2693744390 3859148171 IN IP4 10.74.3.85s=SmcSipc=IN IP4 10.74.3.85t=0 0m=audio 10360 RTP/SAVPF 111 110a=rtpmap:111 OPUS/48000/2a=fmtp:111 useinbandfec=1a=rtpmap:110 telephone-event/48000a=fmtp:110 0-15a=sendrecva=rtcp:10360a=rtcp-muxa=setup:activea=fingerprint:sha-1 D3:82:0D:C0:44:8F:B1:A6:B9:39:0A:47:DB:6B:77:2A:3B:E5:7B:80a=ice-ufrag:5174ThxFa=ice-pwd:RTza1nhxRKAXSAVPNqHOirlu4ea=candidate:ffzHBmDvEZubdQeh 1 UDP 2130706431 10.74.3.85 10360 typ host",
"call_id": "prjo3dgt9g673s3vjhh4",
"cseq": 28,
"data": "SIP/2.0 200 OKVia: SIP/2.0/WSS e0u8rficicia.invalid;branch=z9hG4bK6630752From: <sip:18552085154*101@sip-xmnup.lab.nordigy.ru>;tag=cjq90bpor9To: <sip:102@sip-xmnup.lab.nordigy.ru>;tag=10.74.2.218-5070-8cfeb58f4aeb4afCall-ID: prjo3dgt9g673s3vjhh4CSeq: 28 INVITEContent-Length: 494Contact: <sip:102@10.74.3.83:8083;transport=wss>Content-Type: application/sdpSupported: replaces,timer,diversionP-Rc-Api-Ids: party-id=cs1726225542272257488-1;session-id=Y3MxNzI2MjI1NTQyMjcyMjU3NDg4QDEwLjc0LjIuMjE4Allow: SUBSCRIBE, NOTIFY, REFER, INVITE, ACK, BYE, CANCEL, UPDATE, INFOv=0o=- 878364845 246771824 IN IP4 10.74.3.85s=SmcSipc=IN IP4 10.74.3.85t=0 0m=audio 11822 RTP/SAVPF 111 110a=rtpmap:111 OPUS/48000/2a=fmtp:111 useinbandfec=1a=rtpmap:110 telephone-event/48000a=fmtp:110 0-15a=sendrecva=rtcp:11822a=rtcp-muxa=setup:activea=fingerprint:sha-1 68:1C:05:E3:93:AB:D6:A2:09:36:C3:7E:02:1A:A2:CE:23:A5:EF:9Ca=ice-ufrag:WZ9BJXhla=ice-pwd:SFs1dA3sdQr9g2nqUWSrEZ1RDWa=candidate:YxoXW6bGhfRYh9RF 1 UDP 2130706431 10.74.3.85 11822 typ host",
"from": {},
"from_tag": "cjq90bpor9",
"headers": {
"Allow": [{"raw": "SUBSCRIBE, NOTIFY, REFER, INVITE, ACK, BYE, CANCEL, UPDATE, INFO"}],
"Cseq": [{"raw": "28 INVITE","parsed":{"value": 28,"method":"INVITE"}}],
"Call-ID": [{"raw": "prjo3dgt9g673s3vjhh4","parsed": "prjo3dgt9g673s3vjhh4"}],
"Contact": [{"raw": "<sip:102@10.74.3.83:8083;transport=wss>","parsed": {}}],
"Content-Length": [{"raw": "494","parsed": 494}],
"Content-Type": [{"parsed":"application/sdp","raw":"application/sdp"}],
"From": [{"raw":"<sip:18552085154*101@sip-xmnup.lab.nordigy.ru>;tag=cjq90bpor9","parsed":{}}],
"P-Rc-Api-Ids": [{"raw":"party-id=cs1726225542272257488-1;session-id=Y3MxNzI2MjI1NTQyMjcyMjU3NDg4QDEwLjc0LjIuMjE4"}],
"Supported": [{"raw": "replaces,timer,diversion"}],
"To": [{"raw": "<sip:102@sip-xmnup.lab.nordigy.ru>;tag=10.74.2.218-5070-8cfeb58f4aeb4af","parsed":{}}],
"Via": {"branch":"z9hG4bK6630752","host":"e0u8rficicia.invalid","host_type":"domain","protocol":"SIP","transport":"WSS"},
"via_branch": "z9hG4bK6630752"
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const getPhone = async (shouldMockForLogin = true) => {
});
if (shouldMockForLogin) {
mock.restore();
mock.mockForLogin();
mock.mockForLogin({ mockUpdateConference: true });
phone.connectivityMonitor._checkConnectionFunc = () => true;
await ensureLogin(phone.auth, {
username: 'test',
Expand Down