Skip to content

Commit

Permalink
Merge branch 'main' into feat-sequence-id
Browse files Browse the repository at this point in the history
  • Loading branch information
compulim authored Apr 7, 2022
2 parents 81881be + 6a5359f commit dc12441
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Fixed

- Fixes [#4102](https://github.com/microsoft/BotFramework-WebChat/issues/4102). Fixed `cldr-data-downloader` package not working properly on Windows, by [@compulim](https://github.com/compulim) in PR [#4223](https://github.com/microsoft/BotFramework-WebChat/pull/4223)
- Fixes [#4232](https://github.com/microsoft/BotFramework-WebChat/issues/4232). Added `blob:` to allowed protocol list for file attachment UI (`<FileContent>`), by [@compulim](https://github.com/compulim) in PR [#4233](https://github.com/microsoft/BotFramework-WebChat/pull/4233)
- Fixes [#4204](https://github.com/microsoft/BotFramework-WebChat/issues/4204). Sort using `activity.channelData['webchat:sequence-id']` and fallback to epoch time of `activity.timestamp`, by [@compulim](https://github.com/compulim), in PR [#4203](https://github.com/microsoft/BotFramework-WebChat/pull/4203)

### Changed
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 44 additions & 0 deletions __tests__/html/attachment.fileContent.blobURL.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<!DOCTYPE html>
<html lang="en-US">
<head>
<link href="/assets/index.css" rel="stylesheet" type="text/css" />
<script crossorigin="anonymous" src="https://unpkg.com/react@17.0.2/umd/react.production.min.js"></script>
<script crossorigin="anonymous" src="https://unpkg.com/react-dom@17.0.2/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>
<div id="webchat"></div>
<script>
run(async function () {
const {
Components: { Composer, FileContent }
} = WebChat;

// TODO: [P2] #2869 When the "DLJS patching code" is being moved to DLJS, we should use standard Web Chat setup, instead of composition mode.
// SETUP: Web Chat using composition mode because the logic which talk to DLJS will strip out blob:// URL.
ReactDOM.render(
React.createElement(
Composer,
{
directLine: testHelpers.createDirectLineWithTranscript(),
store: testHelpers.createStore()
},
React.createElement(FileContent, {
fileName: 'blob.txt',
href: URL.createObjectURL(new Blob())
})
),
document.getElementById('webchat')
);

// WHEN: <FileContent href="blob:http://..." /> is being displayed.
await pageConditions.uiConnected();

// THEN: The attachment should have a download icon which means the attachment is downloadable.
await host.snapshot();
});
</script>
</body>
</html>
3 changes: 3 additions & 0 deletions __tests__/html/attachment.fileContent.blobURL.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/** @jest-environment ./packages/test/harness/src/host/jest/WebDriverEnvironment.js */

test('File attachment with blob URL should be downloadable', () => runHTML('attachment.fileContent.blobURL.html'));
2 changes: 1 addition & 1 deletion packages/component/src/Attachment/FileContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const ROOT_STYLE = {
}
};

const ALLOWED_PROTOCOLS = ['data:', 'http:', 'https:'];
const ALLOWED_PROTOCOLS = ['blob:', 'data:', 'http:', 'https:'];

function isAllowedProtocol(url) {
try {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit dc12441

Please sign in to comment.