From 9576fde657f18909c437d8b78a1d11fbcaf9bf32 Mon Sep 17 00:00:00 2001 From: Devin Hurley Date: Fri, 23 Jun 2023 12:40:47 -0400 Subject: [PATCH] add snapshot test --- .../__snapshots__/index.test.tsx.snap | 604 ++++++++++++++++++ .../components/query_bar/index.test.tsx | 125 +--- 2 files changed, 605 insertions(+), 124 deletions(-) create mode 100644 x-pack/plugins/security_solution/public/common/components/query_bar/__snapshots__/index.test.tsx.snap diff --git a/x-pack/plugins/security_solution/public/common/components/query_bar/__snapshots__/index.test.tsx.snap b/x-pack/plugins/security_solution/public/common/components/query_bar/__snapshots__/index.test.tsx.snap new file mode 100644 index 0000000000000..de2b59e10b41e --- /dev/null +++ b/x-pack/plugins/security_solution/public/common/components/query_bar/__snapshots__/index.test.tsx.snap @@ -0,0 +1,604 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`QueryBar check if we format the appropriate props to QueryBar 1`] = ` +Object { + "dataTestSubj": undefined, + "dateRangeFrom": "now/d", + "dateRangeTo": "now/d", + "displayStyle": undefined, + "filters": Array [], + "indexPatterns": Array [ + DataView { + "allowNoIndex": false, + "deleteFieldFormat": [Function], + "fieldAttrs": Object {}, + "fieldFormatMap": Object { + "deserialize": [MockFunction], + "getByFieldType": [MockFunction], + "getDefaultConfig": [MockFunction], + "getDefaultInstance": [MockFunction], + "getDefaultInstanceCacheResolver": [MockFunction], + "getDefaultInstancePlain": [MockFunction], + "getDefaultType": [MockFunction], + "getDefaultTypeName": [MockFunction], + "getInstance": [MockFunction], + "getType": [MockFunction], + "getTypeNameByEsTypes": [MockFunction], + "getTypeWithoutMetaParams": [MockFunction], + "has": [MockFunction], + "init": [MockFunction], + "parseDefaultTypeMap": [MockFunction], + "register": [MockFunction], + }, + "fieldFormats": Object {}, + "fields": FldList [ + Object { + "aggregatable": true, + "conflictDescriptions": undefined, + "count": 10, + "customLabel": undefined, + "esTypes": Array [ + "long", + ], + "lang": undefined, + "name": "bytes", + "readFromDocValues": true, + "script": undefined, + "scripted": false, + "searchable": true, + "subType": undefined, + "type": "number", + }, + Object { + "aggregatable": true, + "conflictDescriptions": undefined, + "count": 20, + "customLabel": undefined, + "esTypes": Array [ + "boolean", + ], + "lang": undefined, + "name": "ssl", + "readFromDocValues": true, + "script": undefined, + "scripted": false, + "searchable": true, + "subType": undefined, + "type": "boolean", + }, + Object { + "aggregatable": true, + "conflictDescriptions": undefined, + "count": 30, + "customLabel": undefined, + "esTypes": Array [ + "date", + ], + "lang": undefined, + "name": "@timestamp", + "readFromDocValues": true, + "script": undefined, + "scripted": false, + "searchable": true, + "subType": undefined, + "type": "date", + }, + Object { + "aggregatable": true, + "conflictDescriptions": undefined, + "count": 30, + "customLabel": undefined, + "esTypes": Array [ + "date", + ], + "lang": undefined, + "name": "time", + "readFromDocValues": true, + "script": undefined, + "scripted": false, + "searchable": true, + "subType": undefined, + "type": "date", + }, + Object { + "aggregatable": true, + "conflictDescriptions": undefined, + "count": 0, + "customLabel": undefined, + "esTypes": Array [ + "keyword", + ], + "lang": undefined, + "name": "@tags", + "readFromDocValues": true, + "script": undefined, + "scripted": false, + "searchable": true, + "subType": undefined, + "type": "string", + }, + Object { + "aggregatable": true, + "conflictDescriptions": undefined, + "count": 0, + "customLabel": undefined, + "esTypes": Array [ + "date", + ], + "lang": undefined, + "name": "utc_time", + "readFromDocValues": true, + "script": undefined, + "scripted": false, + "searchable": true, + "subType": undefined, + "type": "date", + }, + Object { + "aggregatable": true, + "conflictDescriptions": undefined, + "count": 0, + "customLabel": undefined, + "esTypes": Array [ + "integer", + ], + "lang": undefined, + "name": "phpmemory", + "readFromDocValues": true, + "script": undefined, + "scripted": false, + "searchable": true, + "subType": undefined, + "type": "number", + }, + Object { + "aggregatable": true, + "conflictDescriptions": undefined, + "count": 0, + "customLabel": undefined, + "esTypes": Array [ + "ip", + ], + "lang": undefined, + "name": "ip", + "readFromDocValues": true, + "script": undefined, + "scripted": false, + "searchable": true, + "subType": undefined, + "type": "ip", + }, + Object { + "aggregatable": true, + "conflictDescriptions": undefined, + "count": 0, + "customLabel": undefined, + "esTypes": Array [ + "attachment", + ], + "lang": undefined, + "name": "request_body", + "readFromDocValues": true, + "script": undefined, + "scripted": false, + "searchable": true, + "subType": undefined, + "type": "attachment", + }, + Object { + "aggregatable": true, + "conflictDescriptions": undefined, + "count": 0, + "customLabel": undefined, + "esTypes": Array [ + "geo_point", + ], + "lang": undefined, + "name": "point", + "readFromDocValues": true, + "script": undefined, + "scripted": false, + "searchable": true, + "subType": undefined, + "type": "geo_point", + }, + Object { + "aggregatable": true, + "conflictDescriptions": undefined, + "count": 0, + "customLabel": undefined, + "esTypes": Array [ + "geo_shape", + ], + "lang": undefined, + "name": "area", + "readFromDocValues": true, + "script": undefined, + "scripted": false, + "searchable": true, + "subType": undefined, + "type": "geo_shape", + }, + Object { + "aggregatable": false, + "conflictDescriptions": undefined, + "count": 0, + "customLabel": undefined, + "esTypes": Array [ + "murmur3", + ], + "lang": undefined, + "name": "hashed", + "readFromDocValues": false, + "script": undefined, + "scripted": false, + "searchable": true, + "subType": undefined, + "type": "murmur3", + }, + Object { + "aggregatable": true, + "conflictDescriptions": undefined, + "count": 0, + "customLabel": undefined, + "esTypes": Array [ + "geo_point", + ], + "lang": undefined, + "name": "geo.coordinates", + "readFromDocValues": true, + "script": undefined, + "scripted": false, + "searchable": true, + "subType": undefined, + "type": "geo_point", + }, + Object { + "aggregatable": true, + "conflictDescriptions": undefined, + "count": 0, + "customLabel": undefined, + "esTypes": Array [ + "keyword", + ], + "lang": undefined, + "name": "extension", + "readFromDocValues": true, + "script": undefined, + "scripted": false, + "searchable": true, + "subType": undefined, + "type": "string", + }, + Object { + "aggregatable": true, + "conflictDescriptions": undefined, + "count": 0, + "customLabel": undefined, + "esTypes": Array [ + "text", + ], + "lang": undefined, + "name": "machine.os", + "readFromDocValues": false, + "script": undefined, + "scripted": false, + "searchable": true, + "subType": undefined, + "type": "string", + }, + Object { + "aggregatable": true, + "conflictDescriptions": undefined, + "count": 0, + "customLabel": undefined, + "esTypes": Array [ + "keyword", + ], + "lang": undefined, + "name": "machine.os.raw", + "readFromDocValues": true, + "script": undefined, + "scripted": false, + "searchable": true, + "subType": Object { + "multi": Object { + "parent": "machine.os", + }, + }, + "type": "string", + }, + Object { + "aggregatable": true, + "conflictDescriptions": undefined, + "count": 0, + "customLabel": undefined, + "esTypes": Array [ + "keyword", + ], + "lang": undefined, + "name": "geo.src", + "readFromDocValues": true, + "script": undefined, + "scripted": false, + "searchable": true, + "subType": undefined, + "type": "string", + }, + Object { + "aggregatable": true, + "conflictDescriptions": undefined, + "count": 0, + "customLabel": undefined, + "esTypes": Array [ + "_id", + ], + "lang": undefined, + "name": "_id", + "readFromDocValues": false, + "script": undefined, + "scripted": false, + "searchable": true, + "subType": undefined, + "type": "string", + }, + Object { + "aggregatable": true, + "conflictDescriptions": undefined, + "count": 0, + "customLabel": undefined, + "esTypes": Array [ + "_type", + ], + "lang": undefined, + "name": "_type", + "readFromDocValues": false, + "script": undefined, + "scripted": false, + "searchable": true, + "subType": undefined, + "type": "string", + }, + Object { + "aggregatable": true, + "conflictDescriptions": undefined, + "count": 0, + "customLabel": undefined, + "esTypes": Array [ + "_source", + ], + "lang": undefined, + "name": "_source", + "readFromDocValues": false, + "script": undefined, + "scripted": false, + "searchable": true, + "subType": undefined, + "type": "_source", + }, + Object { + "aggregatable": true, + "conflictDescriptions": undefined, + "count": 0, + "customLabel": undefined, + "esTypes": Array [ + "text", + ], + "lang": undefined, + "name": "non-filterable", + "readFromDocValues": false, + "script": undefined, + "scripted": false, + "searchable": false, + "subType": undefined, + "type": "string", + }, + Object { + "aggregatable": false, + "conflictDescriptions": undefined, + "count": 0, + "customLabel": undefined, + "esTypes": Array [ + "text", + ], + "lang": undefined, + "name": "non-sortable", + "readFromDocValues": false, + "script": undefined, + "scripted": false, + "searchable": false, + "subType": undefined, + "type": "string", + }, + Object { + "aggregatable": true, + "conflictDescriptions": undefined, + "count": 0, + "customLabel": undefined, + "esTypes": Array [ + "long", + "text", + ], + "lang": undefined, + "name": "custom_user_field", + "readFromDocValues": true, + "script": undefined, + "scripted": false, + "searchable": true, + "subType": undefined, + "type": "conflict", + }, + Object { + "aggregatable": true, + "conflictDescriptions": undefined, + "count": 0, + "customLabel": undefined, + "esTypes": undefined, + "lang": "expression", + "name": "script string", + "readFromDocValues": false, + "script": "'i am a string'", + "scripted": true, + "searchable": true, + "subType": undefined, + "type": "string", + }, + Object { + "aggregatable": true, + "conflictDescriptions": undefined, + "count": 0, + "customLabel": undefined, + "esTypes": undefined, + "lang": "expression", + "name": "script number", + "readFromDocValues": false, + "script": "1234", + "scripted": true, + "searchable": true, + "subType": undefined, + "type": "number", + }, + Object { + "aggregatable": true, + "conflictDescriptions": undefined, + "count": 0, + "customLabel": undefined, + "esTypes": undefined, + "lang": "painless", + "name": "script date", + "readFromDocValues": false, + "script": "1234", + "scripted": true, + "searchable": true, + "subType": undefined, + "type": "date", + }, + Object { + "aggregatable": true, + "conflictDescriptions": undefined, + "count": 0, + "customLabel": undefined, + "esTypes": undefined, + "lang": "expression", + "name": "script murmur3", + "readFromDocValues": false, + "script": "1234", + "scripted": true, + "searchable": true, + "subType": undefined, + "type": "murmur3", + }, + Object { + "aggregatable": false, + "conflictDescriptions": undefined, + "count": 0, + "customLabel": undefined, + "esTypes": Array [ + "text", + ], + "lang": undefined, + "name": "nestedField.child", + "readFromDocValues": false, + "script": undefined, + "scripted": false, + "searchable": true, + "subType": Object { + "nested": Object { + "path": "nestedField", + }, + }, + "type": "string", + }, + Object { + "aggregatable": false, + "conflictDescriptions": undefined, + "count": 0, + "customLabel": undefined, + "esTypes": Array [ + "text", + ], + "lang": undefined, + "name": "nestedField.nestedChild.doublyNestedChild", + "readFromDocValues": false, + "script": undefined, + "scripted": false, + "searchable": true, + "subType": Object { + "nested": Object { + "path": "nestedField.nestedChild", + }, + }, + "type": "string", + }, + Object { + "aggregatable": false, + "conflictDescriptions": Object { + "text": Array [ + ".siem-signals-default-000001", + ".siem-signals-default-000002", + ".siem-signals-default-000011", + ".siem-signals-default-000012", + ], + "unmapped": Array [ + ".siem-signals-default-000004", + ".siem-signals-default-000005", + ".siem-signals-default-000240", + ], + }, + "count": 0, + "customLabel": undefined, + "esTypes": Array [ + "text", + "unmapped", + ], + "lang": undefined, + "name": "mapping issues", + "readFromDocValues": false, + "script": undefined, + "scripted": false, + "searchable": true, + "subType": undefined, + "type": "conflict", + }, + ], + "flattenHit": [Function], + "getFieldAttrs": [Function], + "getIndexPattern": [Function], + "getName": [Function], + "getOriginalSavedObjectBody": [Function], + "id": "1234", + "matchedIndices": Array [], + "metaFields": Array [], + "name": "", + "namespaces": Array [], + "originalSavedObjectBody": Object {}, + "resetOriginalSavedObjectBody": [Function], + "runtimeFieldMap": Object {}, + "setFieldFormat": [Function], + "setIndexPattern": [Function], + "shortDotsEnable": false, + "sourceFilters": Array [], + "timeFieldName": undefined, + "title": "filebeat-*,auditbeat-*,packetbeat-*", + "type": undefined, + "typeMeta": undefined, + "version": "1", + }, + ], + "isDisabled": undefined, + "isLoading": false, + "isRefreshPaused": true, + "query": Object { + "language": "kuery", + "query": "here: query", + }, + "refreshInterval": undefined, + "savedQuery": undefined, + "showAutoRefreshOnly": false, + "showDatePicker": false, + "showFilterBar": true, + "showQueryInput": true, + "showSaveQuery": true, + "showSubmitButton": false, +} +`; diff --git a/x-pack/plugins/security_solution/public/common/components/query_bar/index.test.tsx b/x-pack/plugins/security_solution/public/common/components/query_bar/index.test.tsx index 75ce97482552c..d3cf73eb02320 100644 --- a/x-pack/plugins/security_solution/public/common/components/query_bar/index.test.tsx +++ b/x-pack/plugins/security_solution/public/common/components/query_bar/index.test.tsx @@ -99,130 +99,7 @@ describe('QueryBar ', () => { ...searchBarProps } = wrapper.find(SearchBar).props(); - expect(searchBarProps).toEqual({ - dataTestSubj: undefined, - dateRangeFrom: 'now/d', - dateRangeTo: 'now/d', - displayStyle: undefined, - filters: [], - indexPatterns: [ - { - fields: [ - { - aggregatable: true, - name: '@timestamp', - searchable: true, - type: 'date', - }, - { - aggregatable: true, - name: '@version', - searchable: true, - type: 'string', - }, - { - aggregatable: true, - name: 'agent.ephemeral_id', - searchable: true, - type: 'string', - }, - { - aggregatable: true, - name: 'agent.hostname', - searchable: true, - type: 'string', - }, - { - aggregatable: true, - name: 'agent.id', - searchable: true, - type: 'string', - }, - { - aggregatable: true, - name: 'agent.test1', - searchable: true, - type: 'string', - }, - { - aggregatable: true, - name: 'agent.test2', - searchable: true, - type: 'string', - }, - { - aggregatable: true, - name: 'agent.test3', - searchable: true, - type: 'string', - }, - { - aggregatable: true, - name: 'agent.test4', - searchable: true, - type: 'string', - }, - { - aggregatable: true, - name: 'agent.test5', - searchable: true, - type: 'string', - }, - { - aggregatable: true, - name: 'agent.test6', - searchable: true, - type: 'string', - }, - { - aggregatable: true, - name: 'agent.test7', - searchable: true, - type: 'string', - }, - { - aggregatable: true, - name: 'agent.test8', - searchable: true, - type: 'string', - }, - { - aggregatable: true, - name: 'host.name', - searchable: true, - type: 'string', - }, - { - aggregatable: false, - name: 'nestedField.firstAttributes', - searchable: true, - type: 'string', - }, - { - aggregatable: false, - name: 'nestedField.secondAttributes', - searchable: true, - type: 'string', - }, - ], - title: 'filebeat-*,auditbeat-*,packetbeat-*', - }, - ], - isLoading: false, - isRefreshPaused: true, - query: { - language: 'kuery', - query: 'here: query', - }, - refreshInterval: undefined, - savedQuery: undefined, - showAutoRefreshOnly: false, - showDatePicker: false, - showFilterBar: true, - showQueryInput: true, - showSaveQuery: true, - showSubmitButton: false, - }); + expect(searchBarProps).toMatchSnapshot(); }); // FLAKY: https://github.com/elastic/kibana/issues/132659