Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add prop to setDBEngine in DatabaseModal #18653

Merged
merged 8 commits into from
Feb 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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