diff --git a/src/data.ts b/src/data.ts index dac4eaa..ffa2fe7 100644 --- a/src/data.ts +++ b/src/data.ts @@ -225,7 +225,6 @@ function getReportData(request: GoogleAppsScript.Data_Studio.Request name)).join(','); } @@ -290,8 +291,8 @@ function getReportData(request: GoogleAppsScript.Data_Studio.Request { expect(result).toEqual(getExpectedResponse(result, 'data', 'Events.getName_withDateDimension_date')); }); + it('should correctly fetch a single column from a **.get API method', async () => { + let result = await Clasp.run('getData', { + configParams: { + idsite: env.APPSCRIPT_TEST_IDSITE, + report: JSON.stringify({ apiModule: 'API', apiAction: 'get' }), + filter_limit: 5, + }, + dateRange: { + startDate: DATE_TO_TEST, + endDate: DATE_TO_TEST, + }, + fields: [ + { name: 'bounce_rate' }, + ], + }); + expect(result).toEqual(getExpectedResponse(result, 'data', `API.get_singleProcessedMetric`)); + }); + it('should correctly fetch data for a date range spanning multiple days', async () => { await Clasp.run('setScriptProperties', {}, true); diff --git a/tests/appscript/expected/data_API.get_singleProcessedMetric.json b/tests/appscript/expected/data_API.get_singleProcessedMetric.json new file mode 100644 index 0000000..d70c703 --- /dev/null +++ b/tests/appscript/expected/data_API.get_singleProcessedMetric.json @@ -0,0 +1,22 @@ +{ + "filtersApplied": false, + "rows": [ + { + "values": [ + "0.73" + ] + } + ], + "schema": [ + { + "dataType": "NUMBER", + "label": "Bounce Rate", + "name": "bounce_rate", + "semantics": { + "conceptType": "METRIC", + "isReaggregatable": false, + "semanticType": "PERCENT" + } + } + ] +} \ No newline at end of file