Skip to content

Commit

Permalink
Merge 83be3d3 into 35635ea
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosscastro committed Aug 7, 2019
2 parents 35635ea + 83be3d3 commit 678f1f4
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 62 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Added
- [main] Added End-to-End tests using Spectron in PR [1696](https://github.com/microsoft/BotFramework-Emulator/pull/1696)
- [main] New Conversation: send a single conversation update activity including bot and user as members added [1709](https://github.com/microsoft/BotFramework-Emulator/pull/1709)

## v4.5.2 - 2019 - 07 - 17
## Fixed
Expand Down
Expand Up @@ -128,6 +128,10 @@ describe('The directLine middleware', () => {
{
type: 'conversationUpdate',
membersAdded: [
{
id: '0a441b55-d1d6-4015-bbb4-2e7f44fa9f42',
name: 'User',
},
{
id: 'http://localhost:3978/api/messages',
name: 'Bot',
Expand All @@ -151,32 +155,6 @@ describe('The directLine middleware', () => {
},
serviceUrl: 'https://a457e760.ngrok.io',
},
{
type: 'conversationUpdate',
membersAdded: [
{
id: '0a441b55-d1d6-4015-bbb4-2e7f44fa9f42',
name: 'User',
},
],
channelId: 'emulator',
conversation: {
id: '6e8b5950-bcec-11e8-97ca-bd586926880a|livechat',
},
id: '6e9fcbb0-bcec-11e8-a0e5-939fd8c687fd',
localTimestamp: '2018-09-20T08:47:08-07:00',
recipient: {
id: 'http://localhost:3978/api/messages',
name: 'Bot',
role: 'bot',
},
timestamp: '2018-09-20T15:47:08.907Z',
from: {
id: '0a441b55-d1d6-4015-bbb4-2e7f44fa9f42',
name: 'User',
},
serviceUrl: 'https://a457e760.ngrok.io',
},
{
type: 'message',
serviceUrl: 'https://a457e760.ngrok.io',
Expand Down
Expand Up @@ -60,10 +60,17 @@ export default function startConversation(botEmulator: BotEmulator) {

if (!conversation) {
conversation = conversations.newConversation(botEmulator, botEndpoint, currentUser, conversationId);
// Sends "bot added to conversation"
await conversation.sendConversationUpdate([{ id: botEndpoint.botId, name: 'Bot' }], undefined);
// Sends "user added to conversation"
await conversation.sendConversationUpdate([currentUser], undefined);

if (!currentUser) {
// New conversations should have a user. Since we don't have one, this is a bug. Report the error
res.send(HttpStatus.BAD_REQUEST, 'current user not provided');
res.end();
next();
return;
}

// Send a ConversationUpdate activity adding the bot and user to the conversation
await conversation.sendConversationUpdate([currentUser, { id: botEndpoint.botId, name: 'Bot' }], undefined);
created = true;
} else if (botEndpoint && !conversationId.endsWith('transcript')) {
if (conversation.members.findIndex(user => user.id === botEndpoint.botId) === -1) {
Expand Down
46 changes: 14 additions & 32 deletions packages/emulator/core/src/facility/conversation.spec.ts
Expand Up @@ -42,6 +42,10 @@ const mockTranscript = [
activity: {
type: 'conversationUpdate',
membersAdded: [
{
id: '5e1f1c4c-6a89-4880-8db0-0f222c07ae9a',
name: 'User',
},
{
id: '1',
name: 'Bot',
Expand All @@ -67,36 +71,6 @@ const mockTranscript = [
serviceUrl: 'https://3a469f6b.ngrok.io',
},
},
{
type: 'activity add',
activity: {
type: 'conversationUpdate',
membersAdded: [
{
id: '5e1f1c4c-6a89-4880-8db0-0f222c07ae9a',
name: 'User',
},
],
channelId: 'emulator',
conversation: {
id: 'b94a54f0-1f4d-11e9-a14a-49165b6799aa|livechat',
},
id: 'b9c50330-1f4d-11e9-bad7-9740f2a4e769',
localTimestamp: '2019-01-23T12:30:30-08:00',
recipient: {
id: '1',
name: 'Bot',
role: 'bot',
},
timestamp: '2019-01-23T20:30:30.115Z',
from: {
id: '5e1f1c4c-6a89-4880-8db0-0f222c07ae9a',
name: 'User',
},
locale: 'en-us',
serviceUrl: 'https://3a469f6b.ngrok.io',
},
},
{
type: 'activity add',
activity: {
Expand Down Expand Up @@ -156,6 +130,10 @@ const mockTranscript = [
const mockActivity = {
type: 'conversationUpdate',
membersAdded: [
{
id: '5e1f1c4c-6a89-4880-8db0-0f222c07ae9a',
name: 'User',
},
{
id: '1',
name: 'Bot',
Expand Down Expand Up @@ -293,7 +271,7 @@ describe('Conversation class', () => {
it('should get the transcript from the conversation', async () => {
(conversation as any).transcript = mockTranscript;
const transcripts = await conversation.getTranscript();
expect(transcripts.length).toBe(4);
expect(transcripts.length).toBe(3);
let i = transcripts.length;
while (i--) {
expect(transcripts[i]).toEqual(mockTranscript[i].activity);
Expand All @@ -317,12 +295,16 @@ describe('Conversation class', () => {
expect(spy).toHaveBeenCalledWith(
{
membersAdded: [
{
id: '5e1f1c4c-6a89-4880-8db0-0f222c07ae9a',
name: 'User',
},
{
id: '1',
name: 'Bot',
},
],
membersRemoved: [{ id: '1', name: 'Bot' }],
membersRemoved: [{ id: '5e1f1c4c-6a89-4880-8db0-0f222c07ae9a', name: 'User' }, { id: '1', name: 'Bot' }],
type: 'conversationUpdate',
},
false
Expand Down

0 comments on commit 678f1f4

Please sign in to comment.