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
@@ -0,0 +1,26 @@
{
"uri" : "https://platform.ringcentral.com/restapi/v1.0/account/208594004/extension/208594004/message-store/937441587020",
"id" : 5475922005,
"from" : {
"phoneNumber" : "+1234567890",
"name" : "Something1 New1",
"location" : "Orange, CA"
},
"type" : "Fax",
"creationTime" : "2018-02-12T05:20:02.000Z",
"readStatus" : "Read",
"priority" : "Normal",
"attachments" : [ {
"id" : 5475922005,
"uri" : "https://platform.ringcentral.com/restapi/v1.0/account/208594004/extension/208594004/message-store/937441587020/content/937441587020",
"type" : "RenderedDocument",
"contentType" : "application/pdf"
} ],
"direction" : "Inbound",
"availability" : "Alive",
"subject" : "+1234567890",
"messageStatus" : "Received",
"faxResolution" : "High",
"faxPageCount" : 3,
"lastModifiedTime" : "2018-02-12T15:15:35.758Z"
}
Original file line number Diff line number Diff line change
@@ -1,26 +1,37 @@
{
"uri" : "https://platform.ringcentral.com/restapi/v1.0/account/208594004/extension/208594004/message-store/937441587020",
"id" : 5475922005,
"from" : {
"phoneNumber" : "+1234567890",
"name" : "Something1 New1",
"location" : "Orange, CA"
"uri": "https://platform.ringcentral.com/restapi/v1.0/account/208594004/extension/208594004/message-store/5475922005",
"id": 5475922005,
"to": [
{
"extensionNumber": "101",
"name": "Something1 New1"
}
],
"from": {
"extensionNumber": "101",
"name": "Something1 New1"
},
"type" : "Fax",
"creationTime" : "2018-02-12T05:20:02.000Z",
"readStatus" : "Read",
"priority" : "Normal",
"attachments" : [ {
"id" : 5475922005,
"uri" : "https://platform.ringcentral.com/restapi/v1.0/account/208594004/extension/208594004/message-store/937441587020/content/937441587020",
"type" : "RenderedDocument",
"contentType" : "application/pdf"
} ],
"direction" : "Inbound",
"availability" : "Alive",
"subject" : "+1234567890",
"messageStatus" : "Received",
"faxResolution" : "High",
"faxPageCount" : 3,
"lastModifiedTime" : "2018-02-12T15:15:35.758Z"
"type": "Pager",
"creationTime": "2017-06-01T02:24:02.000Z",
"readStatus": "Read",
"priority": "Normal",
"attachments": [
{
"id": 5475922005,
"uri": "https://platform.ringcentral.com/restapi/v1.0/account/208594004/extension/208594004/message-store/5475922005/content/5475922005",
"type": "Text",
"contentType": "text/plain"
}
],
"direction": "Inbound",
"availability": "Alive",
"subject": "test 2",
"messageStatus": "Sent",
"conversationId": 6015823250778200202,
"conversation": {
"id": "6015823250778200202",
"uri": "https://platform.ringcentral.com/restapi/v1.0/conversation/6015823250778200202"
},
"lastModifiedTime": "2017-06-30T02:24:08.238Z",
"pgToDepartment": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ export function messageSync(mockResponse = {}, isOnce = true) {

export function messageList(mockResponse = {}) {
mockApi({
url: `begin:${mockServer}/restapi/v1.0/account/~/extension/~/message-store`,
url: `begin:${mockServer}/restapi/v1.0/account/~/extension/~/message-store?`,
body: {
...messageListBody,
...mockResponse,
Expand All @@ -263,14 +263,15 @@ export function messageList(mockResponse = {}) {
});
}

export function updateMessageStatus(mockResponse = {}) {
export function updateMessageStatus(mockResponse = {}, isOnce = true) {
mockApi({
url: `begin:${mockServer}/restapi/v1.0/account/~/extension/~/message-store`,
url: `begin:${mockServer}/restapi/v1.0/account/~/extension/~/message-store/`,
method: 'PUT',
body: {
...messageItemBody,
...mockResponse,
}
},
isOnce
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ describe('fax messages', () => {
await panel.find(NavigationBar).props().goTo('Fax');
wrapper.update();
mockUpdateMessageStatusApi({
id: 0,
id: 1,
readStatus: 'Read',
messageType: 'Fax',
});
Expand Down Expand Up @@ -458,7 +458,7 @@ describe('fax messages', () => {
await panel.find(NavigationBar).props().goTo('Fax');
wrapper.update();
mockUpdateMessageStatusApi({
id: 0,
id: 1,
readStatus: 'Unread',
messageType: 'Fax',
});
Expand All @@ -482,7 +482,7 @@ describe('fax messages', () => {
count: 100, messageType: 'Fax', readStatus: 'Unread', direction: 'Inbound'
});
mockUpdateMessageStatusApi({
id: 0,
id: 1,
readStatus: 'Read',
messageType: 'Fax',
});
Expand Down Expand Up @@ -524,7 +524,7 @@ describe('fax messages', () => {
count: 100, messageType: 'Fax', readStatus: 'Unread', direction: 'Inbound'
});
mockUpdateMessageStatusApi({
id: 0,
id: 1,
readStatus: 'Read',
messageType: 'Fax',
});
Expand Down Expand Up @@ -553,7 +553,7 @@ describe('fax messages', () => {

wrapper.update();
mockUpdateMessageStatusApi({
id: 0,
id: 1,
readStatus: 'Unread',
messageType: 'Fax',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import ConversationPanel from 'ringcentral-widgets/components/ConversationPanel'
import LogButton from 'ringcentral-widgets/components/LogButton';
import Button from 'ringcentral-widgets/components/Button';
import Spinner from 'ringcentral-widgets/components/Spinner';
import * as mock from 'ringcentral-integration/integration-test/mock';

import { getWrapper, timeout } from '../shared';

Expand Down Expand Up @@ -54,8 +55,15 @@ describe('messages', () => {
});

test('click a message', async () => {
const message = wrapper.props().phone.messageStore.allConversations[0];
mock.updateMessageStatus({
...message,
readStatus: 'Read',
lastModifiedTime: (new Date()).toISOString(),
}, false);
const firstMessage = panel.find(MessageItem).first();
await firstMessage.find('.wrapper').first().simulate('click');
await timeout(200); // wait conversation loaded
const conversationPanel = wrapper.find(ConversationPanel);
expect(conversationPanel.length > 0).toBe(true);
});
Expand Down Expand Up @@ -89,16 +97,30 @@ describe('messages', () => {
});

test('message log button', async () => {
const message = wrapper.props().phone.messageStore.allConversations[0];
mock.updateMessageStatus({
...message,
readStatus: 'Read',
lastModifiedTime: (new Date()).toISOString(),
}, false);
const firstMessage = panel.find(MessageItem).first();
await firstMessage.find('.wrapper').first().simulate('click');
await timeout(200); // wait conversation loaded
const conversationPanel = wrapper.find(ConversationPanel);
const logButton = conversationPanel.find(LogButton).first().find(Button);
expect(logButton.props().disabled).toBe(false);
});

test('message click log button', async () => {
const message = wrapper.props().phone.messageStore.allConversations[0];
mock.updateMessageStatus({
...message,
readStatus: 'Read',
lastModifiedTime: (new Date()).toISOString(),
}, false);
const firstMessage = panel.find(MessageItem).first();
await firstMessage.find('.wrapper').first().simulate('click');
await timeout(200); // wait conversation loaded
let conversationPanel = wrapper.find(ConversationPanel);
let logButton = conversationPanel.find(LogButton).find(Button);
logButton.simulate('click');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import messageSyncBody from 'ringcentral-integration/integration-test/mock/data/messageSync.json';
import messageFaxItemBody from 'ringcentral-integration/integration-test/mock/data/messageFaxItem.json';
import subscriptionBody from 'ringcentral-integration/integration-test/mock/data/subscription.json';
import pubnubMsg from 'ringcentral-integration/integration-test/mock/data/pubnub.json';
import * as mock from 'ringcentral-integration/integration-test/mock';
Expand Down Expand Up @@ -26,8 +27,8 @@ export function mockGenerateMessageApi({
count = 1, messageType = 'Text', readStatus = 'Unread', direction = 'Inbound'
}) {
const records = [];
for (let i = 0; i < count; i += 1) {
records.push({
for (let i = 1; i <= count; i += 1) {
const mockedMessage = {
...messageSyncBody.records[0],
type: messageType,
readStatus,
Expand All @@ -44,21 +45,38 @@ export function mockGenerateMessageApi({
},
creationTime: (new Date()).toISOString(),
lastModifiedTime: (new Date()).toISOString(),
});
};
if (messageType === 'Fax' || messageType === 'VoiceMail') {
// Fax and Voicemail doesn't have conversation
mockedMessage.conversation = undefined;
mockedMessage.conversationId = undefined;
}
records.push(mockedMessage);
}
mock.messageSync({ records });
}
export function mockUpdateMessageStatusApi({
id = 0, messageType = 'Text', readStatus = 'Unread', direction = 'Inbound'
id = 1, messageType = 'Text', readStatus = 'Unread', direction = 'Inbound'
}) {
mock.updateMessageStatus({
let preDefined = {};
if (messageType === 'Fax') {
preDefined = messageFaxItemBody;
}
const mockedMessage = {
...preDefined,
type: messageType,
id,
readStatus,
direction,
messageStatus: direction === 'Inbound' ? 'Received' : 'Sent',
creationTime: (new Date()).toISOString(),
lastModifiedTime: (new Date()).toISOString(),
});
};
if (messageType === 'Fax' || messageType === 'VoiceMail') {
// Fax and Voicemail doesn't have conversation
mockedMessage.conversation = undefined;
mockedMessage.conversationId = undefined;
}
mock.updateMessageStatus(mockedMessage);
}