From 95d2792a226a3d8560191888f5f7bc0bac55d96c Mon Sep 17 00:00:00 2001 From: William Wong Date: Fri, 28 Feb 2020 11:37:19 -0800 Subject: [PATCH] Add download attribute --- __tests__/fileAttachment.js | 13 +++++++++++++ packages/component/src/Attachment/FileContent.js | 1 + 2 files changed, 14 insertions(+) diff --git a/__tests__/fileAttachment.js b/__tests__/fileAttachment.js index feb080ced9..e441fd20ac 100644 --- a/__tests__/fileAttachment.js +++ b/__tests__/fileAttachment.js @@ -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 () => { @@ -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(); }); diff --git a/packages/component/src/Attachment/FileContent.js b/packages/component/src/Attachment/FileContent.js index c4e197192b..c78850383d 100644 --- a/packages/component/src/Attachment/FileContent.js +++ b/packages/component/src/Attachment/FileContent.js @@ -90,6 +90,7 @@ const FileContent = ({ className, href, fileName, size }) => {