Skip to content

Commit a3f7887

Browse files
srinaathSrinaath Ravichandran
and
Srinaath Ravichandran
authored
Added tests to ensure restart bubble not present (#2107)
Should hide restart bubble if speech bot Co-authored-by: Srinaath Ravichandran <[email protected]>
1 parent 4e714bf commit a3f7887

File tree

4 files changed

+206
-2
lines changed

4 files changed

+206
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## Fixed
99
- [build] Replaced a missing .icns file that was deleted by mistake in a previous PR. Fixes the app icon on Linux & Mac in PR [2104](https://github.com/microsoft/BotFramework-Emulator/pull/2104)
1010
- [client] Fixed an issue where Restart activity wont appear on selected activity after restarting once in PR [2105](https://github.com/microsoft/BotFramework-Emulator/pull/2105)
11-
11+
- [client] Disable "Restart conversation from here" bubble on DL Speech bots [2107](https://github.com/microsoft/BotFramework-Emulator/pull/2107)
1212

1313
## v4.8.0 - 2019 - 03 - 12
1414
## Added

packages/app/client/src/ui/editor/emulator/parts/chat/outerActivityWrapper.spec.tsx

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ import { ValueTypes, RestartConversationOptions, RestartConversationStatus } fro
4040
import { OuterActivityWrapper } from './outerActivityWrapper';
4141
import { OuterActivityWrapperContainer } from './outerActivityWrapperContainer';
4242

43+
jest.mock('./chat.scss', () => ({
44+
hidden: 'hidden-restart',
45+
}));
46+
4347
describe('<OuterActivityWrapper />', () => {
4448
it('should render', () => {
4549
const storeState = {
@@ -152,4 +156,201 @@ describe('<OuterActivityWrapper />', () => {
152156
expect((instance as any).isUserActivity(userCard.activity)).toBe(true);
153157
expect((instance as any).isUserActivity(botCard.activity)).toBe(false);
154158
});
159+
160+
describe('Restart conversation bubble in OuterActivityWrapper', () => {
161+
it('should show restart bubble if a)not Speech bot; b) Webchat is enabled; c)User activity is selected', () => {
162+
const card = {
163+
activity: {
164+
id: 'card1',
165+
from: {
166+
role: 'user',
167+
},
168+
channelData: {
169+
test: true,
170+
},
171+
},
172+
};
173+
const storeState = {
174+
chat: {
175+
chats: {
176+
doc1: {
177+
highlightedObjects: [],
178+
inspectorObjects: [{ value: { ...card.activity }, valueType: ValueTypes.Activity }],
179+
mode: 'livechat',
180+
},
181+
},
182+
restartStatus: {
183+
doc1: RestartConversationStatus.Stop,
184+
},
185+
},
186+
};
187+
188+
const wrapper = mount(
189+
<Provider store={createStore((state, action) => state, storeState)}>
190+
<OuterActivityWrapperContainer
191+
card={card}
192+
documentId={'doc1'}
193+
onRestartConversationFromActivityClick={jest.fn()}
194+
/>
195+
</Provider>
196+
);
197+
expect(wrapper.find('hidden-restart').length).toBe(0);
198+
});
199+
200+
it('should hide restart bubble if activity not selected', () => {
201+
const card = {
202+
activity: {
203+
id: 'card1',
204+
from: {
205+
role: 'user',
206+
},
207+
channelData: {
208+
test: true,
209+
},
210+
},
211+
};
212+
const storeState = {
213+
chat: {
214+
chats: {
215+
doc1: {
216+
highlightedObjects: [],
217+
inspectorObjects: [{ value: {}, valueType: ValueTypes.Activity }],
218+
mode: 'livechat',
219+
},
220+
},
221+
restartStatus: {
222+
doc1: RestartConversationStatus.Stop,
223+
},
224+
},
225+
};
226+
227+
const wrapper = mount(
228+
<Provider store={createStore((state, action) => state, storeState)}>
229+
<OuterActivityWrapperContainer
230+
card={card}
231+
documentId={'doc1'}
232+
onRestartConversationFromActivityClick={jest.fn()}
233+
/>
234+
</Provider>
235+
);
236+
expect(wrapper.find('.hidden-restart').length).toBe(1);
237+
});
238+
239+
it('should hide restart bubble if it is a speech bot', () => {
240+
const card = {
241+
activity: {
242+
id: 'card1',
243+
from: {
244+
role: 'user',
245+
},
246+
channelData: {
247+
test: true,
248+
},
249+
},
250+
};
251+
const storeState = {
252+
chat: {
253+
chats: {
254+
doc1: {
255+
highlightedObjects: [],
256+
inspectorObjects: [{ value: { ...card.activity }, valueType: ValueTypes.Activity }],
257+
mode: 'livechat',
258+
speechKey: 'abc',
259+
speechRegion: 'westus',
260+
},
261+
},
262+
restartStatus: {
263+
doc1: RestartConversationStatus.Stop,
264+
},
265+
},
266+
};
267+
268+
const wrapper = mount(
269+
<Provider store={createStore((state, action) => state, storeState)}>
270+
<OuterActivityWrapperContainer
271+
card={card}
272+
documentId={'doc1'}
273+
onRestartConversationFromActivityClick={jest.fn()}
274+
/>
275+
</Provider>
276+
);
277+
expect(wrapper.find('.hidden-restart').length).toBe(1);
278+
});
279+
280+
it('should hide restart bubble if restart conversation has a status of "Started" for chat', () => {
281+
const card = {
282+
activity: {
283+
id: 'card1',
284+
from: {
285+
role: 'user',
286+
},
287+
channelData: {
288+
test: true,
289+
},
290+
},
291+
};
292+
const storeState = {
293+
chat: {
294+
chats: {
295+
doc1: {
296+
highlightedObjects: [],
297+
inspectorObjects: [{ value: { ...card.activity }, valueType: ValueTypes.Activity }],
298+
mode: 'livechat',
299+
},
300+
},
301+
restartStatus: {
302+
doc1: RestartConversationStatus.Started,
303+
},
304+
},
305+
};
306+
307+
const wrapper = mount(
308+
<Provider store={createStore((state, action) => state, storeState)}>
309+
<OuterActivityWrapperContainer
310+
card={card}
311+
documentId={'doc1'}
312+
onRestartConversationFromActivityClick={jest.fn()}
313+
/>
314+
</Provider>
315+
);
316+
expect(wrapper.find('.hidden-restart').length).toBe(1);
317+
});
318+
319+
it('should hide restart bubble if chat in transcript mode', () => {
320+
const card = {
321+
activity: {
322+
id: 'card1',
323+
from: {
324+
role: 'user',
325+
},
326+
channelData: {
327+
test: true,
328+
},
329+
},
330+
};
331+
const storeState = {
332+
chat: {
333+
chats: {
334+
doc1: {
335+
highlightedObjects: [],
336+
inspectorObjects: [{ value: { ...card.activity }, valueType: ValueTypes.Activity }],
337+
mode: 'transcript',
338+
},
339+
},
340+
restartStatus: {},
341+
},
342+
};
343+
344+
const wrapper = mount(
345+
<Provider store={createStore((state, action) => state, storeState)}>
346+
<OuterActivityWrapperContainer
347+
card={card}
348+
documentId={'doc1'}
349+
onRestartConversationFromActivityClick={jest.fn()}
350+
/>
351+
</Provider>
352+
);
353+
expect(wrapper.find('.hidden-restart').length).toBe(1);
354+
});
355+
});
155356
});

packages/app/client/src/ui/editor/emulator/parts/chat/outerActivityWrapper.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export interface OuterActivityWrapperProps {
5757
currentRestartConversationOption: RestartConversationOptions;
5858
mode: EmulatorMode;
5959
restartStatus: RestartConversationStatus;
60+
isDLSpeechBot: boolean;
6061
}
6162

6263
export class OuterActivityWrapper extends React.Component<OuterActivityWrapperProps, {}> {
@@ -69,14 +70,15 @@ export class OuterActivityWrapper extends React.Component<OuterActivityWrapperPr
6970
onItemRendererKeyDown,
7071
mode,
7172
restartStatus,
73+
isDLSpeechBot,
7274
} = this.props;
7375

7476
const isSelected = this.shouldBeSelected(card.activity);
7577
const isUserActivity = this.isUserActivity(card.activity);
7678
const isWebChatDisabled =
7779
mode === 'transcript' || mode === 'debug' || restartStatus === RestartConversationStatus.Started;
7880

79-
const showRestartBubble = isUserActivity && isSelected && !isWebChatDisabled;
81+
const showRestartBubble = !isDLSpeechBot && isUserActivity && isSelected && !isWebChatDisabled;
8082

8183
return (
8284
<ActivityWrapper

packages/app/client/src/ui/editor/emulator/parts/chat/outerActivityWrapperContainer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ function mapStateToProps(state: RootState, { documentId }: { documentId: string
5959
currentRestartConversationOption: state.chat.chats[documentId].restartConversationOption,
6060
mode: state.chat.chats[documentId].mode,
6161
restartStatus: state.chat.restartStatus[documentId],
62+
isDLSpeechBot: !!(state.chat.chats[documentId].speechKey && state.chat.chats[documentId].speechRegion),
6263
};
6364
}
6465

0 commit comments

Comments
 (0)