Skip to content

Commit 888d58a

Browse files
authored
Merge branch 'main' into remove-activity-listener-composer
2 parents 541402e + a6b3ad8 commit 888d58a

File tree

5 files changed

+98
-8
lines changed

5 files changed

+98
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ Notes: web developers are advised to use [`~` (tilde range)](https://github.com/
8585
- Added support of [contentless activity in livestream](https://github.com/microsoft/BotFramework-WebChat/blob/main/docs/LIVESTREAMING.md#scenario-3-interim-activities-with-no-content), in PR [#5430](https://github.com/microsoft/BotFramework-WebChat/pull/5430), by [@compulim](https://github.com/compulim)
8686
- Added sliding dots typing indicator in Fluent theme, in PR [#5447](https://github.com/microsoft/BotFramework-WebChat/pull/5447) and PR [#5448](https://github.com/microsoft/BotFramework-WebChat/pull/5448), by [@compulim](https://github.com/compulim)
8787
- (Experimental) Add an ability to pass `completion` prop into Fluent send box and expose the component, in PR [#5466](https://github.com/microsoft/BotFramework-WebChat/pull/5466), by [@OEvgeny](https://github.com/OEvgeny)
88-
- Added feedback form for like/dislike button when `feedbackActionsPlacement` is `"activity-actions"`, in PR [#5460](https://github.com/microsoft/BotFramework-WebChat/pull/5460), by [@lexi-taylor](https://github.com/lexi-taylor) and [@OEvgeny](https://github.com/OEvgeny)
88+
- Added feedback form for like/dislike button when `feedbackActionsPlacement` is `"activity-actions"`, in PR [#5460](https://github.com/microsoft/BotFramework-WebChat/pull/5460) and in PR [#5469](https://github.com/microsoft/BotFramework-WebChat/pull/5469), by [@lexi-taylor](https://github.com/lexi-taylor) and [@OEvgeny](https://github.com/OEvgeny)
8989

9090
### Changed
9191

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<!doctype html>
2+
<html lang="en-US">
3+
<head>
4+
<link href="/assets/index.css" rel="stylesheet" type="text/css" />
5+
<script crossorigin="anonymous" src="https://unpkg.com/@babel/[email protected]/babel.min.js"></script>
6+
<script crossorigin="anonymous" src="https://unpkg.com/[email protected]/umd/react.production.min.js"></script>
7+
<script crossorigin="anonymous" src="https://unpkg.com/[email protected]/umd/react-dom.production.min.js"></script>
8+
<script crossorigin="anonymous" src="/test-harness.js"></script>
9+
<script crossorigin="anonymous" src="/test-page-object.js"></script>
10+
<script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script>
11+
<script crossorigin="anonymous" src="/__dist__/botframework-webchat-fluent-theme.production.min.js"></script>
12+
</head>
13+
14+
<body>
15+
<main id="webchat"></main>
16+
<script type="text/babel">
17+
run(async function () {
18+
const {
19+
React,
20+
ReactDOM: { render },
21+
WebChat: { FluentThemeProvider, ReactWebChat }
22+
} = window; // Imports in UMD fashion.
23+
24+
const { directLine, store } = testHelpers.createDirectLineEmulator();
25+
26+
const App = () => <ReactWebChat directLine={directLine} store={store} />;
27+
28+
render(
29+
<FluentThemeProvider>
30+
<App />
31+
</FluentThemeProvider>,
32+
document.getElementById('webchat')
33+
);
34+
35+
await pageConditions.uiConnected();
36+
37+
await directLine.emulateIncomingActivity({
38+
type: 'message',
39+
id: 'a-00001',
40+
timestamp: 0,
41+
text: 'This is a a test message without a disclaimer',
42+
from: {
43+
role: 'bot'
44+
},
45+
locale: 'en-US',
46+
entities: [],
47+
channelData: {
48+
feedbackLoop: {
49+
type: 'default'
50+
}
51+
}
52+
});
53+
54+
pageElements.byTestId('send box text area').focus();
55+
await host.sendShiftTab(2);
56+
57+
await host.sendKeys('ENTER');
58+
59+
await host.sendKeys('ENTER');
60+
61+
await pageConditions.became(
62+
'feedback form is open',
63+
() => document.activeElement === pageElements.byTestId('feedback sendbox'),
64+
1000
65+
);
66+
67+
await host.snapshot('local');
68+
});
69+
</script>
70+
</body>
71+
</html>
24.5 KB
Loading
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { type WebChatActivity } from 'botframework-webchat-core';
2-
import hasFeedbackLoop from './hasFeedbackLoop';
2+
import { hasDisclaimer } from './hasFeedbackLoop';
33

44
export default function getDisclaimer(activity: WebChatActivity): string | undefined {
5-
return hasFeedbackLoop(activity) ? activity.channelData.feedbackLoop.disclaimer : undefined;
5+
return hasDisclaimer(activity) ? activity.channelData.feedbackLoop.disclaimer : undefined;
66
}
Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,36 @@
11
import { type WebChatActivity } from 'botframework-webchat-core';
2-
import { literal, object, safeParse, string, type InferOutput } from 'valibot';
2+
import { literal, object, optional, safeParse, string, union, type InferOutput } from 'valibot';
33

4-
const activityWithFeedbackLoopSchema = object({
4+
const activityWithFeedbackLoopSchemaWithDisclaimer = object({
55
channelData: object({
66
feedbackLoop: object({
7-
disclaimer: string(),
7+
disclaimer: optional(string()),
88
type: literal('default')
99
})
1010
})
1111
});
1212

13-
type FeedbackActivity = WebChatActivity & InferOutput<typeof activityWithFeedbackLoopSchema>;
13+
const activityWithFeedbackLoopSchemaWithOutDisclaimer = object({
14+
channelData: object({
15+
feedbackLoop: object({
16+
type: literal('default')
17+
})
18+
})
19+
});
20+
21+
const feedbackLoopSchema = union([
22+
activityWithFeedbackLoopSchemaWithDisclaimer,
23+
activityWithFeedbackLoopSchemaWithOutDisclaimer
24+
]);
25+
26+
type FeedbackActivity = WebChatActivity & InferOutput<typeof feedbackLoopSchema>;
27+
28+
export function hasDisclaimer(
29+
activity: WebChatActivity
30+
): activity is WebChatActivity & InferOutput<typeof activityWithFeedbackLoopSchemaWithDisclaimer> {
31+
return safeParse(activityWithFeedbackLoopSchemaWithDisclaimer, activity).success;
32+
}
1433

1534
export default function hasFeedbackLoop(activity: WebChatActivity): activity is FeedbackActivity {
16-
return safeParse(activityWithFeedbackLoopSchema, activity).success;
35+
return safeParse(feedbackLoopSchema, activity).success;
1736
}

0 commit comments

Comments
 (0)