-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcurlApiGeneration.spec.ts
More file actions
47 lines (41 loc) · 1.87 KB
/
Copy pathcurlApiGeneration.spec.ts
File metadata and controls
47 lines (41 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { expect, test } from "../../../fixtures/fixtures";
import { awaitBootstrapTest } from "../../../helpers/other/await-bootstrap-test";
test(
"user can copy a valid macOS/Linux curl command from the API access modal",
{ tag: ["@release", "@workspace", "@stable"] },
async ({ page }) => {
await test.step("Open the Basic Prompting template", async () => {
await awaitBootstrapTest(page);
await page.getByTestId("side_nav_options_all-templates").click();
await page.getByRole("heading", { name: "Basic Prompting" }).click();
});
await test.step("Open the API access modal on the cURL tab", async () => {
await page.getByTestId("publish-button").click();
await page.getByTestId("api-access-item").click();
await page.getByTestId("api_tab_curl").click();
});
await test.step("Force the macOS/Linux platform variant", async () => {
await page.getByRole("tab", { name: "macOS/Linux" }).click();
});
await test.step("Copy the generated command to the clipboard", async () => {
await page.getByTestId("icon-Copy").last().click();
});
const clipboardContent = await page.evaluate(() =>
navigator.clipboard.readText(),
);
await test.step("Validate the curl command structure", async () => {
expect(clipboardContent).toMatch(/^curl --request POST/);
expect(clipboardContent).toMatch(
/--url '[^']*\/api\/v1\/run\/[0-9a-f-]{36}\?stream=false'/,
);
expect(clipboardContent).toContain(
"--header 'Content-Type: application/json'",
);
expect(clipboardContent).toContain("x-api-key: YOUR_API_KEY_HERE");
expect(clipboardContent).toContain("--data");
expect(clipboardContent).toContain('"input_value": "Hello"');
expect(clipboardContent).toContain('"session_id"');
expect(clipboardContent).toContain('"output_type": "chat"');
});
},
);