feat: support new errors payload in SQL Lab (#10243)

This commit is contained in:
Erik Ritter
2020-07-06 09:49:32 -07:00
committed by GitHub
parent 2314aad450
commit 9a5195ab85
7 changed files with 92 additions and 18 deletions

View File

@@ -19,12 +19,20 @@
import React from 'react';
import { shallow } from 'enzyme';
import sinon from 'sinon';
import { Alert, ProgressBar } from 'react-bootstrap';
import FilterableTable from 'src/components/FilterableTable/FilterableTable';
import ExploreResultsButton from 'src/SqlLab/components/ExploreResultsButton';
import ResultSet from 'src/SqlLab/components/ResultSet';
import { queries, stoppedQuery, runningQuery, cachedQuery } from './fixtures';
import ErrorMessageWithStackTrace from 'src/components/ErrorMessage/ErrorMessageWithStackTrace';
import {
cachedQuery,
failedQueryWithErrorMessage,
failedQueryWithErrors,
queries,
runningQuery,
stoppedQuery,
} from './fixtures';
describe('ResultSet', () => {
const clearQuerySpy = sinon.spy();
@@ -42,6 +50,14 @@ describe('ResultSet', () => {
const stoppedQueryProps = { ...mockedProps, query: stoppedQuery };
const runningQueryProps = { ...mockedProps, query: runningQuery };
const cachedQueryProps = { ...mockedProps, query: cachedQuery };
const failedQueryWithErrorMessageProps = {
...mockedProps,
query: failedQueryWithErrorMessage,
};
const failedQueryWithErrorsProps = {
...mockedProps,
query: failedQueryWithErrors,
};
const newProps = {
query: {
cached: false,
@@ -117,5 +133,15 @@ describe('ResultSet', () => {
const wrapper = shallow(<ResultSet {...runningQueryProps} />);
expect(wrapper.find(ProgressBar)).toHaveLength(1);
});
it('should render a failed query with an error message', () => {
const wrapper = shallow(
<ResultSet {...failedQueryWithErrorMessageProps} />,
);
expect(wrapper.find(ErrorMessageWithStackTrace)).toHaveLength(1);
});
it('should render a failed query with an errors object', () => {
const wrapper = shallow(<ResultSet {...failedQueryWithErrorsProps} />);
expect(wrapper.find(ErrorMessageWithStackTrace)).toHaveLength(1);
});
});
});

View File

@@ -389,6 +389,50 @@ export const stoppedQuery = {
tab: 'Untitled Query 2',
tempTable: '',
};
export const failedQueryWithErrorMessage = {
dbId: 1,
cached: false,
ctas: false,
errorMessage: 'Something went wrong',
id: 'ryhMUZCGb',
progress: 0,
results: [],
runAsync: false,
schema: 'main',
sql: 'SELECT ...',
sqlEditorId: 'rJaf5u9WZ',
startDttm: 1497400851936,
state: 'failed',
tab: 'Untitled Query 2',
tempTable: '',
};
export const failedQueryWithErrors = {
dbId: 1,
cached: false,
ctas: false,
errors: [
{
message: 'Something went wrong',
error_type: 'TEST_ERROR',
level: 'error',
extra: null,
},
],
id: 'ryhMUZCGb',
progress: 0,
results: [],
runAsync: false,
schema: 'main',
sql: 'SELECT ...',
sqlEditorId: 'rJaf5u9WZ',
startDttm: 1497400851936,
state: 'failed',
tab: 'Untitled Query 2',
tempTable: '',
};
export const runningQuery = {
dbId: 1,
cached: false,