forked from microsoft/BotFramework-WebChat
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfeedback.form.emptyFeedback.html
More file actions
102 lines (89 loc) · 3.05 KB
/
feedback.form.emptyFeedback.html
File metadata and controls
102 lines (89 loc) · 3.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<!doctype html>
<html lang="en-US">
<head>
<link href="/assets/index.css" rel="stylesheet" type="text/css" />
<script crossorigin="anonymous" src="/test-harness.js"></script>
<script crossorigin="anonymous" src="/test-page-object.js"></script>
<script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script>
</head>
<body>
<main id="webchat"></main>
<script type="module">
run(async function () {
const {
WebChat: { renderWebChat, testIds }
} = window; // Imports in UMD fashion.
const { directLine, store } = testHelpers.createDirectLineEmulator();
renderWebChat(
{
directLine,
store,
styleOptions: { feedbackActionsPlacement: 'activity-actions' }
},
document.getElementById('webchat')
);
await pageConditions.uiConnected();
pageElements.byTestId(testIds.sendBoxTextBox).focus();
// GIVEN: An activity with feedback form.
await directLine.emulateIncomingActivity({
type: 'message',
id: 'a-00000',
timestamp: 0,
text: 'This is a test message to show feedback buttons',
from: {
role: 'bot'
},
locale: 'en-US',
entities: [],
channelData: {
feedbackLoop: {
type: 'default',
disclaimer: 'This is a test disclaimer message'
}
}
});
await pageConditions.numActivitiesShown(1);
// WHEN: Focus on the like button.
await host.sendShiftTab(3);
await host.sendKeys('ENTER', 'SPACE');
// THEN: The feedback form should be expanded.
await pageConditions.became(
'feedback form is open',
() => document.activeElement === pageElements.byTestId(testIds.feedbackSendBox),
1000
);
// WHEN: An empty feedback is being submitted.
const { activity } = await directLine.actPostActivity(async () => {
await host.sendTab(1);
await host.sendKeys('ENTER');
});
// THEN: Should post a "message/submitAction".
expect(activity).toEqual(
expect.objectContaining({
type: 'invoke',
name: 'message/submitAction',
value: {
actionName: 'feedback',
actionValue: {
reaction: 'like',
feedback: {
feedbackText: ''
}
}
}
})
);
// THEN: Feedback form should be collapsed.
await expect(pageElements.byTestId(testIds.feedbackSendBox)).toBeFalsy();
// THEN: All feedback buttons should be grayed out.
await expect(
Array.from(pageElements.allByTestId(testIds.feedbackButton)).every(
buttonElement => buttonElement.getAttribute('aria-disabled') === 'true'
)
).toBe(true);
// THEN: Should match snapshot.
await host.snapshot('local');
});
</script>
</body>
</html>