diff --git a/web-console/src/components/segment-timeline/__snapshots__/segment-timeline.spec.tsx.snap b/web-console/src/components/segment-timeline/__snapshots__/segment-timeline.spec.tsx.snap new file mode 100644 index 00000000000..b4a34bb8e4a --- /dev/null +++ b/web-console/src/components/segment-timeline/__snapshots__/segment-timeline.spec.tsx.snap @@ -0,0 +1,198 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Segment Timeline matches snapshot 1`] = ` +
+
+
+ +
+
+
+
+
+
+ + +
+
+
+
+ +
+
+ + + + + double-caret-vertical + + + + +
+
+
+
+ +
+
+ + + + + double-caret-vertical + + + + +
+
+
+
+
+`; diff --git a/web-console/src/components/segment-timeline/segment-timeline.spec.tsx b/web-console/src/components/segment-timeline/segment-timeline.spec.tsx new file mode 100644 index 00000000000..6d13e435c4d --- /dev/null +++ b/web-console/src/components/segment-timeline/segment-timeline.spec.tsx @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { render } from '@testing-library/react'; +import React from 'react'; + +import { SegmentTimeline } from './segment-timeline'; + +describe('Segment Timeline', () => { + it('matches snapshot', () => { + const tableColumn = ; + const { container } = render(tableColumn); + expect(container.firstChild).toMatchSnapshot(); + }); +}); diff --git a/web-console/src/components/timed-button/__snapshots__/timed-button.spec.tsx.snap b/web-console/src/components/timed-button/__snapshots__/timed-button.spec.tsx.snap new file mode 100644 index 00000000000..97e0b8ca77b --- /dev/null +++ b/web-console/src/components/timed-button/__snapshots__/timed-button.spec.tsx.snap @@ -0,0 +1,44 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Timed button matches snapshot 1`] = ` +
+ + + +
+`; diff --git a/web-console/src/components/timed-button/timed-button.spec.tsx b/web-console/src/components/timed-button/timed-button.spec.tsx new file mode 100644 index 00000000000..2de48117a17 --- /dev/null +++ b/web-console/src/components/timed-button/timed-button.spec.tsx @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { render } from '@testing-library/react'; +import React from 'react'; + +import { TimedButton } from './timed-button'; + +describe('Timed button', () => { + it('matches snapshot', () => { + const timedButton = ( + null} + label={'label'} + defaultValue={1000} + /> + ); + const { container } = render(timedButton); + expect(container.firstChild).toMatchSnapshot(); + }); +}); diff --git a/web-console/src/utils/spec-utils.spec.ts b/web-console/src/utils/spec-utils.spec.ts index f3684173b76..c55a46eba29 100644 --- a/web-console/src/utils/spec-utils.spec.ts +++ b/web-console/src/utils/spec-utils.spec.ts @@ -16,6 +16,7 @@ * limitations under the License. */ +import { getSamplerType } from './sampler'; import { computeFlattenExprsForData } from './spec-utils'; describe('spec-utils', () => { @@ -66,3 +67,42 @@ describe('spec-utils', () => { }); }); }); + +describe.skip('test-utils', () => { + it('spec-utils', () => { + expect( + getSamplerType({ + type: 'index_parallel', + ioConfig: { + type: 'index_parallel', + firehose: { + type: 'http', + uris: ['https://static.imply.io/data/wikipedia.json.gz'], + }, + }, + tuningConfig: { + type: 'index_parallel', + }, + dataSchema: { + dataSource: 'wikipedia', + granularitySpec: { + type: 'uniform', + segmentGranularity: 'DAY', + queryGranularity: 'HOUR', + }, + parser: { + type: 'string', + parseSpec: { + format: 'json', + timestampSpec: { + column: 'timestamp', + format: 'iso', + }, + dimensionsSpec: {}, + }, + }, + }, + }), + ).toMatchInlineSnapshot(`"TRIM( TRAILING 'M' undefined 'MADAM')"`); + }); +}); diff --git a/web-console/src/utils/utils.spec.ts b/web-console/src/utils/utils.spec.ts new file mode 100644 index 00000000000..dda3c73b3ae --- /dev/null +++ b/web-console/src/utils/utils.spec.ts @@ -0,0 +1,241 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { getDruidErrorMessage, parseHtmlError, parseQueryPlan } from './druid-query'; +import { + getColumnTypeFromHeaderAndRows, + getDimensionSpecs, + getMetricSecs, + guessTypeFromSample, + updateSchemaWithSample, +} from './druid-type'; +import { IngestionSpec } from './ingestion-spec'; +import { + getSamplerType, + headerFromSampleResponse, + sampleForConnect, + sampleForExampleManifests, + sampleForFilter, + sampleForParser, + sampleForSchema, + sampleForTimestamp, + sampleForTransform, +} from './sampler'; + +describe('test-utils', () => { + const ingestionSpec = { + type: 'index_parallel', + ioConfig: { + type: 'index_parallel', + firehose: { + type: 'http', + uris: ['https://static.imply.io/data/wikipedia.json.gz'], + }, + }, + tuningConfig: { + type: 'index_parallel', + }, + dataSchema: { + dataSource: 'wikipedia', + granularitySpec: { + type: 'uniform', + segmentGranularity: 'DAY', + queryGranularity: 'HOUR', + }, + parser: { + type: 'string', + parseSpec: { + format: 'json', + timestampSpec: { + column: 'timestamp', + format: 'iso', + }, + dimensionsSpec: {}, + }, + }, + }, + }; + it('spec-utils getSamplerType', () => { + expect(getSamplerType(ingestionSpec as IngestionSpec)).toMatchInlineSnapshot(`"index"`); + }); + it('spec-utils headerFromSampleResponse', () => { + expect(headerFromSampleResponse({ cacheKey: 'abc123', data: [] })).toMatchInlineSnapshot( + `Array []`, + ); + }); + it('spec-utils sampleForParser', () => { + expect( + sampleForParser(ingestionSpec as IngestionSpec, 'start', 'abc123'), + ).toMatchInlineSnapshot(`Promise {}`); + }); + it('spec-utils SampleSpec', () => { + expect(sampleForConnect(ingestionSpec as IngestionSpec, 'start')).toMatchInlineSnapshot( + `Promise {}`, + ); + }); + it('spec-utils sampleForTimestamp', () => { + expect( + sampleForTimestamp(ingestionSpec as IngestionSpec, 'start', 'abc123'), + ).toMatchInlineSnapshot(`Promise {}`); + }); + it('spec-utils sampleForTransform', () => { + expect( + sampleForTransform(ingestionSpec as IngestionSpec, 'start', 'abc123'), + ).toMatchInlineSnapshot(`Promise {}`); + }); + it('spec-utils sampleForFilter', () => { + expect( + sampleForFilter(ingestionSpec as IngestionSpec, 'start', 'abc123'), + ).toMatchInlineSnapshot(`Promise {}`); + }); + it('spec-utils sampleForSchema', () => { + expect( + sampleForSchema(ingestionSpec as IngestionSpec, 'start', 'abc123'), + ).toMatchInlineSnapshot(`Promise {}`); + }); + it('spec-utils sampleForExampleManifests', () => { + expect(sampleForExampleManifests('abc123')).toMatchInlineSnapshot(`Promise {}`); + }); +}); + +describe('druid-type.ts', () => { + const ingestionSpec = { + type: 'index_parallel', + ioConfig: { + type: 'index_parallel', + firehose: { + type: 'http', + uris: ['https://static.imply.io/data/wikipedia.json.gz'], + }, + }, + tuningConfig: { + type: 'index_parallel', + }, + dataSchema: { + dataSource: 'wikipedia', + granularitySpec: { + type: 'uniform', + segmentGranularity: 'DAY', + queryGranularity: 'HOUR', + }, + parser: { + type: 'string', + parseSpec: { + format: 'json', + timestampSpec: { + column: 'timestamp', + format: 'iso', + }, + dimensionsSpec: {}, + }, + }, + }, + }; + it('spec-utils getSamplerType', () => { + expect(guessTypeFromSample([])).toMatchInlineSnapshot(`"string"`); + }); + it('spec-utils getColumnTypeFromHeaderAndRows', () => { + expect( + getColumnTypeFromHeaderAndRows({ header: ['header'], rows: [] }, 'header'), + ).toMatchInlineSnapshot(`"string"`); + }); + it('spec-utils getDimensionSpecs', () => { + expect(getDimensionSpecs({ header: ['header'], rows: [] }, true)).toMatchInlineSnapshot(` + Array [ + "header", + ] + `); + }); + it('spec-utils getMetricSecs', () => { + expect(getMetricSecs({ header: ['header'], rows: [] })).toMatchInlineSnapshot(` + Array [ + Object { + "name": "count", + "type": "count", + }, + ] + `); + }); + it('spec-utils updateSchemaWithSample', () => { + expect( + updateSchemaWithSample( + ingestionSpec as IngestionSpec, + { header: ['header'], rows: [] }, + 'specific', + true, + ), + ).toMatchInlineSnapshot(` + Object { + "dataSchema": Object { + "dataSource": "wikipedia", + "granularitySpec": Object { + "queryGranularity": "HOUR", + "rollup": true, + "segmentGranularity": "DAY", + "type": "uniform", + }, + "metricsSpec": Array [ + Object { + "name": "count", + "type": "count", + }, + ], + "parser": Object { + "parseSpec": Object { + "dimensionsSpec": Object { + "dimensions": Array [ + "header", + ], + }, + "format": "json", + "timestampSpec": Object { + "column": "timestamp", + "format": "iso", + }, + }, + "type": "string", + }, + }, + "ioConfig": Object { + "firehose": Object { + "type": "http", + "uris": Array [ + "https://static.imply.io/data/wikipedia.json.gz", + ], + }, + "type": "index_parallel", + }, + "tuningConfig": Object { + "type": "index_parallel", + }, + "type": "index_parallel", + } + `); + }); +}); +describe('druid-query.ts', () => { + it('spec-utils parseHtmlError', () => { + expect(parseHtmlError('
')).toMatchInlineSnapshot(`undefined`); + }); + it('spec-utils parseHtmlError', () => { + expect(getDruidErrorMessage({})).toMatchInlineSnapshot(`undefined`); + }); + it('spec-utils parseQueryPlan', () => { + expect(parseQueryPlan('start')).toMatchInlineSnapshot(`"start"`); + }); +}); diff --git a/web-console/src/views/query-view/query-output/__snapshots__/query-output.spec.tsx.snap b/web-console/src/views/query-view/query-output/__snapshots__/query-output.spec.tsx.snap index 65e36a818c6..e5a679fa368 100644 --- a/web-console/src/views/query-view/query-output/__snapshots__/query-output.spec.tsx.snap +++ b/web-console/src/views/query-view/query-output/__snapshots__/query-output.spec.tsx.snap @@ -13,196 +13,1711 @@ exports[`query output matches snapshot 1`] = ` >
+ > +
+
+ + +
+ language +
+
+
+
+
+
+
+
+ + +
+ Count +
+
+
+
+
+
+
+
+ + +
+ dist_language +
+
+
+
+
+
+
+
+ + +
+ language_filtered_count +
+
+
+
+
+
+
+ > +
+ +
+
+
+ + +
+ 6881 +
+
+
+
+
+
+
+ + +
+ 1 +
+
+
+
+
+
+ 0 +
+
+ > +
+
+ + +
+ JavaScript +
+
+
+
+
+
+
+ + +
+ 166 +
+
+
+
+
+
+
+ + +
+ 1 +
+
+
+
+
+
+ 0 +
+
+ > +
+
+ + +
+ Python +
+
+
+
+
+
+
+ + +
+ 62 +
+
+
+
+
+
+
+ + +
+ 1 +
+
+
+
+
+
+ 0 +
+
+ > +
+
+ + +
+ HTML +
+
+
+
+
+
+
+ + +
+ 46 +
+
+
+
+
+
+
+ + +
+ 1 +
+
+
+
+
+
+ 0 +
+
+ > +
+
+ + +
+ Java +
+
+
+
+
+
+
+ + +
+ 42 +
+
+
+
+
+
+
+ + +
+ 1 +
+
+
+
+
+
+ 0 +
+
+ > +
+
+ + +
+ C++ +
+
+
+
+
+
+
+ + +
+ 28 +
+
+
+
+
+
+
+ + +
+ 1 +
+
+
+
+
+
+ 0 +
+
+ > +
+
+ + +
+ Go +
+
+
+
+
+
+
+ + +
+ 24 +
+
+
+
+
+
+
+ + +
+ 1 +
+
+
+
+
+
+ 0 +
+
+ > +
+
+ + +
+ Ruby +
+
+
+
+
+
+
+ + +
+ 20 +
+
+
+
+
+
+
+ + +
+ 1 +
+
+
+
+
+
+ 0 +
+
+ > +
+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 0 +
+
@@ -246,7 +1761,7 @@ exports[`query output matches snapshot 1`] = ` - 1 + 2
-
- lol -
diff --git a/web-console/src/views/query-view/query-output/query-output.spec.tsx b/web-console/src/views/query-view/query-output/query-output.spec.tsx index ae3d06eb6a7..d36ced139f0 100644 --- a/web-console/src/views/query-view/query-output/query-output.spec.tsx +++ b/web-console/src/views/query-view/query-output/query-output.spec.tsx @@ -17,14 +17,77 @@ */ import { render } from '@testing-library/react'; +import { sqlParserFactory } from 'druid-query-toolkit'; import React from 'react'; +import { SQL_FUNCTIONS } from '../../../../lib/sql-docs'; + import { QueryOutput } from './query-output'; describe('query output', () => { it('matches snapshot', () => { + const parser = sqlParserFactory(SQL_FUNCTIONS.map(sqlFunction => sqlFunction.name)); + + const parsedQuery = parser(`SELECT + "language", + COUNT(*) AS "Count", COUNT(DISTINCT "language") AS "dist_language", COUNT(*) FILTER (WHERE "language"= 'xxx') AS "language_filtered_count" +FROM "github" +WHERE "__time" >= CURRENT_TIMESTAMP - INTERVAL '1' DAY AND "language" != 'TypeScript' +GROUP BY 1 +HAVING "Count" != 37392 +ORDER BY "Count" DESC`); + const queryOutput = ( - {}} loading={false} error="lol" /> + null} + /> ); const { container } = render(queryOutput); diff --git a/web-console/src/views/query-view/query-output/query-output.tsx b/web-console/src/views/query-view/query-output/query-output.tsx index 17878d5b1fe..a1da2c07c53 100644 --- a/web-console/src/views/query-view/query-output/query-output.tsx +++ b/web-console/src/views/query-view/query-output/query-output.tsx @@ -93,6 +93,7 @@ export class QueryOutput extends React.PureComponent {
); } + getHeaderActions(h: string) { const { parsedQuery, onQueryChange, runeMode } = this.props; diff --git a/web-console/src/visualization/__snapshots__/visualization.spec.tsx.snap b/web-console/src/visualization/__snapshots__/visualization.spec.tsx.snap new file mode 100644 index 00000000000..18e5c970586 --- /dev/null +++ b/web-console/src/visualization/__snapshots__/visualization.spec.tsx.snap @@ -0,0 +1,18 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Visualization BarUnit 1`] = ` + +`; + +exports[`Visualization action barGroup 1`] = ` + +`; diff --git a/web-console/src/visualization/visualization.spec.tsx b/web-console/src/visualization/visualization.spec.tsx new file mode 100644 index 00000000000..b65b51c186e --- /dev/null +++ b/web-console/src/visualization/visualization.spec.tsx @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { render } from '@testing-library/react'; +import React from 'react'; + +import { BarUnit } from './bar-unit'; +import { ChartAxis } from './chart-axis'; + +describe('Visualization', () => { + it('BarUnit', () => { + const barGroup = ; + const { container } = render(barGroup); + expect(container.firstChild).toMatchSnapshot(); + }); + it('action barGroup', () => { + const barGroup = null} />; + const { container } = render(barGroup); + expect(container.firstChild).toMatchSnapshot(); + }); +});