This is an automated email from the ASF dual-hosted git repository. hugh pushed a commit to branch hugh/sqlalchemy-docs-2 in repository https://gitbox.apache.org/repos/asf/superset.git
commit 19f72e2add8db7ace5f2a79ab81a274f37aa4ac8 Author: hughhhh <[email protected]> AuthorDate: Wed Feb 17 12:54:31 2021 -0500 this test is working --- .../views/CRUD/data/database/DatabaseList_spec.jsx | 18 ++++++------------ superset-frontend/src/views/App.tsx | 1 + .../src/views/CRUD/data/database/DatabaseModal.tsx | 17 ++++++++++++++++- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/superset-frontend/spec/javascripts/views/CRUD/data/database/DatabaseList_spec.jsx b/superset-frontend/spec/javascripts/views/CRUD/data/database/DatabaseList_spec.jsx index 607f65e..5645577 100644 --- a/superset-frontend/spec/javascripts/views/CRUD/data/database/DatabaseList_spec.jsx +++ b/superset-frontend/spec/javascripts/views/CRUD/data/database/DatabaseList_spec.jsx @@ -57,6 +57,11 @@ const mockdatabases = [...new Array(3)].map((_, i) => ({ id: i, })); +jest.mock('react-redux', () => ({ + ...jest.requireActual('react-redux'), + useSelector: jest.fn(), +})); + const mockUser = { userId: 1, }; @@ -109,22 +114,11 @@ describe('DatabaseList', () => { it('fetches Databases', () => { const callsD = fetchMock.calls(/database\/\?q/); - expect(callsD).toHaveLength(2); + expect(callsD).toHaveLength(1); expect(callsD[0][0]).toMatchInlineSnapshot( `"http://localhost/api/v1/database/?q=(order_column:changed_on_delta_humanized,order_direction:desc,page:0,page_size:25)"`, ); }); -}); - -describe('DatabaseList async', () => { - const wrapper = mount( - <Provider store={store}> - <DatabaseList user={mockUser} /> - </Provider>, - ); - beforeAll(async () => { - await waitForComponentToPaint(wrapper); - }); it('deletes', async () => { act(() => { diff --git a/superset-frontend/src/views/App.tsx b/superset-frontend/src/views/App.tsx index 9e3fcbb..0e8dc24 100644 --- a/superset-frontend/src/views/App.tsx +++ b/superset-frontend/src/views/App.tsx @@ -51,6 +51,7 @@ initFeatureFlags(bootstrap.common.feature_flags); const store = createStore( combineReducers({ messageToasts: messageToastReducer, + common: () => common, }), {}, compose(applyMiddleware(thunk), initEnhancer(false)), diff --git a/superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx b/superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx index 081fb35..f2541da 100644 --- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx +++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx @@ -17,6 +17,7 @@ * under the License. */ import React, { FunctionComponent, useState, useEffect } from 'react'; +import { useSelector } from 'react-redux'; import { styled, t, SupersetClient } from '@superset-ui/core'; import InfoTooltip from 'src/common/components/InfoTooltip'; import { useSingleViewResource } from 'src/views/CRUD/hooks'; @@ -39,6 +40,16 @@ interface DatabaseModalProps { database?: DatabaseObject | null; // If included, will go into edit mode } +// todo: define common type fully in types file +interface RootState { + common: { + conf: { + SQLALCHEMY_DOCS_URL: string; + }; + }; + messageToast: Array<Object>; +} + const DEFAULT_TAB_KEY = '1'; const StyledIcon = styled(Icon)` @@ -132,6 +143,10 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({ const [db, setDB] = useState<DatabaseObject | null>(null); const [isHidden, setIsHidden] = useState<boolean>(true); const [tabKey, setTabKey] = useState<string>(DEFAULT_TAB_KEY); + const conf = useSelector((state: RootState) => { + console.log(state); + return state.common.conf; + }); const isEditMode = database !== null; const defaultExtra = @@ -402,7 +417,7 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({ <div className="helper"> {t('Refer to the ')} <a - href="https://docs.sqlalchemy.org/en/rel_1_2/core/engines.html#" + href={conf.SQLALCHEMY_DOCS_URL ? conf.SQLALCHEMY_DOCS_URL : ''} target="_blank" rel="noopener noreferrer" >
