Skip to content

Commit

Permalink
Add download attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
compulim committed Feb 28, 2020
1 parent 3eb19da commit 95d2792
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions __tests__/fileAttachment.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,21 @@ test('show ZIP files with contentUrl', async () => {
document.querySelector('[role="listitem"]:nth-child(1) a[target="_blank"]').getAttribute('href')
)
).resolves.toEqual('https://example.org/');
await expect(
driver.executeScript(() =>
document.querySelector('[role="listitem"]:nth-child(1) a[target="_blank"]').getAttribute('download')
)
).resolves.toEqual('empty.zip');
await expect(
driver.executeScript(() =>
document.querySelector('[role="listitem"]:nth-child(2) a[target="_blank"]').getAttribute('href')
)
).resolves.toEqual('https://example.org/');
await expect(
driver.executeScript(() =>
document.querySelector('[role="listitem"]:nth-child(2) a[target="_blank"]').getAttribute('download')
)
).resolves.toEqual('empty.zip');
});

test('show ZIP files without contentUrl', async () => {
Expand Down Expand Up @@ -111,4 +121,7 @@ test('show ZIP files without contentUrl', async () => {
await expect(
driver.executeScript(() => !!document.querySelector('[role="listitem"]:nth-child(2) a'))
).resolves.toBeFalsy();
await expect(
driver.executeScript(() => !!document.querySelector('[role="listitem"]:nth-child(1) a'))
).resolves.toBeFalsy();
});
1 change: 1 addition & 0 deletions packages/component/src/Attachment/FileContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ const FileContent = ({ className, href, fileName, size }) => {
<a
aria-hidden={true}
className="webchat__fileContent__buttonLink"
download={fileName}
href={href}
rel="noopener noreferrer"
target="_blank"
Expand Down

0 comments on commit 95d2792

Please sign in to comment.