Skip to content

Commit

Permalink
feat: add prop to setDBEngine in DatabaseModal (#18653)
Browse files Browse the repository at this point in the history
* saving this now

* remove for testing

* added test

* remove this

* remove set

* remove log

* Update index.test.jsx
  • Loading branch information
hughhhh committed Feb 11, 2022
1 parent 33d1c96 commit 78e20e2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1016,4 +1016,24 @@ describe('DatabaseModal', () => {
});
});
});
describe('DatabaseModal w/ Deeplinking Engine', () => {
const renderAndWait = async () => {
const mounted = act(async () => {
render(<DatabaseModal {...dbProps} dbEngine="PostgreSQL" />, {
useRedux: true,
});
});

return mounted;
};

beforeEach(async () => {
await renderAndWait();
});

it('enters step 2 of 3 when proper database is selected', () => {
const step2of3text = screen.getByText(/step 2 of 3/i);
expect(step2of3text).toBeVisible();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ interface DatabaseModalProps {
onHide: () => void;
show: boolean;
databaseId: number | undefined; // If included, will go into edit mode
dbEngine: string | undefined; // if included goto step 2 with engine already set
}

enum ActionType {
Expand Down Expand Up @@ -428,6 +429,7 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
onHide,
show,
databaseId,
dbEngine,
}) => {
const [db, setDB] = useReducer<
Reducer<Partial<DatabaseObject> | null, DBReducerActionType>
Expand Down Expand Up @@ -850,6 +852,11 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
if (isLoading) {
setLoading(false);
}

if (availableDbs && dbEngine) {
// set model if passed into props
setDatabaseModel(dbEngine);
}
}, [availableDbs]);

const tabChange = (key: string) => {
Expand Down

0 comments on commit 78e20e2

Please sign in to comment.