-
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.
* feat(js,react): block key * feat(js): export props from the package * feat: type documentation * fix: tests * @flows/[email protected] * fix: block in active block * @flows/[email protected] * fix: tests * feat: remove key from active block * fix: remove unused file --------- Co-authored-by: flows-bot[bot] <170794745+flows-bot[bot]@users.noreply.github.com>
- Loading branch information
1 parent
5916c0d
commit 924b964
Showing
36 changed files
with
348 additions
and
320 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 was deleted.
Oops, something went wrong.
This file was deleted.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { Block } from "@flows/shared"; | ||
import { expect, test } from "@playwright/test"; | ||
import { randomUUID } from "crypto"; | ||
|
||
const getBlocks = (): Block[] => | ||
[ | ||
{ | ||
id: randomUUID(), | ||
key: "my-key", | ||
type: "component", | ||
componentType: "Modal", | ||
data: {}, | ||
exitNodes: [], | ||
slottable: false, | ||
}, | ||
{ | ||
id: randomUUID(), | ||
data: {}, | ||
exitNodes: [], | ||
slottable: false, | ||
type: "tour", | ||
tourBlocks: [ | ||
{ | ||
id: randomUUID(), | ||
data: {}, | ||
key: "tour-block-key", | ||
slottable: false, | ||
type: "tour-component", | ||
componentType: "Modal", | ||
}, | ||
], | ||
}, | ||
] satisfies Block[]; | ||
|
||
test.beforeEach(async ({ page }) => { | ||
await page.routeWebSocket( | ||
(url) => url.pathname === "/ws/sdk/block-updates", | ||
() => {}, | ||
); | ||
}); | ||
|
||
const run = (packageName: string) => { | ||
test(`${packageName} - return empty blocks`, async ({ page }) => { | ||
await page.route("**/v2/sdk/blocks", (route) => { | ||
route.fulfill({ json: { blocks: [] } }); | ||
}); | ||
await page.goto(`/${packageName}.html`); | ||
await expect(page.locator(".current-blocks")).toHaveText(JSON.stringify([])); | ||
}); | ||
|
||
test(`${packageName} - return floating blocks`, async ({ page }) => { | ||
const blocks = getBlocks(); | ||
await page.route("**/v2/sdk/blocks", (route) => { | ||
route.fulfill({ json: { blocks } }); | ||
}); | ||
await page.goto(`/${packageName}.html`); | ||
await expect(page.locator(".current-blocks")).toHaveText( | ||
JSON.stringify([ | ||
{ | ||
id: blocks[0]?.id, | ||
type: "component", | ||
component: "Modal", | ||
props: { __flows: { key: "my-key" } }, | ||
}, | ||
{ | ||
id: blocks[1]?.tourBlocks?.[0]?.id, | ||
type: "tour-component", | ||
component: "Modal", | ||
props: { __flows: { key: "tour-block-key" } }, | ||
}, | ||
]), | ||
); | ||
}); | ||
}; | ||
|
||
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Block } from "@flows/shared"; | ||
import test, { expect } from "@playwright/test"; | ||
import { randomUUID } from "crypto"; | ||
|
||
test.beforeEach(async ({ page }) => { | ||
await page.routeWebSocket( | ||
(url) => url.pathname === "/ws/sdk/block-updates", | ||
() => {}, | ||
); | ||
}); | ||
|
||
const getBlock = (props: { key: string }): Block => ({ | ||
id: randomUUID(), | ||
type: "component", | ||
componentType: "Card", | ||
data: { text: "My card" }, | ||
exitNodes: [], | ||
slottable: true, | ||
slotId: "my-slot", | ||
key: props.key, | ||
}); | ||
|
||
const run = (packageName: string) => { | ||
test(`${packageName} - should pass block key to component props`, async ({ page }) => { | ||
await page.route("**/v2/sdk/blocks", (route) => { | ||
route.fulfill({ json: { blocks: [getBlock({ key: "my-block-key" })] } }); | ||
}); | ||
await page.goto(`/${packageName}.html`); | ||
await expect(page.getByText("key: my-block-key", { exact: true })).toBeVisible(); | ||
}); | ||
}; | ||
|
||
run("js"); | ||
run("react"); |
Oops, something went wrong.