-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#3453 Fixes plain text file attachments to show download link when up…
…loaded (#3711) * Add test for uploading .txt attachment * Update CHANGELOG.md * Update CHANGELOG.md * Fix breaking tests * Clean up * Update packages/component/src/Middleware/AttachmentForScreenReader/createCoreMiddleware.js Co-authored-by: William Wong <compulim@users.noreply.github.com> * Linting fixes from previous PR * More linting fixes from previous PR * Fix logic and add tests Co-authored-by: William Wong <compulim@users.noreply.github.com>
- Loading branch information
Showing
19 changed files
with
199 additions
and
20 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 added
BIN
+15.2 KB
.../__image_snapshots__/chrome-docker/upload-js-upload-a-txt-plain-file-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
+9.75 KB
...tachment-url-js-text-url-attachment-sent-from-bot-should-be-rendered-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
+10 KB
.../send-files-text-files-js-text-file-sent-from-bot-should-be-rendered-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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<!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 { | ||
WebChatTest: { | ||
conditions, | ||
createDirectLineWithTranscript, | ||
createStore, | ||
getConsoleHistory, | ||
host, | ||
pageObjects, | ||
timeouts, | ||
token | ||
} | ||
} = window; | ||
|
||
(async function () { | ||
window.WebChat.renderWebChat( | ||
{ | ||
directLine: createDirectLineWithTranscript([ | ||
{ | ||
type: 'message', | ||
id: 'CONVERSATION_ID-o|00000', | ||
timestamp: '2000-01-23T12:34:56.12345Z', | ||
channelId: 'directline', | ||
from: { | ||
id: 'webchat-mockbot', | ||
name: 'webchat-mockbot' | ||
}, | ||
conversation: { | ||
id: 'CONVERSATION_ID-o' | ||
}, | ||
locale: 'en-US', | ||
attachments: [ | ||
{ | ||
contentUrl: 'Hello, World!', | ||
contentType: 'text/plain', | ||
name: 'test.txt' | ||
} | ||
] | ||
} | ||
]), | ||
sendTypingIndicator: true, | ||
store: createStore() | ||
}, | ||
document.getElementById('webchat') | ||
); | ||
|
||
await pageObjects.wait(conditions.uiConnected(), timeouts.directLine); | ||
await pageObjects.wait(conditions.numActivitiesShown(1), timeouts.directLine); | ||
|
||
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,7 @@ | ||
/** | ||
* @jest-environment ./__tests__/html/__jest__/WebChatEnvironment.js | ||
*/ | ||
|
||
describe('text url attachment sent from bot should be rendered', () => { | ||
test('', () => runHTMLTest('sendFiles.attachmentUrl.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,67 @@ | ||
<!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 { | ||
WebChatTest: { | ||
conditions, | ||
createDirectLineWithTranscript, | ||
createStore, | ||
getConsoleHistory, | ||
host, | ||
pageObjects, | ||
timeouts, | ||
token | ||
} | ||
} = window; | ||
|
||
(async function () { | ||
window.WebChat.renderWebChat( | ||
{ | ||
directLine: createDirectLineWithTranscript([ | ||
{ | ||
type: 'message', | ||
id: 'CONVERSATION_ID-o|00000', | ||
timestamp: '2000-01-23T12:34:56.12345Z', | ||
channelId: 'directline', | ||
from: { | ||
id: 'webchat-mockbot', | ||
name: 'webchat-mockbot' | ||
}, | ||
conversation: { | ||
id: 'CONVERSATION_ID-o' | ||
}, | ||
locale: 'en-US', | ||
attachments: [ | ||
{ | ||
content: 'Hello, World!', | ||
contentType: 'text/plain', | ||
name: 'test.txt' | ||
} | ||
] | ||
} | ||
]), | ||
sendTypingIndicator: true, | ||
store: createStore() | ||
}, | ||
document.getElementById('webchat') | ||
); | ||
|
||
await pageObjects.wait(conditions.uiConnected(), timeouts.directLine); | ||
await pageObjects.wait(conditions.numActivitiesShown(1), timeouts.directLine); | ||
|
||
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,7 @@ | ||
/** | ||
* @jest-environment ./__tests__/html/__jest__/WebChatEnvironment.js | ||
*/ | ||
|
||
describe('text file sent from bot should be rendered', () => { | ||
test('', () => runHTMLTest('sendFiles.textFiles.html')); | ||
}); |
Empty file.
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
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