Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SITES-20282] Authors unable to select Excel and Word documents into dialog #2709

Merged
merged 2 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
fieldLabel="Download Asset"
fileNameParameter="./fileName"
fileReferenceParameter="./fileReference"
mimeTypes="[image/*,video/*,audio/*,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/pdf,application/zip,text/plain]"
mimeTypes="[image/*,video/*,audio/*,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/pdf,application/zip,text/plain,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet]"
name="./file"/>
</items>
</column>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@

public class DownloadIT extends com.adobe.cq.wcm.core.components.it.seljup.tests.download.v1.DownloadIT {

private static String assetDocumentFilter = "[name='assetfilter_document_path']";
private static String testAssetName = "core-comp-test-word.doc";
private static String testAssetWordPath = testAssetsPath + "/" + testAssetName;
private static final String assetDocumentFilter = "[name='assetfilter_document_path']";
private static final String testAssetWordName = "core-comp-test-word.doc";
private static final String testAssetWordPath = testAssetsPath + "/" + testAssetWordName;
private static final String testAssetXlsxName = "core-comp-test-xlsx.xlsx";
private static final String testAssetXlsxPath = testAssetsPath + "/" + testAssetXlsxName;

private void setupResources() {
downloadRT = RT_DOWNLOAD_V2;
Expand All @@ -55,21 +57,32 @@ public void setupBefore() throws Exception {

@Test
public void downloadWordFile() throws TimeoutException, InterruptedException, ClientException, URISyntaxException {
Header[] headers = getDownloadedFileHeaders(testAssetWordPath);
assertTrue(headers.length > 0);
assertEquals("attachment; filename=\"" + testAssetWordName + "\"", headers[0].getValue());
}

@Test
public void downloadXlsxFile() throws TimeoutException, InterruptedException, ClientException, URISyntaxException {
Header[] headers = getDownloadedFileHeaders(testAssetXlsxPath);
assertTrue(headers.length > 0);
assertEquals("attachment; filename=\"" + testAssetXlsxName + "\"", headers[0].getValue());
}

private Header[] getDownloadedFileHeaders (String testAssetPath) throws InterruptedException, TimeoutException, URISyntaxException, ClientException {
Commons.openSidePanel();
Commons.useDialogSelect("assetfilter_type_selector", "Documents");
Commons.selectInAutocomplete(assetDocumentFilter, testAssetsPath);
Commons.openEditDialog(editorPage, cmpPath);
DownloadEditDialog downloadEditDialog = download.getEditDialog();
downloadEditDialog.uploadAssetFromSidePanel(testAssetWordPath);
downloadEditDialog.uploadAssetFromSidePanel(testAssetPath);
Commons.saveConfigureDialog();
Commons.switchContext("ContentFrame");
Commons.webDriverWait(RequestConstants.WEBDRIVER_WAIT_TIME_MS);
String url = download.getDownloadTitleLink();
SlingClient slingClient = new SlingClient(new URI(url), authorClient.getUser(), authorClient.getPassword());
SlingHttpResponse response = slingClient.doGet(url, Collections.EMPTY_LIST, Collections.EMPTY_LIST, HttpStatus.SC_OK);
Header headers[] = response.getHeaders(HttpHeaders.CONTENT_DISPOSITION);
assertTrue(headers.length > 0);
assertEquals("attachment; filename=\"" + testAssetName + "\"", headers[0].getValue());
return response.getHeaders(HttpHeaders.CONTENT_DISPOSITION);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:dam="http://www.day.com/dam/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:mix="http://www.jcp.org/jcr/mix/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:dc="http://purl.org/dc/elements/1.1/"
jcr:mixinTypes="[mix:referenceable]"
jcr:primaryType="dam:Asset"
jcr:uuid="d59dfca8-2c84-4ea6-ba7d-c187b24440d3">
<jcr:content
dam:assetState="processed"
jcr:lastModified="{Date}2024-04-01T18:08:30.637+02:00"
jcr:lastModifiedBy="admin"
jcr:primaryType="dam:AssetContent">
<metadata
dam:Application="Microsoft Excel"
dam:AppVersion="{Decimal}14.0300"
dam:created="{Date}2017-08-03T11:50:33.000Z"
dam:DocSecurity="{Long}0"
dam:extracted="{Date}2024-04-01T18:08:30.599+02:00"
dam:modified="{Date}2017-08-04T11:27:53.000Z"
dam:revision="{Long}4"
dam:sha1="524d370df08e2543a52ddb5c907e017e0df12a42"
dam:size="{Long}8227"
dam:TotalTime="{Long}84507"
dc:format="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
dc:language="[en-US]"
dc:title="Test Xlsx"
dc:language_xmpArrayType="rdf:Bag"
jcr:mixinTypes="[cq:Taggable]"
jcr:primaryType="nt:unstructured"/>
<related jcr:primaryType="nt:unstructured"/>
</jcr:content>
</jcr:root>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:oak="http://jackrabbit.apache.org/oak/ns/1.0"
jcr:primaryType="nt:file">
<jcr:content
jcr:lastModifiedBy="admin"
jcr:mimeType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
jcr:primaryType="oak:Resource"/>
</jcr:root>
Loading