-
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 adaptiveCardsParserMaxVersion style options (#3778)
- Loading branch information
Showing
6 changed files
with
120 additions
and
5 deletions.
There are no files selected for viewing
Binary file added
BIN
+9.46 KB
...-adaptive-cards-with-adaptive-cards-parser-max-version-style-options-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 added
BIN
+8.72 KB
...-adaptive-cards-with-adaptive-cards-parser-max-version-style-options-2-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 added
BIN
+9.46 KB
...-adaptive-cards-with-adaptive-cards-parser-max-version-style-options-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.
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,96 @@ | ||
<!DOCTYPE html> | ||
<html lang="en-US"> | ||
<head> | ||
<script crossorigin="anonymous" src="/__dist__/testharness.js"></script> | ||
<script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script> | ||
</head> | ||
<body> | ||
<div id="webchat"></div> | ||
<script type="text/babel" data-presets="env,stage-3,react"> | ||
const { | ||
conditions, | ||
createDirectLineWithTranscript, | ||
createStore, | ||
expect, | ||
host, | ||
pageObjects, | ||
timeouts, | ||
token, | ||
updateIn | ||
} = window.WebChatTest; | ||
|
||
const directLine = createDirectLineWithTranscript([ | ||
{ | ||
attachments: [ | ||
{ | ||
contentType: 'application/vnd.microsoft.card.adaptive', | ||
content: { | ||
type: 'AdaptiveCard', | ||
$schema: 'http://adaptivecards.io/schemas/adaptive-card.json', | ||
version: '1.3', | ||
body: [ | ||
{ | ||
type: 'Input.Text', | ||
placeholder: 'Placeholder text', | ||
isRequired: true, | ||
errorMessage: 'Error message', | ||
label: 'Label', | ||
id: 'id-1' | ||
} | ||
] | ||
} | ||
} | ||
], | ||
from: { | ||
id: 'bot', | ||
role: 'bot' | ||
}, | ||
id: '1', | ||
timestamp: new Date().toISOString(), | ||
type: 'message' | ||
} | ||
]); | ||
|
||
const store = createStore(); | ||
|
||
(async function () { | ||
function renderWebChatWithMaxVersion(adaptiveCardsParserMaxVersion) { | ||
window.WebChat.renderWebChat( | ||
{ | ||
directLine, | ||
store, | ||
styleOptions: { | ||
adaptiveCardsParserMaxVersion | ||
} | ||
}, | ||
document.getElementById('webchat') | ||
); | ||
} | ||
|
||
renderWebChatWithMaxVersion(); | ||
|
||
await pageObjects.wait(conditions.uiConnected(), timeouts.directLine); | ||
|
||
// When no maxVersion is specified, it should use the latest. | ||
// The screenshot should have the "Label" text. | ||
await host.snapshot(); | ||
|
||
// When maxVersion is specified, it should use that version. | ||
// The screenshot should not have the "Label" text, as it was introduced in 1.3. | ||
renderWebChatWithMaxVersion('1.2'); | ||
await host.snapshot(); | ||
|
||
// When maxVersion is specified but invalid, it should use the latest. | ||
// The screenshot should have the "Label" text. | ||
renderWebChatWithMaxVersion('x.y.z'); | ||
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 "adaptiveCardsParserMaxVersion" style options', () => | ||
runHTMLTest('adaptiveCards.parserMaxVersion.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