-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
49 changed files
with
2,067 additions
and
1,304 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
grai-frontend/src/components/connections/create/ConnectionCreateContent.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { render, screen, waitFor } from "testing" | ||
import ConnectionCreateContent from "./ConnectionCreateContent" | ||
|
||
const workspace = { | ||
id: "1", | ||
} | ||
|
||
test("renders", async () => { | ||
render(<ConnectionCreateContent workspace={workspace} />, { | ||
withRouter: true, | ||
}) | ||
|
||
await waitFor(() => { | ||
expect(screen.queryAllByText("Select Integration")).toHaveLength(2) | ||
}) | ||
|
||
await waitFor(() => | ||
expect(screen.queryAllByText("Hello World")).toHaveLength(3), | ||
) | ||
}) | ||
|
||
test("renders schedule", async () => { | ||
render(<ConnectionCreateContent workspace={workspace} />, { | ||
route: "/default/demo/connections/create?step=schedule&connectionId=1", | ||
path: "/:organisationName/:workspaceName/connections/create", | ||
withRouter: true, | ||
}) | ||
|
||
await waitFor(() => { | ||
expect(screen.getByText(/Schedule type/i)).toBeInTheDocument() | ||
}) | ||
}) | ||
|
||
test("renders schedule missing connectionId", async () => { | ||
render(<ConnectionCreateContent workspace={workspace} />, { | ||
route: "/default/demo/connections/create?step=schedule", | ||
path: "/:organisationName/:workspaceName/connections/create", | ||
withRouter: true, | ||
}) | ||
|
||
await waitFor(() => { | ||
expect(screen.queryByText(/Schedule type/i)).not.toBeInTheDocument() | ||
}) | ||
|
||
expect(screen.getByText("Page not found")).toBeInTheDocument() | ||
}) | ||
|
||
test("renders connection", async () => { | ||
render(<ConnectionCreateContent workspace={workspace} />, { | ||
route: "/default/demo/connections/create?connectionId=1", | ||
path: "/:organisationName/:workspaceName/connections/create", | ||
withRouter: true, | ||
}) | ||
|
||
await waitFor(() => { | ||
expect(screen.getByText("Invite a teammate")).toBeInTheDocument() | ||
}) | ||
}) | ||
|
||
test("renders connectorId", async () => { | ||
render(<ConnectionCreateContent workspace={workspace} />, { | ||
route: "/default/demo/connections/create?connectorId=1", | ||
path: "/:organisationName/:workspaceName/connections/create", | ||
withRouter: true, | ||
}) | ||
|
||
await waitFor(() => { | ||
expect(screen.getByText("Invite a teammate")).toBeInTheDocument() | ||
}) | ||
}) |
54 changes: 54 additions & 0 deletions
54
grai-frontend/src/components/connections/create/ConnectionCreateContent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import React from "react" | ||
import NotFound from "pages/NotFound" | ||
import useSearchParams from "helpers/useSearchParams" | ||
import ConnectorSelectTab from "components/connections/create/ConnectorSelectTab" | ||
import ScheduleTab from "./ScheduleTab" | ||
import SetupConnectionTab from "./SetupConnectionTab" | ||
import UpdateConnectionTab from "./UpdateConnectionTab" | ||
|
||
interface Workspace { | ||
id: string | ||
} | ||
|
||
type ConnectionCreateContentProps = { | ||
workspace: Workspace | ||
} | ||
|
||
const ConnectionCreateContent: React.FC<ConnectionCreateContentProps> = ({ | ||
workspace, | ||
}) => { | ||
const { searchParams } = useSearchParams() | ||
|
||
const step = searchParams.get("step") | ||
const connectionId = searchParams.get("connectionId") | ||
|
||
if (step === "schedule") { | ||
if (!connectionId) return <NotFound /> | ||
|
||
return ( | ||
<ScheduleTab workspaceId={workspace.id} connectionId={connectionId} /> | ||
) | ||
} | ||
|
||
if (connectionId) | ||
return ( | ||
<UpdateConnectionTab | ||
workspaceId={workspace.id} | ||
connectionId={connectionId} | ||
/> | ||
) | ||
|
||
const connectorId = searchParams.get("connectorId") | ||
|
||
if (connectorId) | ||
return ( | ||
<SetupConnectionTab | ||
workspaceId={workspace.id} | ||
connectorId={connectorId} | ||
/> | ||
) | ||
|
||
return <ConnectorSelectTab /> | ||
} | ||
|
||
export default ConnectionCreateContent |
Oops, something went wrong.