-
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.
Fix ENTER/SPACEBAR on card with tapAction (#3197)
* Fix ENTER/SPACEBAR on card with tapAction * Add entry
- Loading branch information
Showing
15 changed files
with
211 additions
and
39 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
!/packages/bundle/dist | ||
!/packages/playground/build | ||
!/packages/testharness/dist | ||
!/serve-test.json |
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
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 |
---|---|---|
|
@@ -8,8 +8,9 @@ ENV PORT=80 | |
EXPOSE 80 | ||
RUN npm install [email protected] -g | ||
WORKDIR /web/ | ||
ENTRYPOINT ["npx", "--no-install", "serve", "-p", "80", "/web/__tests__/html/"] | ||
ENTRYPOINT ["npx", "--no-install", "serve", "-c", "serve-test.json", "-p", "80", "/web/"] | ||
|
||
ADD serve-test.json /web/ | ||
ADD __tests__/html/ /web/__tests__/html/ | ||
ADD packages/bundle/dist/webchat-es5.js /web/packages/bundle/dist/ | ||
ADD packages/testharness/dist/testharness.js /web/packages/testharness/dist/ |
Binary file added
BIN
+37.6 KB
...-cards-with-tap-action-prop-should-react-to-click-enter-and-spacebar-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.
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
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,113 @@ | ||
<!DOCTYPE html> | ||
<html lang="en-US"> | ||
<head> | ||
<script crossorigin="anonymous" src="/__dist__/testharness.js"></script> | ||
<script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script> | ||
<link href="focusManagement.css" rel="stylesheet" type="text/css" /> | ||
</head> | ||
<body> | ||
<div id="webchat"></div> | ||
<script type="text/babel" data-presets="env,stage-3,react"> | ||
const { | ||
conditions, | ||
createRunHookActivityMiddleware, | ||
createStore, | ||
expect, | ||
host, | ||
pageObjects, | ||
shareObservable, | ||
timeouts, | ||
token, | ||
updateIn | ||
} = window.WebChatTest; | ||
|
||
function stringToArrayBuffer(value) { | ||
// This assume the string is ASCII (0-127). | ||
|
||
const { length } = value; | ||
const byteArray = new Array(length); | ||
|
||
for (let index = 0; index < length; index++) { | ||
const charCode = value.charCodeAt(index); | ||
|
||
if (charCode > 127) { | ||
throw new Error('Only ASCII characters are supported.'); | ||
} | ||
|
||
byteArray[index] = charCode; | ||
} | ||
|
||
return new Uint8Array(byteArray).buffer; | ||
} | ||
|
||
(async function() { | ||
window.WebChat.renderWebChat( | ||
{ | ||
activityMiddleware: createRunHookActivityMiddleware(), | ||
directLine: window.WebChat.createDirectLine({ | ||
token: await token.fetchDirectLineToken() | ||
}), | ||
store: createStore() | ||
}, | ||
document.getElementById('webchat') | ||
); | ||
|
||
await pageObjects.wait(conditions.uiConnected(), timeouts.directLine); | ||
|
||
const fileBlob = new Blob([ | ||
stringToArrayBuffer( | ||
JSON.stringify( | ||
{ | ||
contentType: 'application/vnd.microsoft.card.hero', | ||
content: { | ||
tap: { | ||
type: 'imBack', | ||
value: 'Hello, World.' | ||
}, | ||
subtitle: | ||
'The first `imBack` is from mouse click. The second is from `ENTER` key. The third is from `SPACEBAR` key.', | ||
title: 'Tap on this card to say, "echo Hello, World."' | ||
} | ||
}, | ||
null, | ||
2 | ||
) | ||
) | ||
]); | ||
|
||
fileBlob.name = 'hello-card.attachmentjson'; | ||
|
||
await pageObjects.runHook(({ useSendFiles }) => useSendFiles()([fileBlob])); | ||
await pageObjects.wait(conditions.minNumActivitiesShown(2), timeouts.directLine); | ||
|
||
const renderer = document.querySelector('.webchat__adaptive-card-renderer'); | ||
const card = renderer.querySelector('.ac-adaptiveCard[tabindex="0"]'); | ||
|
||
expect(card).toBeTruthy(); | ||
|
||
renderer.click(); | ||
|
||
await pageObjects.wait(conditions.minNumActivitiesShown(4), timeouts.directLine); | ||
|
||
card.focus(); | ||
await host.sendKeys('\n'); | ||
|
||
await pageObjects.wait(conditions.minNumActivitiesShown(6), timeouts.directLine); | ||
|
||
card.focus(); | ||
await host.sendKeys(' '); | ||
|
||
await pageObjects.wait(conditions.minNumActivitiesShown(8), timeouts.directLine); | ||
|
||
await pageObjects.wait(conditions.scrollToBottomCompleted(), timeouts.scrollToBottom); | ||
await host.snapshot(); | ||
|
||
await host.done(); | ||
})().catch(async err => { | ||
console.error(err); | ||
|
||
await host.error(err); | ||
}); | ||
</script> | ||
</body> | ||
</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,8 @@ | ||
/** | ||
* @jest-environment ./__tests__/html/__jest__/WebChatEnvironment.js | ||
*/ | ||
|
||
describe('Adaptive Cards', () => { | ||
test('with "tapAction" prop should react to click, ENTER, and SPACEBAR', () => | ||
runHTMLTest('adaptiveCards.tapAction.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
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
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
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
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
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
10 changes: 2 additions & 8 deletions
10
packages/testharness/src/utils/createRunHookActivityMiddleware.js
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
Oops, something went wrong.