Skip to content

Commit 138146b

Browse files
committed
Fix test
1 parent 58c6f7e commit 138146b

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

__tests__/html/focusManagement.disableHeroCard.obsolete.html

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="en-US">
33
<head>
44
<link href="/assets/index.css" rel="stylesheet" type="text/css" />
@@ -15,14 +15,29 @@
1515
<script type="text/babel" data-presets="env,stage-3,react">
1616
const {
1717
WebChat: {
18-
Components: { HeroCardContent }
18+
Components: { HeroCardContent },
19+
hooks: { useActivities }
1920
}
2021
} = window;
2122

2223
run(async function () {
2324
const store = testHelpers.createStore();
2425
const directLine = WebChat.createDirectLine({ token: await testHelpers.token.fetchDirectLineToken() });
2526

27+
const AutoDisableHeroCardContent = ({ activity, attachment }) => {
28+
const [activities] = useActivities();
29+
const messageActivities = activities.filter(activity => activity.type === 'message');
30+
const isMostRecentMessageActivity = messageActivities.pop() === activity;
31+
32+
return (
33+
<HeroCardContent
34+
actionPerformedClassName="card__action--performed"
35+
content={attachment.content}
36+
disabled={!isMostRecentMessageActivity}
37+
/>
38+
);
39+
};
40+
2641
WebChat.renderWebChat(
2742
{
2843
attachmentMiddleware:
@@ -35,13 +50,7 @@
3550
const mostRecent = messageActivities.pop() === activity;
3651

3752
if (attachment.contentType === 'application/vnd.microsoft.card.hero') {
38-
return (
39-
<HeroCardContent
40-
actionPerformedClassName="card__action--performed"
41-
content={attachment.content}
42-
disabled={!mostRecent}
43-
/>
44-
);
53+
return <AutoDisableHeroCardContent activity={activity} attachment={attachment} />;
4554
}
4655

4756
return next(...args);

0 commit comments

Comments
 (0)