From fec1fe268251dbc460c8faf506d9cd419bfcaaf7 Mon Sep 17 00:00:00 2001 From: Sean Li Date: Mon, 28 Aug 2023 16:23:14 -0700 Subject: [PATCH] adding tests for query error Signed-off-by: Sean Li --- .../__snapshots__/result_grid.test.tsx.snap | 3000 +++++++++++++++++ .../__test__/result_grid.test.tsx | 23 + test/constants.ts | 9 + 3 files changed, 3032 insertions(+) diff --git a/public/components/query_compare/search_result/result_components/__test__/__snapshots__/result_grid.test.tsx.snap b/public/components/query_compare/search_result/result_components/__test__/__snapshots__/result_grid.test.tsx.snap index 204ce7b..1b46fdc 100644 --- a/public/components/query_compare/search_result/result_components/__test__/__snapshots__/result_grid.test.tsx.snap +++ b/public/components/query_compare/search_result/result_components/__test__/__snapshots__/result_grid.test.tsx.snap @@ -2467,3 +2467,3003 @@ exports[`Result grid component Renders result grid component 1`] = ` `; + +exports[`Result panel query error Displays error message on query error 1`] = ` + + + <_EuiSplitPanelInner + className="search-relevance-result-panel" + > + +
+ +
+ +
+ +

+ Result 1 +

+
+
+
+ +
+ +

+ 10 + results +

+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ +

+ 1 +

+
+
+
+ +
+ +
+ + Not applicable + + + + Not in + + Results + 2 + + + } + size="m" + type="questionInCircle" + > + + Not in + + Results + 2 + + + } + delay="regular" + position="top" + > + + + + + + + + + + + +
+
+
+
+
+
+
+
+ +
+
+ arr: +
+
+ + ["el1","el2","el3"] + + +
+
+ id: +
+
+ + 3920564 + + +
+
+ name: +
+
+ + 006R90321 + + +
+
+ title: +
+
+ + Xerox 006R90321 toner cartridge Original Black 6 pc(s) + + +
+
+ short_description: +
+
+ + Toner (6 Per Box) for CopyCentre C65 Digital Copier + + +
+
+ img_500x500: +
+
+ + http://images.icecat.biz/img/gallery_mediums/img_3920564_medium_1472618727_1445_7091.jpg + + +
+
+ date_released: +
+
+ + 2009-12-10T00:00:00Z + + +
+
+ supplier: +
+
+ + Xerox + + +
+
+ price: +
+
+ + 4995 + + +
+
+
+
+
+ +
+ +
+ +

+ 2 +

+
+
+
+ +
+ +
+ + Not applicable + + + + Not in + + Results + 2 + + + } + size="m" + type="questionInCircle" + > + + Not in + + Results + 2 + + + } + delay="regular" + position="top" + > + + + + + + + + + + + +
+
+
+
+
+
+
+
+ +
+
+ nestObj: +
+
+ + {"key1":[1,true,null],"key2":{"key21":"element"}} + + +
+
+ id: +
+
+ + 2101957 + + +
+
+ name: +
+
+ + dv7-1211ea + + +
+
+ title: +
+
+ + HP Pavilion dv7-1211ea Notebook Silver 43.2 cm (17") 1440 x 900 pixels Intel® Core™2 Duo 4 GB DDR2-SDRAM 250 GB HDD NVIDIA® GeForce® 9200M GS Windows Vista Home Premium + + +
+
+ short_description: +
+
+ + Intel Core 2 Duo Processor P7450 (3M Cache, 2.13 GHz, 1066 MHz FSB), 4GB DDR2, 250GB SATA HDD, 17" WXGA+ HD BrightView 1440 x 900, nVidia GeForce 9200M GS, DVD Super Multi DL, Gigabit Ethernet, WLAN 802.11 b/g, WebCam, Windows Vista Home Premium 32-bit + + +
+
+ img_500x500: +
+
+ + http://images.icecat.biz/img/gallery_mediums/2101957_8011415648.jpg + + +
+
+ date_released: +
+
+ + 2008-12-19T00:00:00Z + + +
+
+ supplier: +
+
+ + HP + + +
+
+ price: +
+
+ + 10995 + + +
+
+ attr_t_product_colour: +
+
+ + Silver + + +
+
+
+
+
+ +
+ +
+ +

+ 3 +

+
+
+
+ +
+ +
+ + Not applicable + + + + Not in + + Results + 2 + + + } + size="m" + type="questionInCircle" + > + + Not in + + Results + 2 + + + } + delay="regular" + position="top" + > + + + + + + + + + + + +
+
+
+
+
+
+
+
+ +
+
+ id: +
+
+ + 1128895 + + +
+
+ name: +
+
+ + DB9 RS232 Serial Null Modem Adapter - M/F + + +
+
+ title: +
+
+ + StarTech.com DB9 RS232 Serial Null Modem Adapter - M/F + + +
+
+ short_description: +
+
+ + StarTech.com DB9 RS232 Serial Null Modem Adapter - M/F + + +
+
+ img_500x500: +
+
+ + http://images.icecat.biz/img/gallery_mediums/1128895_4034494654.jpg + + +
+
+ date_released: +
+
+ + 2007-08-09T00:00:00Z + + +
+
+ supplier: +
+
+ + StarTech.com + + +
+
+ price: +
+
+ + 595 + + +
+
+ attr_t_product_colour: +
+
+ + Grey + + +
+
+
+
+
+ +
+ +
+ +

+ 4 +

+
+
+
+ +
+ +
+ + Not applicable + + + + Not in + + Results + 2 + + + } + size="m" + type="questionInCircle" + > + + Not in + + Results + 2 + + + } + delay="regular" + position="top" + > + + + + + + + + + + + +
+
+
+
+
+
+
+
+ +
+
+ id: +
+
+ + 1449722 + + +
+
+ name: +
+
+ + ProCurve 420 Wireless Access Point + + +
+
+ title: +
+
+ + HP ProCurve 420 Wireless Access Point + + +
+
+ short_description: +
+
+ + Refurbished A FULL-FEATURED IEEE 802.11G SINGLE-RADIO ACCESS POINT IDEALLY + + +
+
+ img_500x500: +
+
+ + http://images.icecat.biz/img/gallery_mediums/img_1449722_medium_1480997766_6498_5955.jpg + + +
+
+ date_released: +
+
+ + 2008-03-07T00:00:00Z + + +
+
+ supplier: +
+
+ + HP + + +
+
+ price: +
+
+ + 9495 + + +
+
+
+
+
+ +
+ +
+ +

+ 5 +

+
+
+
+ +
+ +
+ + Not applicable + + + + Not in + + Results + 2 + + + } + size="m" + type="questionInCircle" + > + + Not in + + Results + 2 + + + } + delay="regular" + position="top" + > + + + + + + + + + + + +
+
+
+
+
+
+
+
+ +
+
+ id: +
+
+ + 1625640 + + +
+
+ name: +
+
+ + 2GB SD Card + + +
+
+ title: +
+
+ + Integral 2GB SD Card memory card + + +
+
+ short_description: +
+
+ + 2GB SD Card + + +
+
+ img_500x500: +
+
+ + http://images.icecat.biz/img/gallery_mediums/img_1625640_medium_1480990774_7102_6217.jpg + + +
+
+ date_released: +
+
+ + 2008-06-23T00:00:00Z + + +
+
+ supplier: +
+
+ + Integral + + +
+
+ price: +
+
+ + 1195 + + +
+
+
+
+
+ +
+ +
+ +

+ 6 +

+
+
+
+ +
+ +
+ + Not applicable + + + + Not in + + Results + 2 + + + } + size="m" + type="questionInCircle" + > + + Not in + + Results + 2 + + + } + delay="regular" + position="top" + > + + + + + + + + + + + +
+
+
+
+
+
+
+
+ +
+
+ id: +
+
+ + 2067378 + + +
+
+ name: +
+
+ + LC51C + + +
+
+ title: +
+
+ + Brother LC51C Original Cyan + + +
+
+ short_description: +
+
+ + LC51C + + +
+
+ img_500x500: +
+
+ + http://images.icecat.biz/img/gallery_mediums/img_2067378_medium_1481020819_0464_12184.jpg + + +
+
+ date_released: +
+
+ + 2009-04-08T00:00:00Z + + +
+
+ supplier: +
+
+ + Brother + + +
+
+ price: +
+
+ + 1795 + + +
+
+
+
+
+ +
+ +
+ +

+ 7 +

+
+
+
+ +
+ +
+ + Not applicable + + + + Not in + + Results + 2 + + + } + size="m" + type="questionInCircle" + > + + Not in + + Results + 2 + + + } + delay="regular" + position="top" + > + + + + + + + + + + + +
+
+
+
+
+
+
+
+ +
+
+ id: +
+
+ + 636678 + + +
+
+ name: +
+
+ + Emergency Power Off (EPO) + + +
+
+ title: +
+
+ + APC Emergency Power Off (EPO) + + +
+
+ short_description: +
+
+ + Emergency Power Off (EPO) + + +
+
+ img_500x500: +
+
+ + http://images.icecat.biz/img/gallery_mediums/img_636678_medium_1480944064_4778_26509.jpg + + +
+
+ date_released: +
+
+ + 2006-11-15T00:00:00Z + + +
+
+ supplier: +
+
+ + APC + + +
+
+ price: +
+
+ + 69195 + + +
+
+ attr_t_product_colour: +
+
+ + Black + + +
+
+
+
+
+ +
+ +
+ +

+ 8 +

+
+
+
+ +
+ +
+ + Not applicable + + + + Not in + + Results + 2 + + + } + size="m" + type="questionInCircle" + > + + Not in + + Results + 2 + + + } + delay="regular" + position="top" + > + + + + + + + + + + + +
+
+
+
+
+
+
+
+ +
+
+ id: +
+
+ + 1570809 + + +
+
+ name: +
+
+ + IT Power Distribution Module 3 Pole 5 Wire 32A IEC309 620cm + + +
+
+ title: +
+
+ + APC IT Power Distribution Module 3 Pole 5 Wire 32A IEC309 620cm power distribution unit (PDU) + + +
+
+ short_description: +
+
+ + IT Power Distribution Module 3 Pole 5 Wire 32A IEC309 620cm + + +
+
+ img_500x500: +
+
+ + http://images.icecat.biz/img/gallery_mediums/img_1570809_medium_1480983343_7059_6217.jpg + + +
+
+ date_released: +
+
+ + 2008-04-11T00:00:00Z + + +
+
+ supplier: +
+
+ + APC + + +
+
+ price: +
+
+ + 53895 + + +
+
+
+
+
+ +
+ +
+ +

+ 9 +

+
+
+
+ +
+ +
+ + Not applicable + + + + Not in + + Results + 2 + + + } + size="m" + type="questionInCircle" + > + + Not in + + Results + 2 + + + } + delay="regular" + position="top" + > + + + + + + + + + + + +
+
+
+
+
+
+
+
+ +
+
+ id: +
+
+ + 148843 + + +
+
+ name: +
+
+ + Labels Premium A4 64.6x33.8 mm white paper matt 2400 pcs. + + +
+
+ title: +
+
+ + HERMA Labels Premium A4 64.6x33.8 mm white paper matt 2400 pcs. + + +
+
+ short_description: +
+
+ + Labels Premium A4 64.6x33.8 mm white paper matt 2400 pcs. + + +
+
+ img_500x500: +
+
+ + http://images.icecat.biz/img/gallery_mediums/148843_2449.jpg + + +
+
+ date_released: +
+
+ + 2005-07-15T00:00:00Z + + +
+
+ supplier: +
+
+ + HERMA + + +
+
+ price: +
+
+ + 3795 + + +
+
+ attr_t_product_colour: +
+
+ + White + + +
+
+
+
+
+ +
+ +
+ +

+ 10 +

+
+
+
+ +
+ +
+ + Not applicable + + + + Not in + + Results + 2 + + + } + size="m" + type="questionInCircle" + > + + Not in + + Results + 2 + + + } + delay="regular" + position="top" + > + + + + + + + + + + + +
+
+
+
+
+
+
+
+ +
+
+ id: +
+
+ + 968447 + + +
+
+ name: +
+
+ + Cyan Toner Cartridge for C7100/C7300/C7500 Series 'Type C4' + + +
+
+ title: +
+
+ + OKI Cyan Toner Cartridge for C7100/C7300/C7500 Series 'Type C4' Original + + +
+
+ short_description: +
+
+ + Cyan Toner Cartridge for C7100/C7300/C7500 Series 'Type C4' + + +
+
+ img_500x500: +
+
+ + http://images.icecat.biz/img/gallery_mediums/img_968447_medium_1480985748_8727_5647.jpg + + +
+
+ date_released: +
+
+ + 2007-08-09T00:00:00Z + + +
+
+ supplier: +
+
+ + OKI + + +
+
+ price: +
+
+ + 20395 + + +
+
+
+
+
+
+
+
+
+ +
+
+`; diff --git a/public/components/query_compare/search_result/result_components/__test__/result_grid.test.tsx b/public/components/query_compare/search_result/result_components/__test__/result_grid.test.tsx index 4a8b689..86008af 100644 --- a/public/components/query_compare/search_result/result_components/__test__/result_grid.test.tsx +++ b/public/components/query_compare/search_result/result_components/__test__/result_grid.test.tsx @@ -11,8 +11,10 @@ import { ResultGridComponent } from '../result_grid'; import { TEST_QUERY_RESPONSE, TEST_COMPARED_DOCUMENTS_RANK, + TEST_QUERY_ERROR, } from '../../../../../../test/constants'; import { SearchRelevanceContextProvider } from '../../../../../contexts'; +import { ResultPanel } from '../result_panel'; describe('Result grid component', () => { configure({ adapter: new Adapter() }); @@ -34,3 +36,24 @@ describe('Result grid component', () => { }); }); }); + +describe('Result panel query error', () => { + configure({ adapter: new Adapter() }); + it('Displays error message on query error', async () => { + const wrapper = mount( + + + + ); + + wrapper.update(); + + await waitFor(() => { + expect(wrapper).toMatchSnapshot(); + }); + }); +}); diff --git a/test/constants.ts b/test/constants.ts index 80e7126..1cafce1 100644 --- a/test/constants.ts +++ b/test/constants.ts @@ -3,6 +3,8 @@ * SPDX-License-Identifier: Apache-2.0 */ +import { QueryError } from '../public/types'; + export const TEST_SEARCH_TEXT = 'basic'; export const TEST_QUERY_RESPONSE = { @@ -200,3 +202,10 @@ export const TEST_COMPARED_DOCUMENTS_RANK = { }; export const TEST_QUERY_STRING = '{}'; + +export const TEST_QUERY_ERROR: QueryError = { + selectIndex: '', + queryString: 'error', + statusCode: 400, + body: 'Error: parsing_exception - Unknown key for a VALUE_STRING in [this].', +};