10000 Added tests to ensure restart bubble not present by srinaath · Pull Request #2107 · microsoft/BotFramework-Emulator · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Added tests to ensure restart bubble not present #2107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 13, 2020
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Fixed
- [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)
- [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)

- [client] Disable "Restart conversation from here" bubble on DL Speech bots [2107](https://github.com/microsoft/BotFramework-Emulator/pull/2107)

## v4.8.0 - 2019 - 03 - 12
## Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ import { ValueTypes, RestartConversationOptions, RestartConversationStatus } fro
import { OuterActivityWrapper } from './outerActivityWrapper';
import { OuterActivityWrapperContainer } from './outerActivityWrapperContainer';

jest.mock('./chat.scss', () => ({
hidden: 'hidden-restart',
}));

describe('<OuterActivityWrapper />', () => {
it('should render', () => {
const storeState = {
Expand Down Expand Up @@ -152,4 +156,201 @@ describe('<OuterActivityWrapper />', () => {
expect((instance as any).isUserActivity(userCard.activity)).toBe(true);
expect((instance as any).isUserActivity(botCard.activity)).toBe(false);
});

describe('Restart conversation bubble in OuterActivityWrapper', () => {
it('should show restart bubble if a)not Speech bot; b) Webchat is enabled; c)User activity is selected', () => {
const card = {
activity: {
id: 'card1',
from: {
role: 'user',
},
channelData: {
test: true,
},
},
};
const storeState = {
chat: {
chats: {
doc1: {
highlightedObjects: [],
inspectorObjects: [{ value: { ...card.activity }, valueType: ValueTypes.Activity }],
mode: 'livechat',
},
},
restartStatus: {
doc1: RestartConversationStatus.Stop,
},
},
};

const wrapper = mount(
<Provider store={createStore((state, action) => state, storeState)}>
<OuterActivityWrapperContainer
card={card}
documentId={'doc1'}
>
/>
</Provider>
);
expect(wrapper.find('hidden-restart').length).toBe(0);
});

it('should hide restart bubble if activity not selected', () => {
const card = {
activity: {
id: 'card1',
from: {
role: 'user',
},
channelData: {
test: true,
},
},
};
const storeState = {
chat: {
chats: {
doc1: {
highlightedObjects: [],
inspectorObjects: [{ value: {}, valueType: ValueTypes.Activity }],
mode: 'livechat',
},
},
restartStatus: {
doc1: RestartConversationStatus.Stop,
},
},
};

const wrapper = mount(
<Provider store={createStore((state, action) => state, storeState)}>
<OuterActivityWrapperContainer
card={card}
documentId={'doc1'}
>
/>
</Provider>
);
expect(wrapper.find('.hidden-restart').length).toBe(1);
});

it('should hide restart bubble if it is a speech bot', () => {
const card = {
activity: {
id: 'card1',
from: {
role: 'user',
},
channelData: {
test: true,
},
},
};
const storeState = {
chat: {
chats: {
doc1: {
highlightedObjects: [],
inspectorObjects: [{ value: { ...card.activity }, valueType: ValueTypes.Activity }],
mode: 'livechat',
speechKey: 'abc',
speechRegion: 'westus',
},
},
restartStatus: {
doc1: RestartConversationStatus.Stop,
},
},
};

const wrapper = mount(
<Provider store={createStore((state, action) => state, storeState)}>
<OuterActivityWrapperContainer
card={card}
documentId={'doc1'}
>
/>
</Provider>
);
expect(wrapper.find('.hidden-restart').length).toBe(1);
});

it('should hide restart bubble if restart conversation has a status of "Started" for chat', () => {
const card = {
activity: {
id: 'card1',
from: {
role: 'user',
},
channelData: {
test: true,
},
},
};
const storeState = {
chat: {
chats: {
doc1: {
highlightedObjects: [],
inspectorObjects: [{ value: { ...card.activity }, valueType: ValueTypes.Activity }],
mode: 'livechat',
},
},
restartStatus: {
doc1: RestartConversationStatus.Started,
},
},
};

const wrapper = mount(
<Provider store={createStore((state, action) => state, storeState)}>
<OuterActivityWrapperContainer
card={card}
documentId={'doc1'}
>
/>
</Provider>
);
expect(wrapper.find('.hidden-restart').length).toBe(1);
});

it('should hide restart bubble if chat in transcript mode', () => {
const card = {
activity: {
id: 'card1',
from: {
role: 'user',
},
channelData: {
test: true,
},
},
};
const storeState = {
chat: {
chats: {
doc1: {
highlightedObjects: [],
inspectorObjects: [{ value: { ...card.activity }, valueType: ValueTypes.Activity }],
mode: 'transcript',
},
},
restartStatus: {},
},
};

const wrapper = mount(
<Provider store={createStore((state, action) => state, storeState)}>
<OuterActivityWrapperContainer
card={card}
documentId={'doc1'}
>
/>
</Provider>
);
expect(wrapper.find('.hidden-restart').length).toBe(1);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export interface OuterActivityWrapperProps {
currentRestartConversationOption: RestartConversationOptions;
mode: EmulatorMode;
restartStatus: RestartConversationStatus;
isDLSpeechBot: boolean;
}

export class OuterActivityWrapper extends React.Component<OuterActivityWrapperProps, {}> {
Expand All @@ -69,14 +70,15 @@ export class OuterActivityWrapper extends React.Component<OuterActivityWrapperPr
onItemRendererKeyDown,
mode,
restartStatus,
isDLSpeechBot,
5D40 } = this.props;

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

const showRestartBubble = isUserActivity && isSelected && !isWebChatDisabled;
const showRestartBubble = !isDLSpeechBot && isUserActivity && isSelected && !isWebChatDisabled;

return (
<ActivityWrapper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ function mapStateToProps(state: RootState, { documentId }: { documentId: string
currentRestartConversationOption: state.chat.chats[documentId].restartConversationOption,
mode: state.chat.chats[documentId].mode,
restartStatus: state.chat.restartStatus[documentId],
isDLSpeechBot: !!(state.chat.chats[documentId].speechKey && state.chat.chats[documentId].speechRegion),
};
}

Expand Down
0