Node panel: ports read message first on inputs, code name is text until it differs
An input row now starts from its message and ends as the argument the code
takes it as ("as prompt"); an output keeps its key on top and the message
below. The name the code uses is muted text with a pencil while it follows the
message's last segment, and a field only when it differs. Device Follows ports
get the same order (message, then the port driven). A list port's item type
moves to the second row so it no longer squeezes the name, two ports deriving
one name get a warning, and the rows rebuilt use 44px touch targets on phones.
The stored node spec is unchanged.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { expect, type Page, test } from "@playwright/test"
|
||||
import { apiUrl } from "./config.ts"
|
||||
import { deleteAll } from "./utils/api"
|
||||
import { api, deleteAll } from "./utils/api"
|
||||
|
||||
/**
|
||||
* The flow editor's load-bearing behaviour: nodes are placed, connections come
|
||||
@@ -144,3 +144,80 @@ test("undo brings a deleted node back with its source", async ({ page }) => {
|
||||
await expect(page.locator(".react-flow__node")).toHaveCount(2)
|
||||
expect(await nodeSource(page, "python")).toContain("42.0")
|
||||
})
|
||||
|
||||
/**
|
||||
* A port reads top to bottom, source over destination: an input is its message
|
||||
* and then the argument the code takes it as, an output the key the code
|
||||
* returns and then its message. A name the code uses is only a field when it
|
||||
* differs from the message's last segment, muted text while it follows.
|
||||
*/
|
||||
test("a port's code name is a field only when it differs from its message", async ({
|
||||
page,
|
||||
}) => {
|
||||
const name = `test_ports_${Date.now().toString(36)}`
|
||||
await page.goto("/")
|
||||
const saved = await api(page, `/flows/${name}`, {
|
||||
method: "PUT",
|
||||
data: {
|
||||
name,
|
||||
nodes: [
|
||||
{
|
||||
id: "reader",
|
||||
type: "python",
|
||||
requires: [
|
||||
{ name: "command", port: "prompt", dtype: "str" },
|
||||
{ name: "outdoor", dtype: "float" },
|
||||
{ name: "a.level", dtype: "float" },
|
||||
{ name: "b.level", dtype: "float" },
|
||||
],
|
||||
provides: [
|
||||
{ name: "setpoint", port: "living_room_setpoint", dtype: "float" },
|
||||
{ name: "pv_kw", dtype: "float" },
|
||||
],
|
||||
},
|
||||
],
|
||||
inputs: [],
|
||||
},
|
||||
})
|
||||
expect(saved.ok()).toBeTruthy()
|
||||
try {
|
||||
await page.goto(`/flows/${name}?node=reader`)
|
||||
const panel = page.getByTestId("node-panel")
|
||||
|
||||
// Differs: the argument is a field, under its message.
|
||||
const argument = panel.getByLabel("Argument name")
|
||||
await expect(argument).toHaveCount(1)
|
||||
await expect(argument).toHaveValue("prompt")
|
||||
const message = panel.getByLabel("Message name").first()
|
||||
await expect(message).toHaveValue("command")
|
||||
const [above, below] = await Promise.all([
|
||||
message.boundingBox(),
|
||||
argument.boundingBox(),
|
||||
])
|
||||
expect(above?.y).toBeLessThan(below?.y ?? 0)
|
||||
|
||||
// An output keeps its key on top, a field because it differs.
|
||||
await expect(panel.getByLabel("Port name")).toHaveValue(
|
||||
"living_room_setpoint",
|
||||
)
|
||||
|
||||
// Matches: muted text with a pencil, no field. `level` is derived twice.
|
||||
const following = panel.getByTestId("port-follows")
|
||||
await expect(following).toHaveCount(4)
|
||||
await expect(following.nth(0)).toHaveText("outdoor")
|
||||
await expect(following.nth(3)).toHaveText("pv_kw")
|
||||
await expect(panel.getByTestId("port-clash")).toHaveCount(2)
|
||||
|
||||
// The pencil opens the field on the derived name.
|
||||
await panel
|
||||
.getByRole("button", { name: "Name the argument differently" })
|
||||
.first()
|
||||
.click()
|
||||
await expect(argument).toHaveCount(2)
|
||||
await expect(argument.nth(1)).toBeFocused()
|
||||
await expect(argument.nth(1)).toHaveValue("")
|
||||
await expect(argument.nth(1)).toHaveAttribute("placeholder", "outdoor")
|
||||
} finally {
|
||||
await api(page, `/flows/${name}`, { method: "DELETE" })
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user