Skip to content

Commit 002c1e3

Browse files
committed
Firefly-2126: create test for metaConvert/vo related code
1 parent e47e539 commit 002c1e3

36 files changed

Lines changed: 8422 additions & 327 deletions

‎src/firefly/js/metaConvert/AnalysisUtils.js‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ const LOADING_MSG= 'Loading...';
1919
const gridEntryHasImages= (parts) => parts.find( (p) => p.type===FileAnalysisType.Image);
2020

2121

22-
23-
24-
2522
/**
2623
* create a function to analyze and show a data product
2724
* @param makeReq
@@ -39,7 +36,7 @@ export function makeAnalysisGetSingleDataProduct(makeReq) {
3936
export async function uploadAndAnalyze({request, table, row, activateParams, options, serviceDescMenuList, originalTitle}) {
4037
const ct= getObsCoreAccessFormat(table,row);
4138
const obsTitle= getObsTitle(table,row);
42-
if (!hasRowAccess(table, row)) dpdtSimpleMsg('You do not have access to this data.');
39+
if (!hasRowAccess(table, row)) return dpdtSimpleMsg('You do not have access to this data.');
4340
if (isNonServerAnalysisType(request?.getURL(), ct)) return doFileNameAndTypeAnalysis({url:request?.getURL(),ct, obsTitle});
4441
const analysisPromise = doUploadAndAnalysis({table, row, request, activateParams,
4542
options, originalTitle, serviceDescMenuList});
@@ -119,6 +116,7 @@ export function makeAnalysisGetGridDataProduct(makeReq) {
119116
* @param obj.request
120117
* @param obj.activateParams
121118
* @param obj.menuKey
119+
* @param obj.activeMenuLookupKey
122120
* @param {ServiceDescriptorDef} [obj.serDef]
123121
* @param {DatalinkData} [obj.dlData]
124122
* @param [obj.originalTitle]
@@ -153,7 +151,8 @@ export function makeAnalysisActivateFunc({table, row, request, activateParams,
153151
*/
154152
function dispatchResult(dpType, menu,menuKey,activeMenuLookupKey, dpId, serDef, analysisActivateFunc) {
155153
const modifiedResult= {...dpType, menu, menuKey, activeMenuLookupKey, serDef, analysisActivateFunc};
156-
if (dpType.displayType===DPtypes.MESSAGE) {
154+
const asIsTypes= [DPtypes.MESSAGE, DPtypes.PNG, DPtypes.TXT, DPtypes.DOWNLOAD];
155+
if (asIsTypes.includes(dpType.displayType)) {
157156
dispatchUpdateDataProducts(dpId, modifiedResult);
158157
}
159158
else if (dpType.displayType===DPtypes.SEND_TO_BROWSER) {
@@ -175,8 +174,10 @@ export const isNonServerAnalysisType= (url, ct) => Boolean(doFileNameAndTypeAnal
175174

176175
export function getExtensionFromUrl(url) {
177176
if (!url) return '';
178-
const i = url.lastIndexOf('.');
179-
if (i > 0 && i < url.length - 1) return url.substring(i+1).toLowerCase();
177+
const path= url.split(/[?#]/)[0]; // a dot in the query or fragment is not the extension
178+
const fileName= path.substring(path.lastIndexOf('/')+1);
179+
const i = fileName.lastIndexOf('.');
180+
if (i > 0 && i < fileName.length - 1) return fileName.substring(i+1).toLowerCase();
180181
return '';
181182
}
182183

@@ -264,7 +265,7 @@ export function makeGzipEntry(url,name,obsTitle) {
264265
}
265266

266267
export function makeAnyEntry(url,name, obsTitle) {
267-
const {title,dropDownText,message}= getBasicTitling(name,obsTitle,Format.GZIP);
268+
const {title,dropDownText,message}= getBasicTitling(name,obsTitle,Format.UNKNOWN);
268269
return dpdtDownload(title, url, 'download-0', 'unknown', { message, dropDownText, } );
269270
}
270271

0 commit comments

Comments
 (0)