fix: passing url params in sqllab (#15246)
* fix: passing url params in sqllab * avoid undefined serach and add test Co-authored-by: Ville Brofeldt <ville.v.brofeldt@gmail.com>
This commit is contained in:
parent
5bb406b296
commit
57c4d0f9a4
|
|
@ -332,8 +332,9 @@ export function runQuery(query) {
|
|||
expand_data: true,
|
||||
};
|
||||
|
||||
const search = window.location.search || '';
|
||||
return SupersetClient.post({
|
||||
endpoint: '/superset/sql_json/',
|
||||
endpoint: `/superset/sql_json/${search}`,
|
||||
body: JSON.stringify(postPayload),
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
parseMethod: 'text',
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ describe('async actions', () => {
|
|||
JSON.stringify({ data: mockBigNumber, query: { sqlEditorId: 'dfsadfs' } }),
|
||||
);
|
||||
|
||||
const runQueryEndpoint = 'glob:*/superset/sql_json/*';
|
||||
const runQueryEndpoint = 'glob:*/superset/sql_json/';
|
||||
fetchMock.post(runQueryEndpoint, `{ "data": ${mockBigNumber} }`);
|
||||
|
||||
describe('saveQuery', () => {
|
||||
|
|
@ -188,7 +188,7 @@ describe('async actions', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('runQuery', () => {
|
||||
describe('runQuery without query params', () => {
|
||||
const makeRequest = () => {
|
||||
const request = actions.runQuery(query);
|
||||
return request(dispatch);
|
||||
|
|
@ -250,6 +250,32 @@ describe('async actions', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('runQuery with query params', () => {
|
||||
const { location } = window;
|
||||
|
||||
beforeAll(() => {
|
||||
delete window.location;
|
||||
window.location = new URL('http://localhost/sqllab/?foo=bar');
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
delete window.location;
|
||||
window.location = location;
|
||||
});
|
||||
|
||||
const makeRequest = () => {
|
||||
const request = actions.runQuery(query);
|
||||
return request(dispatch);
|
||||
};
|
||||
|
||||
it('makes the fetch request', () =>
|
||||
makeRequest().then(() => {
|
||||
expect(
|
||||
fetchMock.calls('glob:*/superset/sql_json/?foo=bar'),
|
||||
).toHaveLength(1);
|
||||
}));
|
||||
});
|
||||
|
||||
describe('reRunQuery', () => {
|
||||
let stub;
|
||||
beforeEach(() => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue