-
Notifications
You must be signed in to change notification settings - Fork 2
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
1 parent
31a44f8
commit 9b88a70
Showing
28 changed files
with
1,286 additions
and
737 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,12 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<link rel="stylesheet" href="/reset.css" /> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/react.tsx"></script> | ||
</body> | ||
</html> |
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,44 @@ | ||
import { FlowsProvider, FlowsSlot } from "@flows/react"; | ||
import { FC, StrictMode } from "react"; | ||
import { createRoot } from "react-dom/client"; | ||
|
||
import * as components from "@flows/react-components"; | ||
import * as tourComponents from "@flows/react-components/tour"; | ||
import "@flows/react-components/index.css"; | ||
|
||
const apiUrl = new URLSearchParams(window.location.search).get("apiUrl") ?? undefined; | ||
|
||
const Card: FC<{ text: string }> = (props) => ( | ||
<div | ||
className="flows-card" | ||
style={{ | ||
border: "1px solid black", | ||
padding: "16px", | ||
borderRadius: "4px", | ||
}} | ||
> | ||
<p>{props.text}</p> | ||
</div> | ||
); | ||
|
||
createRoot(document.getElementById("root")!).render( | ||
<StrictMode> | ||
<FlowsProvider | ||
organizationId="orgId" | ||
environment="prod" | ||
userId="testUserId" | ||
userProperties={{ | ||
email: "[email protected]", | ||
age: 10, | ||
}} | ||
apiUrl={apiUrl} | ||
components={{ ...components, Card }} | ||
tourComponents={{ ...tourComponents, Card }} | ||
> | ||
<h1>heading 1</h1> | ||
<h2>Subtitle</h2> | ||
|
||
<FlowsSlot id="my-slot" placeholder={<p>Slot placeholder</p>} /> | ||
</FlowsProvider> | ||
</StrictMode>, | ||
); |
File renamed without changes.
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,63 @@ | ||
import { Block } from "@flows/shared"; | ||
import { test, expect } from "@playwright/test"; | ||
|
||
test.beforeEach(async ({ page }) => { | ||
await page.routeWebSocket( | ||
(url) => url.pathname === "/ws/sdk/block-updates", | ||
() => {}, | ||
); | ||
}); | ||
|
||
const block: Block = { | ||
id: "w", | ||
type: "component", | ||
componentType: "Modal", | ||
data: { title: "Workflow block", body: "", continueText: "continue" }, | ||
exitNodes: [], | ||
slottable: false, | ||
}; | ||
|
||
const run = (packageName: string) => { | ||
test(`${packageName} - shouldn't pass any methods without exit nodes`, async ({ page }) => { | ||
await page.route("**/v2/sdk/blocks", (route) => { | ||
route.fulfill({ json: { blocks: [block] } }); | ||
}); | ||
await page.goto(`/${packageName}.html`); | ||
await expect(page.getByText("Workflow block")).toBeVisible(); | ||
let reqWasSent = false; | ||
page.on("request", (req) => { | ||
if (req.url().includes("v2/sdk/events")) { | ||
reqWasSent = true; | ||
} | ||
}); | ||
await page.getByText("continue").click(); | ||
expect(reqWasSent).toBe(false); | ||
}); | ||
test(`${packageName} - should pass methods with exit nodes`, async ({ page }) => { | ||
const b: Block = { | ||
...block, | ||
exitNodes: ["continue"], | ||
}; | ||
await page.route("**/v2/sdk/blocks", (route) => { | ||
route.fulfill({ json: { blocks: [b] } }); | ||
}); | ||
await page.goto(`/${packageName}.html`); | ||
await expect(page.getByText("Workflow block")).toBeVisible(); | ||
const req = page.waitForRequest((req) => { | ||
const body = req.postDataJSON(); | ||
return ( | ||
req.url() === "https://api.flows-cloud.com/v2/sdk/events" && | ||
body.organizationId === "orgId" && | ||
body.userId === "testUserId" && | ||
body.environment === "prod" && | ||
body.name === "transition" && | ||
body.propertyKey === "continue" | ||
); | ||
}); | ||
await page.getByText("continue").click(); | ||
await req; | ||
}); | ||
}; | ||
|
||
run("js"); | ||
run("react"); |
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,52 @@ | ||
import { test } from "@playwright/test"; | ||
|
||
test.beforeEach(async ({ page }) => { | ||
await page.routeWebSocket( | ||
(url) => url.pathname === "/ws/sdk/block-updates", | ||
() => {}, | ||
); | ||
}); | ||
|
||
const run = (packageName: string) => { | ||
test(`${packageName} - should call blocks with correct parameters`, async ({ page }) => { | ||
await page.route("**/v2/sdk/blocks", (route) => { | ||
route.fulfill({ json: { blocks: [] } }); | ||
}); | ||
const blocksReq = page.waitForRequest((req) => { | ||
const body = req.postDataJSON(); | ||
return ( | ||
req.url() === "https://api.flows-cloud.com/v2/sdk/blocks" && | ||
body.organizationId === "orgId" && | ||
body.userId === "testUserId" && | ||
body.environment === "prod" && | ||
body.userProperties.email === "[email protected]" && | ||
body.userProperties.age === 10 | ||
); | ||
}); | ||
await page.goto(`/${packageName}.html`); | ||
await blocksReq; | ||
}); | ||
test(`${packageName} - should call custom apiUrl`, async ({ page }) => { | ||
await page.route("**/v2/sdk/blocks", (route) => { | ||
route.fulfill({ json: { blocks: [] } }); | ||
}); | ||
const blocksReq = page.waitForRequest((req) => { | ||
const body = req.postDataJSON(); | ||
return ( | ||
req.url() === "https://custom.api.flows.com/v2/sdk/blocks" && | ||
body.organizationId === "orgId" && | ||
body.userId === "testUserId" && | ||
body.environment === "prod" && | ||
body.userProperties.email === "[email protected]" && | ||
body.userProperties.age === 10 | ||
); | ||
}); | ||
await page.goto( | ||
`/${packageName}.html?apiUrl=${encodeURIComponent("https://custom.api.flows.com")}`, | ||
); | ||
await blocksReq; | ||
}); | ||
}; | ||
|
||
run("js"); | ||
run("react"); |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.