diff --git a/CHANGELOG.md b/CHANGELOG.md index a914738a19..b73f3cd21c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -88,7 +88,7 @@ Notes: web developers are advised to use [`~` (tilde range)](https://github.com/ - 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) - (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) - Added feedback form for like/dislike button when `feedbackActionsPlacement` is `"activity-actions"`, in PR [#5460](https://github.com/microsoft/BotFramework-WebChat/pull/5460), PR [#5469](https://github.com/microsoft/BotFramework-WebChat/pull/5469), and PR [5470](https://github.com/microsoft/BotFramework-WebChat/pull/5470) by [@lexi-taylor](https://github.com/lexi-taylor) and [@OEvgeny](https://github.com/OEvgeny) - - ESCAPE key should reset the feedback form, in PR [#5480](https://github.com/microsoft/BotFramework-WebChat/pull/5480), by [@compulim](https://github.com/compulim) + - ESCAPE key should reset the feedback form, in PR [#5480](https://github.com/microsoft/BotFramework-WebChat/pull/5480), by [@compulim](https://github.com/compulim), in PR [#5493](https://github.com/microsoft/BotFramework-WebChat/pull/5493) by [@lexi-taylor](https://github.com/lexi-taylor) - Added multi-dimensional grouping, `styleOptions.groupActivitiesBy`, and `useGroupActivitiesByName` hook, in PR [#5471](https://github.com/microsoft/BotFramework-WebChat/pull/5471), by [@compulim](https://github.com/compulim) - Existing behavior will be kept and activities will be grouped by `sender` followed by `status` - `useGroupActivitiesByName` is favored over the existing `useGroupActivities` hook for performance reason diff --git a/__tests__/html2/feedbackForm/feedback.form.activity.html b/__tests__/html2/feedbackForm/feedback.form.activity.html index 7b721a27f4..ee3261fb09 100644 --- a/__tests__/html2/feedbackForm/feedback.form.activity.html +++ b/__tests__/html2/feedbackForm/feedback.form.activity.html @@ -90,11 +90,11 @@ document.querySelectorAll(`[data-testid="${testIds.feedbackButton}"]`)[0] ); - return await host.snapshot('local'); + // THEN: Should match snapshot. + await host.snapshot('local'); // WHEN: Click on dislike button to re-open feedback form - await host.sendTab(1); - await host.sendKeys('SPACE'); + await host.sendKeys('RIGHT', 'SPACE'); await pageConditions.became( 'feedback form is open', diff --git a/__tests__/html2/feedbackForm/feedback.form.activity.html.snap-3.png b/__tests__/html2/feedbackForm/feedback.form.activity.html.snap-3.png index e13278e784..44be021225 100644 Binary files a/__tests__/html2/feedbackForm/feedback.form.activity.html.snap-3.png and b/__tests__/html2/feedbackForm/feedback.form.activity.html.snap-3.png differ diff --git a/__tests__/html2/feedbackForm/feedback.form.activity.html.snap-4.png b/__tests__/html2/feedbackForm/feedback.form.activity.html.snap-4.png index 1b6392326f..42a37cb3c5 100644 Binary files a/__tests__/html2/feedbackForm/feedback.form.activity.html.snap-4.png and b/__tests__/html2/feedbackForm/feedback.form.activity.html.snap-4.png differ diff --git a/__tests__/html2/feedbackForm/feedback.form.emptyFeedback.html b/__tests__/html2/feedbackForm/feedback.form.emptyFeedback.html new file mode 100644 index 0000000000..6206c44935 --- /dev/null +++ b/__tests__/html2/feedbackForm/feedback.form.emptyFeedback.html @@ -0,0 +1,102 @@ + + + + + + + + + + +
+ + + diff --git a/__tests__/html2/feedbackForm/feedback.form.emptyFeedback.html.snap-1.png b/__tests__/html2/feedbackForm/feedback.form.emptyFeedback.html.snap-1.png new file mode 100644 index 0000000000..c83ddc5ea7 Binary files /dev/null and b/__tests__/html2/feedbackForm/feedback.form.emptyFeedback.html.snap-1.png differ diff --git a/packages/component/src/ActivityFeedback/private/getDisclaimerFromFeedbackLoop.ts b/packages/component/src/ActivityFeedback/private/getDisclaimerFromFeedbackLoop.ts index db23247918..b91da3e5db 100644 --- a/packages/component/src/ActivityFeedback/private/getDisclaimerFromFeedbackLoop.ts +++ b/packages/component/src/ActivityFeedback/private/getDisclaimerFromFeedbackLoop.ts @@ -3,7 +3,7 @@ import { type WebChatActivity } from 'botframework-webchat-core'; import { hasDisclaimer } from './hasFeedbackLoop'; /** - * @deprecated + * @deprecated This helper function should only use for patching the service. After patching, should use `getDisclaimerFromReviewAction` instead. */ export default function getDisclaimer(activity: WebChatActivity): string | undefined { return hasDisclaimer(activity) ? activity.channelData.feedbackLoop.disclaimer : undefined; diff --git a/packages/component/src/ActivityFeedback/private/hasFeedbackLoop.ts b/packages/component/src/ActivityFeedback/private/hasFeedbackLoop.ts index bfd7e2e8e7..8b490a364c 100644 --- a/packages/component/src/ActivityFeedback/private/hasFeedbackLoop.ts +++ b/packages/component/src/ActivityFeedback/private/hasFeedbackLoop.ts @@ -26,7 +26,7 @@ const feedbackLoopSchema = union([ type FeedbackActivity = WebChatActivity & InferOutput; /** - * @deprecated + * @deprecated This helper function should only use for patching the service. After patching, should use `getDisclaimerFormReviewAction` instead. */ export function hasDisclaimer( activity: WebChatActivity @@ -35,7 +35,7 @@ export function hasDisclaimer( } /** - * @deprecated + * @deprecated This helper function should only use for patching the service. After patching, should use `isActionRequireReview` instead. */ export default function hasFeedbackLoop(activity: WebChatActivity): activity is FeedbackActivity { return safeParse(feedbackLoopSchema, activity).success; diff --git a/packages/component/src/ActivityFeedback/providers/ActivityFeedbackComposer.tsx b/packages/component/src/ActivityFeedback/providers/ActivityFeedbackComposer.tsx index 364b01a242..61c2902833 100644 --- a/packages/component/src/ActivityFeedback/providers/ActivityFeedbackComposer.tsx +++ b/packages/component/src/ActivityFeedback/providers/ActivityFeedbackComposer.tsx @@ -1,11 +1,11 @@ import { hooks } from 'botframework-webchat-api'; -import { reactNode, validateProps } from 'botframework-webchat-react-valibot'; import { getOrgSchemaMessage, parseAction, type OrgSchemaAction, type WebChatActivity } from 'botframework-webchat-core'; +import { reactNode, validateProps } from 'botframework-webchat-react-valibot'; import random from 'math-random'; import React, { memo, useCallback, useMemo, useRef, useState, type Dispatch, type SetStateAction } from 'react'; import { wrapWith } from 'react-wrap-with'; @@ -19,6 +19,7 @@ import getDisclaimerFromFeedbackLoop from '../private/getDisclaimerFromFeedbackL import hasFeedbackLoop from '../private/hasFeedbackLoop'; import ActivityFeedbackContext, { type ActivityFeedbackContextType } from './private/ActivityFeedbackContext'; import { ActivityFeedbackFocusPropagationScope, usePropagateActivityFeedbackFocus } from './private/FocusPropagation'; +import isActionRequireReview from '../private/isActionRequireReview'; const { usePonyfill, usePostActivity } = hooks; @@ -220,7 +221,7 @@ function ActivityFeedbackComposer(props: ActivityFeedbackComposerProps) { const isLegacyAction = action['@type'] === 'VoteAction'; // TODO: We should update this to use W3C Hydra.1 - if (typeof feedbackText !== 'undefined') { + if (isActionRequireReview(action)) { postActivity({ name: 'message/submitAction', replyToId: activityRef.current.id, @@ -228,7 +229,7 @@ function ActivityFeedbackComposer(props: ActivityFeedbackComposerProps) { value: { actionName: 'feedback', actionValue: { - feedback: { feedbackText }, + feedback: { feedbackText: feedbackText || '' }, reaction: action['@type'] === 'LikeAction' ? 'like' : 'dislike' } }