Skip to content
This repository has been archived by the owner on Aug 9, 2022. It is now read-only.

Commit

Permalink
Fix CSV Test Cases (#62)
Browse files Browse the repository at this point in the history
Fix CSV test suite with the pre-requisites needed to pass data report test cases
  • Loading branch information
davidcui1225 authored Aug 26, 2020
1 parent 9c9df14 commit 3cdf5a5
Show file tree
Hide file tree
Showing 13 changed files with 470 additions and 95 deletions.
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
},
"dependencies": {
"@babel/core": "^7.10.2",
"@babel/parser": "^7.11.4",
"@elastic/elasticsearch": "^7.8.0",
"@elastic/eui": "^26.0.0",
"@testing-library/jest-dom": "^5.10.1",
Expand All @@ -32,6 +33,7 @@
"@types/react": "^16.9.36",
"@types/react-dom": "^16.9.8",
"@types/react-test-renderer": "^16.9.2",
"axios": "^0.20.0",
"babel-polyfill": "^6.26.0",
"jest-cli": "^26.0.1",
"jest-dom": "^4.0.0",
Expand Down Expand Up @@ -64,6 +66,7 @@
"@kbn/plugin-helpers": "link:../../packages/kbn-plugin-helpers",
"babel-eslint": "^10.0.1",
"babel-jest": "^26.0.1",
"elastic-builder": "^2.7.1",
"eslint": "^5.16.0",
"eslint-plugin-babel": "^5.3.0",
"eslint-plugin-import": "^2.16.0",
Expand All @@ -74,9 +77,8 @@
"eslint-plugin-prefer-object-spread": "^1.2.1",
"eslint-plugin-react": "^7.12.4",
"jest": "^26.0.1",
"json-2-csv": "^3.7.6",
"prettier": "2.0.5",
"react-test-renderer": "^16.13.1",
"elastic-builder": "^2.7.1",
"json-2-csv": "^3.7.6"
"react-test-renderer": "^16.13.1"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export function ReportSettings(props) {
target: { value: React.SetStateAction<string> };
}) => {
setDashboardSourceSelect(e.target.value);
createReportDefinitionRequest['report_params']['url'] =
createReportDefinitionRequest['report_params']['url'] =
getDashboardBaseUrl() + e.target.value;
};

Expand Down Expand Up @@ -398,7 +398,7 @@ export function ReportSettings(props) {
let baseUrl = window.location.href;
return baseUrl.replace(
'opendistro_kibana_reports#/create',
'dashboards#/view/'
'kibana#/dashboard/'
);
};

Expand All @@ -412,7 +412,8 @@ export function ReportSettings(props) {
await handleDashboards(dashboardOptions);
await setDashboardSourceSelect(dashboardOptions[0].value);
createReportDefinitionRequest['report_params']['url'] =
getDashboardBaseUrl() + response['hits']['hits'][0]['_id'].substring(10);
getDashboardBaseUrl() +
response['hits']['hits'][0]['_id'].substring(10);
})
.catch((error) => {
console.log('error when fetching dashboards:', error);
Expand Down
10 changes: 0 additions & 10 deletions server/routes/dataReport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,11 @@ export default function (router: IRouter) {
includeDefaults: true,
}
);

const default_max_size: number =
settings[indexPattern].defaults.index.max_result_window;

//build the ES Count query
const countReq = buildQuery(report, 1);

//Count the Data in ES
const esCount = await context.core.elasticsearch.adminClient.callAsInternalUser(
'count',
Expand Down Expand Up @@ -129,14 +127,6 @@ export default function (router: IRouter) {
rows = nbRows;
nbScroll = Math.floor(nbRows / default_max_size);
}
// let data = {
// esData,
// rows,
// nbScroll,
// fetch_size,
// report,
// reqBody,
// };

for (let i = 0; i < nbScroll - 1; i++) {
let resScroll = await context.core.elasticsearch.adminClient.callAsInternalUser(
Expand Down
14 changes: 7 additions & 7 deletions server/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@
* permissions and limitations under the License.
*/

import registerReportRoute from './report';
import registerVisualReportRoute from './visualReport';
import registerReportDefinitionRoute from './reportDefinition';
import registerDataReport from './dataReport';
import registerDataReportMetadata from './dataReportMetadata';
import dashboardRoute from './getDashboards';
import registerDashboardRoute from './getDashboards';
import { IRouter } from '../../../../src/core/server';

export default function (router: IRouter) {
registerReportRoute(router);
registerReportDefinitionRoute(router);
registerDataReportMetadata(router);
registerDataReport(router);
dashboardRoute(router);
registerVisualReportRoute(router);
registerReportDefinitionRoute(router);
registerDataReportMetadata(router);
registerDataReport(router);
registerDashboardRoute(router);
}
Loading

0 comments on commit 3cdf5a5

Please sign in to comment.