-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add code block copy button * Add tests and accessibility * Add snapshots * Add entry * Simpler tag name * Revert name * Move snapshot to local * Add Adaptive Cards test * Use pre-wrap * Change button to square * Fix tests * Move props to HTML attributes * Add test * Longer text * Move class outside * Add observed attributes * Cache observedAttributes * Change attribute name to "class" from "className" * Anonymous class * Add static * Add margin before button * Use inline-end * Use right * Fix tests * Fix screenshots * Fix screenshots * FIx screenshots * Fix screenshots * Fix tests * Update icon * Update icon * Simplify * Generalize custom element registration * Create React wrapper for custom element * No root element
- Loading branch information
Showing
62 changed files
with
1,254 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+724 Bytes
(100%)
...ive-cards-js-inputs-card-with-custom-style-options-and-submit-action-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+550 Bytes
(100%)
...s-should-show-response-from-bot-and-no-text-from-user-on-messageback-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+550 Bytes
(100%)
...s-js-should-show-response-from-bot-and-text-from-user-on-messageback-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+554 Bytes
(100%)
...ions-js-should-show-response-from-bot-and-text-from-user-on-postback-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+572 Bytes
(100%)
...ack-js-calling-send-message-back-should-send-a-message-back-activity-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+574 Bytes
(110%)
...post-back-js-calling-send-post-back-should-send-a-post-back-activity-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1.34 KB
(100%)
...-accessibility-requirement-disabling-adaptive-card-with-inputs-field-3-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+704 Bytes
(100%)
...-actions-shown-should-stick-to-bottom-if-submitting-an-adaptive-card-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+521 Bytes
(100%)
...operties-with-no-locale-is-sent-should-get-hello-and-welcome-message-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+801 Bytes
(110%)
...properties-with-locale-of-en-us-should-get-hello-and-welcome-message-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+521 Bytes
(100%)
...ies-with-locale-of-invalid-type-should-get-hello-and-welcome-message-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+687 Bytes
(110%)
...erties-with-non-existing-locale-should-get-hello-and-welcome-message-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+649 Bytes
(110%)
...ties-with-non-iso-format-locale-should-get-hello-and-welcome-message-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+646 Bytes
(110%)
...h-locale-of-zh-cn-should-get-hello-and-welcome-in-simplified-chinese-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+542 Bytes
(100%)
...rd-actions-js-hero-card-actions-message-back-display-text-text-value-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+537 Bytes
(100%)
...ots__/html/hero-card-actions-js-hero-card-actions-message-back-value-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+536 Bytes
(100%)
...apshots__/html/hero-card-actions-js-hero-card-actions-post-back-json-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+0 Bytes
(100%)
...tton-tab-order-js-scroll-to-end-button-should-have-correct-tab-order-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+4.75 KB
(100%)
...cript-activity-grouping-js-transcript-with-activity-grouping-test-43-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+647 Bytes
(100%)
...cript-activity-grouping-js-transcript-with-activity-grouping-test-44-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+528 Bytes
(100%)
...cript-activity-grouping-js-transcript-with-activity-grouping-test-46-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
133 changes: 133 additions & 0 deletions
133
__tests__/html2/markdown/codeBlockCopyButton/adaptiveCards/behavior.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
<!doctype html> | ||
<html lang="en-US"> | ||
<head> | ||
<link href="/assets/index.css" rel="stylesheet" type="text/css" /> | ||
<script crossorigin="anonymous" src="https://unpkg.com/@babel/standalone/babel.min.js"></script> | ||
<script crossorigin="anonymous" src="https://unpkg.com/[email protected]/umd/react.production.min.js"></script> | ||
<script crossorigin="anonymous" src="https://unpkg.com/[email protected]/umd/react-dom.production.min.js"></script> | ||
<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" style="position: relative"></main> | ||
<script type="text/babel"> | ||
run(async function () { | ||
await host.sendDevToolsCommand('Browser.setPermission', { | ||
permission: { name: 'clipboard-write' }, | ||
setting: 'granted' | ||
}); | ||
|
||
await expect(navigator.permissions.query({ name: 'clipboard-write' })).resolves.toHaveProperty( | ||
'state', | ||
'granted' | ||
); | ||
|
||
const { | ||
ReactDOM: { render }, | ||
WebChat: { ReactWebChat, testIds } | ||
} = window; // Imports in UMD fashion. | ||
|
||
const { directLine, store } = testHelpers.createDirectLineEmulator(); | ||
|
||
const App = () => ( | ||
<React.Fragment> | ||
<ReactWebChat directLine={directLine} store={store} /> | ||
<div style={{ gap: 8, position: 'absolute', top: 0, width: '100%' }}> | ||
<label> | ||
<div>Paste box</div> | ||
<textarea | ||
data-testid="paste box" | ||
spellCheck={false} | ||
style={{ background: '#f0f0f0', border: 0, height: 100, padding: 0, resize: 'none', width: '100%' }} | ||
/> | ||
</label> | ||
</div> | ||
</React.Fragment> | ||
); | ||
|
||
render(<App />, document.getElementById('webchat')); | ||
|
||
await pageConditions.uiConnected(); | ||
|
||
await directLine.emulateIncomingActivity({ | ||
attachments: [ | ||
{ | ||
content: { | ||
type: 'AdaptiveCard', | ||
$schema: 'http://adaptivecards.io/schemas/adaptive-card.json', | ||
version: '1.5', | ||
body: [ | ||
{ | ||
style: 'heading', | ||
type: 'TextBlock', | ||
text: 'This is an Adaptive Card' | ||
}, | ||
{ | ||
type: 'TextBlock', | ||
text: `Laboris ut proident dolore nisi sint ullamco proident veniam est. | ||
\`\`\` | ||
In do pariatur id enim nisi adipisicing incididunt consectetur do velit quis aliqua ad. | ||
Et proident est fugiat duis exercitation qui sunt amet ipsum. | ||
\`\`\` | ||
Ea sint elit anim enim voluptate aliquip aliqua nulla veniam. | ||
<pre> | ||
Ea et pariatur sint Lorem ex veniam adipisicing. | ||
Aliqua magna aliquip nisi quis. | ||
</pre> | ||
Cupidatat nulla duis dolor nulla ut pariatur minim incididunt quis adipisicing velit id Lorem.`, | ||
wrap: true | ||
} | ||
] | ||
}, | ||
contentType: 'application/vnd.microsoft.card.adaptive' | ||
} | ||
], | ||
type: 'message' | ||
}); | ||
|
||
await pageConditions.numActivitiesShown(1); | ||
|
||
// WHEN: Focus on the "Copy" button via keyboard. | ||
await host.click(document.querySelector(`[data-testid="${WebChat.testIds.sendBoxTextBox}"]`)); | ||
await host.sendShiftTab(3); | ||
await host.sendKeys('ENTER'); | ||
|
||
// THEN: Should focus on the "Copy" button | ||
const copyButton = document.querySelector(`[data-testid="${WebChat.testIds.codeBlockCopyButton}"]`); | ||
|
||
expect(document.activeElement).toBe(copyButton); | ||
await host.snapshot('local'); | ||
|
||
// WHEN: Press ENTER on the "Copy" button. | ||
await host.sendKeys('ENTER'); | ||
|
||
// THEN: The copy button should change to "Copied". | ||
await host.snapshot('local'); | ||
|
||
// WHEN: Paste into plain text and rich text text box. | ||
await host.click(document.querySelector('[data-testid="paste box"]')); | ||
await host.sendKeys('+CONTROL', 'v', '-CONTROL'); | ||
|
||
await host.click(document.querySelector(`[data-testid="${WebChat.testIds.sendBoxTextBox}"]`)); | ||
|
||
// Sleep for 1 second for the checkmark to go away. | ||
await testHelpers.sleep(500); | ||
|
||
// WHEN: Hiding Web Chat and showing it back. | ||
document.getElementById('webchat').style.display = 'none'; | ||
document.body.offsetWidth; // Need for browser to refresh the layout. | ||
document.getElementById('webchat').style.display = ''; | ||
|
||
// THEN: The "Copy" button should kept at normal. | ||
await host.snapshot('local'); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
Binary file added
BIN
+48.1 KB
...sts__/html2/markdown/codeBlockCopyButton/adaptiveCards/behavior.html.snap-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+48.3 KB
...sts__/html2/markdown/codeBlockCopyButton/adaptiveCards/behavior.html.snap-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+54.5 KB
...sts__/html2/markdown/codeBlockCopyButton/adaptiveCards/behavior.html.snap-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
87 changes: 87 additions & 0 deletions
87
__tests__/html2/markdown/codeBlockCopyButton/adaptiveCards/layout.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<!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> | ||
run(async function () { | ||
await host.sendDevToolsCommand('Browser.setPermission', { | ||
permission: { name: 'clipboard-write' }, | ||
setting: 'granted' | ||
}); | ||
|
||
await expect(navigator.permissions.query({ name: 'clipboard-write' })).resolves.toHaveProperty( | ||
'state', | ||
'granted' | ||
); | ||
|
||
const { | ||
WebChat: { renderWebChat, testIds } | ||
} = window; // Imports in UMD fashion. | ||
|
||
const { directLine, store } = testHelpers.createDirectLineEmulator(); | ||
|
||
renderWebChat({ directLine, store }, document.getElementById('webchat')); | ||
|
||
await pageConditions.uiConnected(); | ||
|
||
await directLine.emulateIncomingActivity({ | ||
attachments: [ | ||
{ | ||
content: { | ||
type: 'AdaptiveCard', | ||
$schema: 'http://adaptivecards.io/schemas/adaptive-card.json', | ||
version: '1.5', | ||
body: [ | ||
{ | ||
style: 'heading', | ||
type: 'TextBlock', | ||
text: 'This is an Adaptive Card' | ||
}, | ||
{ | ||
type: 'TextBlock', | ||
text: `Laboris ut proident dolore nisi sint ullamco proident veniam est. | ||
\`\`\` | ||
In do pariatur id enim nisi adipisicing incididunt consectetur do velit quis aliqua ad. | ||
Et proident est fugiat duis exercitation qui sunt amet ipsum. | ||
\`\`\` | ||
Ea sint elit anim enim voluptate aliquip aliqua nulla veniam. | ||
<pre> | ||
Ea et pariatur sint Lorem ex veniam adipisicing. | ||
Aliqua magna aliquip nisi quis. | ||
</pre> | ||
Cupidatat nulla duis dolor nulla ut pariatur minim incididunt quis adipisicing velit id Lorem.`, | ||
wrap: true | ||
} | ||
] | ||
}, | ||
contentType: 'application/vnd.microsoft.card.adaptive' | ||
} | ||
], | ||
type: 'message' | ||
}); | ||
|
||
await pageConditions.numActivitiesShown(1); | ||
|
||
// THEN: Should show 2 copy button, one for triple-backtick codeblock, one for <pre> codeblock. | ||
expect( | ||
pageElements.activities()[0].querySelectorAll(`[data-testid="${testIds.codeBlockCopyButton}"]`) | ||
).toHaveLength(2); | ||
|
||
await host.snapshot('local'); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
Binary file added
BIN
+47.1 KB
__tests__/html2/markdown/codeBlockCopyButton/adaptiveCards/layout.html.snap-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
103 changes: 103 additions & 0 deletions
103
__tests__/html2/markdown/codeBlockCopyButton/behavior.denied.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
<!doctype html> | ||
<html lang="en-US"> | ||
<head> | ||
<link href="/assets/index.css" rel="stylesheet" type="text/css" /> | ||
<script crossorigin="anonymous" src="https://unpkg.com/@babel/standalone/babel.min.js"></script> | ||
<script crossorigin="anonymous" src="https://unpkg.com/[email protected]/umd/react.production.min.js"></script> | ||
<script crossorigin="anonymous" src="https://unpkg.com/[email protected]/umd/react-dom.production.min.js"></script> | ||
<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" style="position: relative"></main> | ||
<script type="text/babel"> | ||
run(async function () { | ||
await host.sendDevToolsCommand('Browser.setPermission', { | ||
permission: { name: 'clipboard-write' }, | ||
setting: 'denied' | ||
}); | ||
|
||
await expect(navigator.permissions.query({ name: 'clipboard-write' })).resolves.toHaveProperty( | ||
'state', | ||
'denied' | ||
); | ||
|
||
const { | ||
ReactDOM: { render }, | ||
WebChat: { ReactWebChat, testIds } | ||
} = window; // Imports in UMD fashion. | ||
|
||
const { directLine, store } = testHelpers.createDirectLineEmulator(); | ||
|
||
const App = () => ( | ||
<React.Fragment> | ||
<ReactWebChat directLine={directLine} store={store} /> | ||
<div style={{ gap: 8, position: 'absolute', top: 0, width: '100%' }}> | ||
<label> | ||
<div>Paste box</div> | ||
<textarea | ||
data-testid="paste box" | ||
spellCheck={false} | ||
style={{ background: '#f0f0f0', border: 0, height: 100, padding: 0, resize: 'none', width: '100%' }} | ||
/> | ||
</label> | ||
</div> | ||
</React.Fragment> | ||
); | ||
|
||
render(<App />, document.getElementById('webchat')); | ||
|
||
await pageConditions.uiConnected(); | ||
|
||
await directLine.emulateIncomingActivity({ | ||
text: `Laboris ut proident dolore nisi sint ullamco proident veniam est. | ||
\`\`\` | ||
In do pariatur id enim nisi adipisicing incididunt consectetur do velit quis aliqua ad. | ||
Et proident est fugiat duis exercitation qui sunt amet ipsum. | ||
\`\`\` | ||
Ea sint elit anim enim voluptate aliquip aliqua nulla veniam. | ||
<pre> | ||
Ea et pariatur sint Lorem ex veniam adipisicing. | ||
Aliqua magna aliquip nisi quis. | ||
</pre> | ||
Cupidatat nulla duis dolor nulla ut pariatur minim incididunt quis adipisicing velit id Lorem.`, | ||
type: 'message' | ||
}); | ||
|
||
await pageConditions.numActivitiesShown(1); | ||
|
||
// WHEN: Focus on the "Copy" button via keyboard. | ||
await host.click(document.querySelector(`[data-testid="${testIds.sendBoxTextBox}"]`)); | ||
await host.sendShiftTab(3); | ||
await host.sendKeys('ENTER'); | ||
|
||
// THEN: Should focus on the "Copy" button | ||
const copyButton = document.querySelector(`[data-testid="${testIds.codeBlockCopyButton}"]`); | ||
|
||
expect(document.activeElement).toBe(copyButton); | ||
await host.snapshot('local'); | ||
|
||
// WHEN: Press ENTER on the "Copy" button. | ||
await host.sendKeys('ENTER'); | ||
|
||
// THEN: The copy button should be disabled. | ||
expect(copyButton.getAttribute('aria-disabled')).toBe('true'); | ||
await host.snapshot('local'); | ||
|
||
// WHEN: Press TAB twice. | ||
await host.sendTab(2); | ||
|
||
// THEN: It should stay on the second copy button. | ||
expect(document.activeElement).toBe(document.querySelectorAll(`[data-testid="${testIds.codeBlockCopyButton}"]`)[1]); | ||
await host.snapshot('local'); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
Binary file added
BIN
+43.7 KB
__tests__/html2/markdown/codeBlockCopyButton/behavior.denied.html.snap-1.png
Oops, something went wrong.
Binary file added
BIN
+43.7 KB
__tests__/html2/markdown/codeBlockCopyButton/behavior.denied.html.snap-2.png
Oops, something went wrong.
Binary file added
BIN
+43.7 KB
__tests__/html2/markdown/codeBlockCopyButton/behavior.denied.html.snap-3.png
Oops, something went wrong.
Oops, something went wrong.