Sync call link call history
This commit is contained in:
parent
ce83195170
commit
2785501f82
26 changed files with 800 additions and 175 deletions
|
@ -321,21 +321,21 @@ describe('sql/getCallHistoryGroups', () => {
|
|||
const now = Date.now();
|
||||
const roomId = generateUuid();
|
||||
|
||||
function toCall(callId: string, timestamp: number, type: CallType) {
|
||||
function toCall(callId: string, timestamp: number) {
|
||||
return {
|
||||
callId,
|
||||
peerId: roomId,
|
||||
ringerId: null,
|
||||
mode: CallMode.Adhoc,
|
||||
type,
|
||||
type: CallType.Adhoc,
|
||||
direction: CallDirection.Outgoing,
|
||||
timestamp,
|
||||
status: AdhocCallStatus.Joined,
|
||||
};
|
||||
}
|
||||
|
||||
const call1 = toCall('1', now - 10, CallType.Group);
|
||||
const call2 = toCall('2', now, CallType.Group);
|
||||
const call1 = toCall('1', now - 10);
|
||||
const call2 = toCall('2', now);
|
||||
|
||||
await saveCallHistory(call1);
|
||||
await saveCallHistory(call2);
|
||||
|
@ -394,28 +394,23 @@ describe('sql/getCallHistoryGroupsCount', () => {
|
|||
const roomId1 = generateUuid();
|
||||
const roomId2 = generateUuid();
|
||||
|
||||
function toCall(
|
||||
callId: string,
|
||||
roomId: string,
|
||||
timestamp: number,
|
||||
type: CallType
|
||||
) {
|
||||
function toCall(callId: string, roomId: string, timestamp: number) {
|
||||
return {
|
||||
callId,
|
||||
peerId: roomId,
|
||||
ringerId: null,
|
||||
mode: CallMode.Adhoc,
|
||||
type,
|
||||
type: CallType.Adhoc,
|
||||
direction: CallDirection.Outgoing,
|
||||
timestamp,
|
||||
status: AdhocCallStatus.Joined,
|
||||
};
|
||||
}
|
||||
|
||||
const call1 = toCall('1', roomId1, now - 20, CallType.Group);
|
||||
const call2 = toCall('2', roomId1, now - 10, CallType.Group);
|
||||
const call3 = toCall('3', roomId1, now, CallType.Group);
|
||||
const call4 = toCall('4', roomId2, now, CallType.Group);
|
||||
const call1 = toCall('1', roomId1, now - 20);
|
||||
const call2 = toCall('2', roomId1, now - 10);
|
||||
const call3 = toCall('3', roomId1, now);
|
||||
const call4 = toCall('4', roomId2, now);
|
||||
|
||||
await saveCallHistory(call1);
|
||||
await saveCallHistory(call2);
|
||||
|
|
|
@ -36,6 +36,8 @@ import {
|
|||
import { generateAci } from '../../../types/ServiceId';
|
||||
import { getDefaultConversation } from '../../../test-both/helpers/getDefaultConversation';
|
||||
import type { UnwrapPromise } from '../../../types/Util';
|
||||
import { CallLinkRestrictions } from '../../../types/CallLink';
|
||||
import { FAKE_CALL_LINK } from '../../../test-both/helpers/fakeCallLink';
|
||||
|
||||
const ACI_1 = generateAci();
|
||||
const NOW = new Date('2020-01-23T04:56:00.000');
|
||||
|
@ -1301,6 +1303,62 @@ describe('calling duck', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('handleCallLinkUpdate', () => {
|
||||
const { roomId, rootKey, expiration } = FAKE_CALL_LINK;
|
||||
|
||||
beforeEach(function (this: Mocha.Context) {
|
||||
this.callingServiceReadCallLink = this.sandbox
|
||||
.stub(callingService, 'readCallLink')
|
||||
.resolves({
|
||||
callLinkState: {
|
||||
name: 'Signal Call',
|
||||
restrictions: CallLinkRestrictions.None,
|
||||
expiration,
|
||||
revoked: false,
|
||||
},
|
||||
errorStatusCode: undefined,
|
||||
});
|
||||
});
|
||||
|
||||
it('reads the call link from calling service', async function (this: Mocha.Context) {
|
||||
const { handleCallLinkUpdate } = actions;
|
||||
const dispatch = sinon.spy();
|
||||
await handleCallLinkUpdate({ rootKey, adminKey: null })(
|
||||
dispatch,
|
||||
getEmptyRootState,
|
||||
null
|
||||
);
|
||||
|
||||
sinon.assert.calledOnce(this.callingServiceReadCallLink);
|
||||
});
|
||||
|
||||
it('dispatches HANDLE_CALL_LINK_UPDATE', async () => {
|
||||
const { handleCallLinkUpdate } = actions;
|
||||
const dispatch = sinon.spy();
|
||||
await handleCallLinkUpdate({ rootKey, adminKey: null })(
|
||||
dispatch,
|
||||
getEmptyRootState,
|
||||
null
|
||||
);
|
||||
|
||||
sinon.assert.calledOnce(dispatch);
|
||||
sinon.assert.calledWith(dispatch, {
|
||||
type: 'calling/HANDLE_CALL_LINK_UPDATE',
|
||||
payload: {
|
||||
roomId,
|
||||
callLinkDetails: {
|
||||
name: 'Signal Call',
|
||||
restrictions: CallLinkRestrictions.None,
|
||||
expiration,
|
||||
revoked: false,
|
||||
rootKey,
|
||||
adminKey: null,
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('peekNotConnectedGroupCall', () => {
|
||||
const { peekNotConnectedGroupCall } = actions;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue