fix: allow option to generate new query (#13488)

This commit is contained in:
Elizabeth Thompson
2021-03-18 11:42:31 -07:00
committed by GitHub
parent ecfcaea803
commit b97bbed2a9
4 changed files with 58 additions and 3 deletions

View File

@@ -173,7 +173,7 @@ describe('async actions', () => {
fetchMock.get(
fetchQueryEndpoint,
{ throws: { error: 'error text' } },
{ throws: { message: 'error text' } },
{ overwriteRoutes: true },
);
@@ -238,7 +238,7 @@ describe('async actions', () => {
fetchMock.post(
runQueryEndpoint,
{ throws: { error: 'error text' } },
{ throws: { message: 'error text' } },
{ overwriteRoutes: true },
);
@@ -252,6 +252,29 @@ describe('async actions', () => {
});
});
describe('reRunQuery', () => {
let stub;
beforeEach(() => {
stub = sinon.stub(shortid, 'generate').returns('abcd');
});
afterEach(() => {
stub.restore();
});
it('creates new query with a new id', () => {
const id = 'id';
const state = {
sqlLab: {
tabHistory: [id],
queryEditors: [{ id, title: 'Dummy query editor' }],
},
};
const store = mockStore(state);
store.dispatch(actions.reRunQuery(query));
expect(store.getActions()[0].query.id).toEqual('abcd');
});
});
describe('postStopQuery', () => {
const stopQueryEndpoint = 'glob:*/superset/stop_query/*';
fetchMock.post(stopQueryEndpoint, {});