mirror of
https://github.com/apache/superset.git
synced 2026-04-22 09:35:23 +00:00
fix(sqllab): normalize changedOn timestamp (#24513)
This commit is contained in:
@@ -18,7 +18,6 @@
|
||||
*/
|
||||
import sqlLabReducer from 'src/SqlLab/reducers/sqlLab';
|
||||
import * as actions from 'src/SqlLab/actions/sqlLab';
|
||||
import { now } from 'src/utils/dates';
|
||||
import { table, initialState as mockState } from '../fixtures';
|
||||
|
||||
const initialState = mockState.sqlLab;
|
||||
@@ -273,6 +272,8 @@ describe('sqlLabReducer', () => {
|
||||
});
|
||||
});
|
||||
describe('Run Query', () => {
|
||||
const DENORMALIZED_CHANGED_ON = '2023-06-26T07:53:05.439';
|
||||
const CHANGED_ON_TIMESTAMP = 1687765985439;
|
||||
let newState;
|
||||
let query;
|
||||
beforeEach(() => {
|
||||
@@ -280,7 +281,8 @@ describe('sqlLabReducer', () => {
|
||||
query = {
|
||||
id: 'abcd',
|
||||
progress: 0,
|
||||
startDttm: now(),
|
||||
changed_on: DENORMALIZED_CHANGED_ON,
|
||||
startDttm: CHANGED_ON_TIMESTAMP,
|
||||
state: 'running',
|
||||
cached: false,
|
||||
sqlEditorId: 'dfsadfs',
|
||||
@@ -292,7 +294,8 @@ describe('sqlLabReducer', () => {
|
||||
query: {
|
||||
id: 'abcd',
|
||||
progress: 0,
|
||||
startDttm: now(),
|
||||
changed_on: DENORMALIZED_CHANGED_ON,
|
||||
startDttm: CHANGED_ON_TIMESTAMP,
|
||||
state: 'running',
|
||||
cached: false,
|
||||
sqlEditorId: 'dfsadfs',
|
||||
@@ -328,6 +331,19 @@ describe('sqlLabReducer', () => {
|
||||
newState = sqlLabReducer(newState, removeQueryAction);
|
||||
expect(Object.keys(newState.queries)).toHaveLength(0);
|
||||
});
|
||||
it('should refresh queries when polling returns new results', () => {
|
||||
newState = sqlLabReducer(
|
||||
{
|
||||
...newState,
|
||||
queries: { abcd: {} },
|
||||
},
|
||||
actions.refreshQueries({
|
||||
abcd: query,
|
||||
}),
|
||||
);
|
||||
expect(newState.queries.abcd.changed_on).toBe(DENORMALIZED_CHANGED_ON);
|
||||
expect(newState.queriesLastUpdate).toBe(CHANGED_ON_TIMESTAMP);
|
||||
});
|
||||
it('should refresh queries when polling returns empty', () => {
|
||||
newState = sqlLabReducer(newState, actions.refreshQueries({}));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user