fix: Changes ResultSet to include sqlEditorImmutableId when fetching results (#35773)

This commit is contained in:
Michael S. Molina
2025-10-21 14:24:39 -03:00
committed by GitHub
parent 4a3453999a
commit 337da13ba7
7 changed files with 55 additions and 6 deletions

View File

@@ -602,4 +602,42 @@ describe('ResultSet', () => {
);
expect(queryByTestId('copy-to-clipboard-button')).not.toBeInTheDocument();
});
test('should include sqlEditorImmutableId in query object when fetching results', async () => {
const queryWithResultsKey = {
...queries[0],
resultsKey: 'test-results-key',
sqlEditorImmutableId: 'test-immutable-id-123',
};
const store = mockStore({
...initialState,
user,
sqlLab: {
...initialState.sqlLab,
queries: {
[queryWithResultsKey.id]: queryWithResultsKey,
},
},
});
setup({ ...mockedProps, queryId: queryWithResultsKey.id }, store);
await waitFor(() => {
// Check that REQUEST_QUERY_RESULTS action was dispatched
const actions = store.getActions();
const requestAction = actions.find(
action => action.type === 'REQUEST_QUERY_RESULTS',
);
expect(requestAction).toBeDefined();
// Verify sqlEditorImmutableId is present in the query object
expect(requestAction?.query?.sqlEditorImmutableId).toBe(
'test-immutable-id-123',
);
});
// Verify the API was called
const resultsCalls = fetchMock.calls('glob:*/api/v1/sqllab/results/*');
expect(resultsCalls).toHaveLength(1);
});
});