From 3bcef87e0a13c9fea873dc8090ae6559a0f53673 Mon Sep 17 00:00:00 2001 From: Zhongnan Su Date: Thu, 24 Jun 2021 09:41:38 -0700 Subject: [PATCH] Remove dependency on demo.elastic and use local mock html for testing (#100) --- .../utils/__tests__/demo_dashboard.html | 9874 +++++++++++++++++ .../__tests__/visualReportHelper.test.ts | 9 +- 2 files changed, 9878 insertions(+), 5 deletions(-) create mode 100644 dashboards-reports/server/routes/utils/__tests__/demo_dashboard.html diff --git a/dashboards-reports/server/routes/utils/__tests__/demo_dashboard.html b/dashboards-reports/server/routes/utils/__tests__/demo_dashboard.html new file mode 100644 index 00000000..ab3b160c --- /dev/null +++ b/dashboards-reports/server/routes/utils/__tests__/demo_dashboard.html @@ -0,0 +1,9874 @@ + + +[eCommerce] Revenue Dashboard - OpenSearch
+
+

+

Dashboard panel: [eCommerce] Markdown[eCommerce] Markdown

Sample eCommerce Data

+

This dashboard contains sample data for you to play with. You can view it, search it, and interact with the visualizations. For more information about OpenSearch Dashboards, check our docs.

+

Dashboard panel: [eCommerce] Controls[eCommerce] Controls

Dashboard panel: [eCommerce] Sold Products per Day[eCommerce] Sold Products per Day

Trxns / day
149

Dashboard panel: [eCommerce] Sales by Gender[eCommerce] Sales by Gender

FEMALE (52.89%)MALE (47.11%)

Dashboard panel: [eCommerce] Average Sales Price[eCommerce] Average Sales Price

$74.62per order
average spend

Dashboard panel: [eCommerce] Average Sold Quantity[eCommerce] Average Sold Quantity

2.124per order
average items

Dashboard panel: [eCommerce] Total Revenue[eCommerce] Total Revenue

$78,725.49

Dashboard panel: [eCommerce] Sales by Category[eCommerce] Sales by Category

Sum of total_quantity020406080100
2021-06-17 12:002021-06-18 12:002021-06-19 12:002021-06-20 12:002021-06-21 12:002021-06-22 12:002021-06-23 12:00order_date per 3 hours

Dashboard panel: [eCommerce] Promotion Tracking[eCommerce] Promotion Tracking

  • Revenue Trousers
    $71
  • Revenue Watches
    $239
  • Revenue Bags
    $1,055.781
  • Revenue Cocktail Dresses
    $483.969

Dashboard panel: [eCommerce] Sales Count Map[eCommerce] Sales Count Map

Dashboard panel: [eCommerce] Top Selling Products[eCommerce] Top Selling Products

Lace-up boots - blackAnkle boots - blackBoots - blackPrint T-shirt - blackJumper - blackLace-up boots - resin coffeeDress with Defined Waist

Dashboard panel: [eCommerce] Orders[eCommerce] Orders

+
+
+
+ + +
1–50 of 1055
+
+
+
+
+ + + + + +
Timecategoryskutaxful_total_pricetotal_quantity
+ +Jun 23, 2021 @ 23:56:10.000
Women's Accessories, Women's Clothing
ZO0301903019, ZO0049800498
$43.98
2
+ +Jun 23, 2021 @ 23:41:46.000
Men's Clothing
ZO0128701287, ZO0577005770
$49.98
2
+ +Jun 23, 2021 @ 23:37:26.000
Men's Clothing
ZO0558005580, ZO0276502765
$18.98
2
+ +Jun 23, 2021 @ 23:33:07.000
Women's Accessories, Women's Clothing
ZO0358803588, ZO0179601796
$91.98
2
+ +Jun 23, 2021 @ 23:21:36.000
Men's Clothing
ZO0543605436, ZO0425604256
$89.98
2
+ +Jun 23, 2021 @ 23:21:36.000
Men's Clothing
ZO0629306293, ZO0578405784
$37.98
2
+ +Jun 23, 2021 @ 22:51:22.000
Men's Clothing
ZO0291602916, ZO0292302923
$221.98
2
+ +Jun 23, 2021 @ 22:48:29.000
Women's Clothing, Women's Accessories
ZO0262902629, ZO0358703587
$83.98
2
+ +Jun 23, 2021 @ 22:29:46.000
Men's Clothing
ZO0474604746, ZO0111701117
$36.98
2
+ +Jun 23, 2021 @ 22:12:29.000
Men's Accessories, Men's Shoes
ZO0598005980, ZO0681706817
$75.98
2
+ +Jun 23, 2021 @ 22:11:02.000
Women's Clothing, Women's Shoes
ZO0221402214, ZO0677006770
$103.98
2
+ +Jun 23, 2021 @ 21:59:31.000
Men's Clothing, Men's Shoes
ZO0579905799, ZO0386403864
$55.98
2
+ +Jun 23, 2021 @ 21:55:12.000
Men's Clothing
ZO0474204742, ZO0574005740
$31.98
2
+ +Jun 23, 2021 @ 21:48:00.000
Men's Clothing, Men's Shoes
ZO0580905809, ZO0507105071
$41.98
2
+ +Jun 23, 2021 @ 21:23:31.000
Women's Clothing
ZO0217002170, ZO0164201642
$27.98
2
+ +Jun 23, 2021 @ 21:17:46.000
Women's Shoes, Women's Clothing
ZO0368003680, ZO0173001730
$63.98
2
+ +Jun 23, 2021 @ 21:12:00.000
Men's Clothing
ZO0437404374, ZO0293102931
$24.98
2
+ +Jun 23, 2021 @ 21:09:07.000
Women's Accessories, Women's Shoes
ZO0085300853, ZO0678506785
$95.98
2
+ +Jun 23, 2021 @ 20:56:10.000
Women's Clothing, Women's Shoes
ZO0638706387, ZO0677206772
$92.98
2
+ +Jun 23, 2021 @ 20:41:46.000
Women's Shoes, Women's Clothing
ZO0678406784, ZO0712707127
$99.98
2
+ +Jun 23, 2021 @ 20:37:26.000
Women's Clothing
ZO0708107081, ZO0500905009
$42.98
2
+ +Jun 23, 2021 @ 20:33:07.000
Women's Shoes
ZO0250002500, ZO0675406754
$159.98
2
+ +Jun 23, 2021 @ 20:24:29.000
Women's Accessories
ZO0205602056, ZO0356903569
$46.98
2
+ +Jun 23, 2021 @ 20:00:00.000
Men's Clothing
ZO0441304413, ZO0561205612
$22.98
2
+ +Jun 23, 2021 @ 19:55:41.000
Men's Shoes, Men's Clothing
ZO0691306913, ZO0275502755
$139.98
2
+ +Jun 23, 2021 @ 19:32:38.000
Men's Clothing
ZO0295102951, ZO0453304533, ZO0588305883, ZO0411304113
$82.96
4
+ +Jun 23, 2021 @ 19:19:41.000
Men's Clothing, Men's Accessories
ZO0296402964, ZO0316203162
$42.98
2
+ +Jun 23, 2021 @ 19:18:14.000
Men's Clothing, Men's Shoes
ZO0588005880, ZO0571805718, ZO0403504035, ZO0457504575
$108.96
4
+ +Jun 23, 2021 @ 19:15:22.000
Women's Clothing
ZO0051800518, ZO0333303333
$92.98
2
+ +Jun 23, 2021 @ 19:06:43.000
Men's Clothing, Men's Shoes
ZO0431904319, ZO0683606836
$149.98
2
+ +Jun 23, 2021 @ 19:05:17.000
Women's Clothing, Women's Accessories
ZO0181701817, ZO0095300953
$45.98
2
+ +Jun 23, 2021 @ 18:58:05.000
Men's Clothing
ZO0620606206, ZO0454204542
$70.98
2
+ +Jun 23, 2021 @ 18:40:48.000
Women's Shoes, Women's Accessories
ZO0670906709, ZO0211302113
$128.98
2
+ +Jun 23, 2021 @ 18:30:43.000
Women's Clothing
ZO0263002630, ZO0497904979
$93.98
2
+ +Jun 23, 2021 @ 18:27:50.000
Men's Clothing, Men's Shoes
ZO0300603006, ZO0123501235, ZO0399803998, ZO0624206242
$160.96
4
+ +Jun 23, 2021 @ 18:13:26.000
Women's Accessories, Women's Shoes
ZO0696806968, ZO0020700207
$66.98
2
+ +Jun 23, 2021 @ 18:03:22.000
Women's Clothing, Women's Accessories
ZO0271302713, ZO0703207032
$74.98
2
+ +Jun 23, 2021 @ 18:00:29.000
Men's Shoes, Men's Accessories
ZO0403504035, ZO0608606086
$91.98
2
+ +Jun 23, 2021 @ 17:46:05.000
Men's Shoes, Men's Clothing
ZO0521405214, ZO0585905859
$64.98
2
+ +Jun 23, 2021 @ 17:31:41.000
Women's Clothing
ZO0171101711, ZO0048400484
$74.98
2
+ +Jun 23, 2021 @ 17:28:48.000
Women's Accessories
ZO0209302093, ZO0087400874
$47.98
2
+ +Jun 23, 2021 @ 17:27:22.000
Women's Accessories
ZO0096100961, ZO0091000910
$53.98
2
+ +Jun 23, 2021 @ 17:04:19.000
Men's Clothing
ZO0284802848, ZO0581605816
$49.98
2
+ +Jun 23, 2021 @ 17:02:53.000
Men's Shoes
ZO0401004010, ZO0257802578
$119.98
2
+ +Jun 23, 2021 @ 16:51:22.000
Men's Shoes, Men's Accessories
ZO0520705207, ZO0397603976, ZO0395003950, ZO0702307023
$207.96
4
+ +Jun 23, 2021 @ 16:49:55.000
Women's Shoes, Women's Clothing
ZO0364403644, ZO0150401504
$116.98
2
+ +Jun 23, 2021 @ 16:31:12.000
Men's Clothing, Women's Accessories
ZO0554505545, ZO0703407034
$96.98
2
+ +Jun 23, 2021 @ 16:25:26.000
Women's Clothing
ZO0263002630
$51.99
1
+ +Jun 23, 2021 @ 16:02:24.000
Women's Shoes
ZO0365203652, ZO0383303833
$126.98
2
+ +Jun 23, 2021 @ 16:00:58.000
Women's Clothing
ZO0179701797, ZO0496004960
$42.98
2
+
+ + +
+ + + +
+ +
+ +
+
\ No newline at end of file diff --git a/dashboards-reports/server/routes/utils/__tests__/visualReportHelper.test.ts b/dashboards-reports/server/routes/utils/__tests__/visualReportHelper.test.ts index e4bda647..ff2aca0b 100644 --- a/dashboards-reports/server/routes/utils/__tests__/visualReportHelper.test.ts +++ b/dashboards-reports/server/routes/utils/__tests__/visualReportHelper.test.ts @@ -62,7 +62,7 @@ const input = { configIds: [], title: 'title', textDescription: 'text description', - htmlDescription: 'html description' + htmlDescription: 'html description', }, trigger: { trigger_type: 'On demand', @@ -70,8 +70,7 @@ const input = { }, }; -const queryUrl = - 'https://demo.elastic.co/app/kibana#/dashboard/welcome_dashboard'; +const mockHtmlPath = `file://${__dirname}/demo_dashboard.html`; describe('test create visual report', () => { test('create report with valid input', async () => { @@ -84,7 +83,7 @@ describe('test create visual report', () => { const reportParams = input.report_definition.report_params; const { dataUrl, fileName } = await createVisualReport( reportParams as ReportParamsSchemaType, - queryUrl, + mockHtmlPath, mockLogger ); expect(fileName).toContain(`${reportParams.report_name}`); @@ -99,7 +98,7 @@ describe('test create visual report', () => { const { dataUrl, fileName } = await createVisualReport( reportParams as ReportParamsSchemaType, - queryUrl, + mockHtmlPath, mockLogger ); expect(fileName).toContain(`${reportParams.report_name}`);