|
| 1 | +# Flow Functionality — cURL API Generation |
| 2 | + |
| 3 | +**Last validated:** Langflow 1.10.x |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## What this test validates *(required)* |
| 8 | + |
| 9 | +Validates that Langflow's **API access modal** generates a valid macOS/Linux `curl` command that callers can execute against `/api/v1/run/{flow_id}` to run a flow programmatically. The test asserts the structural shape of the generated command, not just that the clipboard received some text. |
| 10 | + |
| 11 | +If this breaks, integrators copying the snippet will hit malformed requests, missing headers, or a wrong URL — silently breaking the documented integration path that ships with every flow. |
| 12 | + |
| 13 | +--- |
| 14 | + |
| 15 | +## Tags *(required)* |
| 16 | + |
| 17 | +`@release` `@workspace` `@stable` |
| 18 | + |
| 19 | +--- |
| 20 | + |
| 21 | +## Step by step *(required)* |
| 22 | + |
| 23 | +1. Bootstrap the app and open the Templates page (`side_nav_options_all-templates`) |
| 24 | +2. Open the `Basic Prompting` template |
| 25 | +3. Click the publish button and open the API access item |
| 26 | +4. Switch to the `cURL` tab (`api_tab_curl`) |
| 27 | +5. Switch the platform sub-tab to `macOS/Linux` to make the output deterministic |
| 28 | +6. Click the Copy icon and read `navigator.clipboard` |
| 29 | +7. Assert the structural shape of the curl command (see Validation criterion) |
| 30 | + |
| 31 | +--- |
| 32 | + |
| 33 | +## Validation criterion *(required)* |
| 34 | + |
| 35 | +The clipboard content must satisfy **all** of the following: |
| 36 | + |
| 37 | +- Starts with `curl --request POST` |
| 38 | +- Contains `--url '<base>/api/v1/run/<UUID>?stream=false'` (UUID matched by `[0-9a-f-]{36}`) |
| 39 | +- Contains `--header 'Content-Type: application/json'` |
| 40 | +- Contains `x-api-key: YOUR_API_KEY_HERE` |
| 41 | +- Contains `--data` |
| 42 | +- Contains `"input_value": "Hello"` (the default value carried over from the Basic Prompting template's ChatInput) |
| 43 | +- Contains `"session_id"` and `"output_type": "chat"` |
| 44 | + |
| 45 | +A bare "clipboard is non-empty" check is insufficient — the previous version of the test was passing while silently copying the PowerShell variant. |
| 46 | + |
| 47 | +--- |
| 48 | + |
| 49 | +## External dependencies *(required)* |
| 50 | + |
| 51 | +- `src/frontend/src/modals/apiModal/utils/get-curl-code.tsx` — `getNewCurlCode` builds the command for both `unix` and `powershell` platforms |
| 52 | +- `src/frontend/src/modals/apiModal/codeTabs/code-tabs.tsx` — renders the cURL tab and the macOS/Linux ↔ Windows platform switch (default driven by `getOS()`) |
| 53 | +- `src/frontend/src/utils/utils.ts` — `getOS()` reads `navigator.platform` to pick the default platform tab |
| 54 | +- `src/backend/base/langflow/api/v1/endpoints.py` — owns `/api/v1/run/{flow_id}`; the URL shape encoded in the curl must keep matching this route |
| 55 | + |
| 56 | +--- |
| 57 | + |
| 58 | +## What this test does not cover *(optional)* |
| 59 | + |
| 60 | +- The Windows/PowerShell variant (different syntax: `$jsonData = @'...'@`, `curl.exe`, backtick line-continuation) |
| 61 | +- Tweaks payload encoding for flows with file-upload nodes (multi-step curl) |
| 62 | +- Actually executing the generated command against the running backend (covered by API tests under `api/flows/`) |
| 63 | +- The Python and JavaScript snippets in the same modal (covered by `pythonApiGeneration.spec.ts`) |
| 64 | + |
| 65 | +--- |
| 66 | + |
| 67 | +## Preconditions *(optional)* |
| 68 | + |
| 69 | +- Langflow running at `PLAYWRIGHT_BASE_URL` |
| 70 | +- No LLM credentials required — only the snippet generator is exercised |
| 71 | +- `clipboard-read` permission is granted globally in `playwright.config.ts` |
| 72 | + |
| 73 | +--- |
| 74 | + |
| 75 | +## When to review this test *(optional)* |
| 76 | + |
| 77 | +- The cURL tab gains a new platform option (e.g., a `bash`-only sub-tab) — the explicit `macOS/Linux` click may need to change |
| 78 | +- `getNewCurlCode` is refactored to drop `--request POST` in favor of `-X POST`, or to switch quoting style |
| 79 | +- The `/api/v1/run/{flow_id}` route is renamed or namespaced |
| 80 | +- The Basic Prompting template's default ChatInput value changes from `"Hello"` — the assertion `"input_value": "Hello"` will need to track it |
| 81 | + |
| 82 | +--- |
| 83 | + |
| 84 | +## Notes *(optional)* |
| 85 | + |
| 86 | +- The platform switch is required because `getOS()` is driven by `navigator.platform`, which can differ between local Chromium runs and CI runners. Without explicitly clicking macOS/Linux, the generated snippet is non-deterministic. |
| 87 | +- The previous version of this test asserted only `clipboardContent.length > 0`, which would pass even if the wrong (PowerShell) variant or empty content was copied. The structural assertions guard against that class of false positive. |
0 commit comments