Refactor API generation tests
This commit is contained in:
parent
a3924d657c
commit
76dbaf3b21
5 changed files with 104 additions and 84 deletions
|
|
@ -5,42 +5,42 @@ test.beforeEach(async ({ page }) => {
|
|||
// test.setTimeout(120000);
|
||||
});
|
||||
test("chat_io_teste", async ({ page }) => {
|
||||
await page.goto("/");
|
||||
await page.locator("span").filter({ hasText: "My Collection" }).isVisible();
|
||||
// Read your file into a buffer.
|
||||
const jsonContent = readFileSync(
|
||||
"tests/end-to-end/assets/ChatTest.json",
|
||||
"utf-8"
|
||||
);
|
||||
await page.goto("/");
|
||||
await page.locator("span").filter({ hasText: "My Collection" }).isVisible();
|
||||
// Read your file into a buffer.
|
||||
const jsonContent = readFileSync(
|
||||
"tests/end-to-end/assets/ChatTest.json",
|
||||
"utf-8"
|
||||
);
|
||||
|
||||
// Create the DataTransfer and File
|
||||
const dataTransfer = await page.evaluateHandle((data) => {
|
||||
const dt = new DataTransfer();
|
||||
// Convert the buffer to a hex array
|
||||
const file = new File([data], "ChatTest.json", {
|
||||
type: "application/json",
|
||||
});
|
||||
dt.items.add(file);
|
||||
return dt;
|
||||
}, jsonContent);
|
||||
// Create the DataTransfer and File
|
||||
const dataTransfer = await page.evaluateHandle((data) => {
|
||||
const dt = new DataTransfer();
|
||||
// Convert the buffer to a hex array
|
||||
const file = new File([data], "ChatTest.json", {
|
||||
type: "application/json",
|
||||
});
|
||||
dt.items.add(file);
|
||||
return dt;
|
||||
}, jsonContent);
|
||||
|
||||
await page.locator('//*[@id="new-project-btn"]').click();
|
||||
await page.waitForTimeout(2000);
|
||||
|
||||
await page.getByTestId("blank-flow").click();
|
||||
await page.waitForTimeout(2000);
|
||||
await page.locator('//*[@id="new-project-btn"]').click();
|
||||
await page.waitForTimeout(2000);
|
||||
|
||||
// Now dispatch
|
||||
await page.dispatchEvent(
|
||||
'//*[@id="react-flow-id"]/div[1]/div[1]/div',
|
||||
"drop",
|
||||
{
|
||||
dataTransfer,
|
||||
}
|
||||
);
|
||||
await page.getByLabel('fit view').click();
|
||||
await page.getByText('Run', { exact: true }).click();
|
||||
await page.getByPlaceholder('Send a message...').click();
|
||||
await page.getByPlaceholder('Send a message...').fill('teste');
|
||||
await page.getByRole('button').nth(1).click();
|
||||
await page.getByTestId("blank-flow").click();
|
||||
await page.waitForTimeout(2000);
|
||||
|
||||
// Now dispatch
|
||||
await page.dispatchEvent(
|
||||
'//*[@id="react-flow-id"]/div[1]/div[1]/div',
|
||||
"drop",
|
||||
{
|
||||
dataTransfer,
|
||||
}
|
||||
);
|
||||
await page.getByLabel("fit view").click();
|
||||
await page.getByText("Run", { exact: true }).click();
|
||||
await page.getByPlaceholder("Send a message...").click();
|
||||
await page.getByPlaceholder("Send a message...").fill("teste");
|
||||
await page.getByRole("button").nth(1).click();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -28,21 +28,31 @@ test("CodeAreaModalComponent", async ({ page }) => {
|
|||
await page.getByTestId("code-button-modal").click();
|
||||
|
||||
let value = await page.locator('//*[@id="codeValue"]').inputValue();
|
||||
const code = 'def python_function(text: str) -> str:\n """This is a default python function that returns the input text"""\n return text'
|
||||
const wCode = 'def python_function(text: str) -> st: """This is a default python function that returns the input text""" return text'
|
||||
const assertCode ='def python_function(text: str) -> str: """This is a default python function that returns the input text""" return text'
|
||||
await page.locator('#CodeEditor div').filter({ hasText: 'def python_function(text: str' }).nth(1).click();
|
||||
await page.locator('textarea').press('Control+a');
|
||||
await page.locator('textarea').fill(wCode);
|
||||
const code =
|
||||
'def python_function(text: str) -> str:\n """This is a default python function that returns the input text"""\n return text';
|
||||
const wCode =
|
||||
'def python_function(text: str) -> st: """This is a default python function that returns the input text""" return text';
|
||||
const assertCode =
|
||||
'def python_function(text: str) -> str: """This is a default python function that returns the input text""" return text';
|
||||
await page
|
||||
.locator("#CodeEditor div")
|
||||
.filter({ hasText: "def python_function(text: str" })
|
||||
.nth(1)
|
||||
.click();
|
||||
await page.locator("textarea").press("Control+a");
|
||||
await page.locator("textarea").fill(wCode);
|
||||
await page.locator('//*[@id="checkAndSaveBtn"]').click();
|
||||
await page.waitForTimeout(1000);
|
||||
expect(await page.getByText("invalid syntax (<unknown>, line 1)").isVisible()).toBeTruthy();
|
||||
await page.locator('textarea').press('Control+a');
|
||||
await page.locator('textarea').fill(wCode);
|
||||
await page.locator('textarea').fill(code);
|
||||
expect(
|
||||
await page.getByText("invalid syntax (<unknown>, line 1)").isVisible()
|
||||
).toBeTruthy();
|
||||
await page.locator("textarea").press("Control+a");
|
||||
await page.locator("textarea").fill(wCode);
|
||||
await page.locator("textarea").fill(code);
|
||||
await page.locator('//*[@id="checkAndSaveBtn"]').click();
|
||||
expect(await page.getByText("Code is ready to run").isVisible()).toBeTruthy();
|
||||
await page.getByTestId("code-button-modal").click();
|
||||
expect(await page.locator('//*[@id="codeValue"]').inputValue()).toBe(assertCode);
|
||||
|
||||
});
|
||||
expect(await page.locator('//*[@id="codeValue"]').inputValue()).toBe(
|
||||
assertCode
|
||||
);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
import { test, expect } from '@playwright/test';
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
|
||||
test('curl_api_generation', async ({ page,context }) => {
|
||||
test("curl_api_generation", async ({ page, context }) => {
|
||||
await page.goto("/");
|
||||
await page.locator('//*[@id="new-project-btn"]').click();
|
||||
await context.grantPermissions(["clipboard-read", "clipboard-write"]);
|
||||
await page.getByRole('heading', { name: 'Data Ingestion' }).click();
|
||||
await page.getByRole("heading", { name: "Data Ingestion" }).click();
|
||||
await page.waitForTimeout(2000);
|
||||
await page.getByText('API', { exact: true }).click();
|
||||
await page.getByRole('tab', { name: 'cURL' }).click();
|
||||
await page.getByRole('button', { name: 'Copy Code' }).click();
|
||||
const handle = await page.evaluateHandle(() => navigator.clipboard.readText());
|
||||
await page.getByText("API", { exact: true }).click();
|
||||
await page.getByRole("tab", { name: "cURL" }).click();
|
||||
await page.getByRole("button", { name: "Copy Code" }).click();
|
||||
const handle = await page.evaluateHandle(() =>
|
||||
navigator.clipboard.readText()
|
||||
);
|
||||
const clipboardContent = await handle.jsonValue();
|
||||
expect(clipboardContent.length).toBeGreaterThan(0);
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
import { test, expect } from '@playwright/test';
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
|
||||
test('python_api_generation', async ({ page,context }) => {
|
||||
test("python_api_generation", async ({ page, context }) => {
|
||||
await page.goto("/");
|
||||
await page.locator('//*[@id="new-project-btn"]').click();
|
||||
await context.grantPermissions(["clipboard-read", "clipboard-write"]);
|
||||
await page.getByRole('heading', { name: 'Data Ingestion' }).click();
|
||||
await page.getByRole("heading", { name: "Data Ingestion" }).click();
|
||||
await page.waitForTimeout(2000);
|
||||
await page.getByText('API', { exact: true }).click();
|
||||
await page.getByRole('tab', { name: 'Python API' }).click();
|
||||
await page.getByRole('button', { name: 'Copy Code' }).click();
|
||||
const handle = await page.evaluateHandle(() => navigator.clipboard.readText());
|
||||
await page.getByText("API", { exact: true }).click();
|
||||
await page.getByRole("tab", { name: "Python API" }).click();
|
||||
await page.getByRole("button", { name: "Copy Code" }).click();
|
||||
const handle = await page.evaluateHandle(() =>
|
||||
navigator.clipboard.readText()
|
||||
);
|
||||
const clipboardContent = await handle.jsonValue();
|
||||
expect(clipboardContent.length).toBeGreaterThan(0);
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,28 +1,38 @@
|
|||
import { test, expect } from '@playwright/test';
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
test('curl_api_generation', async ({ page,context }) => {
|
||||
test("curl_api_generation", async ({ page, context }) => {
|
||||
await page.goto("/");
|
||||
await page.locator('//*[@id="new-project-btn"]').click();
|
||||
await context.grantPermissions(["clipboard-read", "clipboard-write"]);
|
||||
await page.getByRole('heading', { name: 'Data Ingestion' }).click();
|
||||
await page.getByRole("heading", { name: "Data Ingestion" }).click();
|
||||
await page.waitForTimeout(2000);
|
||||
await page.getByText('API', { exact: true }).click();
|
||||
await page.getByRole('tab', { name: 'cURL' }).click();
|
||||
await page.getByRole('button', { name: 'Copy Code' }).click();
|
||||
const handle = await page.evaluateHandle(() => navigator.clipboard.readText());
|
||||
await page.getByText("API", { exact: true }).click();
|
||||
await page.getByRole("tab", { name: "cURL" }).click();
|
||||
await page.getByRole("button", { name: "Copy Code" }).click();
|
||||
const handle = await page.evaluateHandle(() =>
|
||||
navigator.clipboard.readText()
|
||||
);
|
||||
const clipboardContent = await handle.jsonValue();
|
||||
const oldValue = clipboardContent;
|
||||
expect(clipboardContent.length).toBeGreaterThan(0);
|
||||
await page.getByRole('tab', { name: 'Tweaks' }).click();
|
||||
await page.getByRole('heading', { name: 'URL' }).locator('div').first().click();
|
||||
await page.getByRole('textbox', { name: 'Type something...' }).click();
|
||||
await page.getByRole('textbox', { name: 'Type something...' }).press('Control+a');
|
||||
await page.getByRole('textbox', { name: 'Type something...' }).fill('teste');
|
||||
await page.getByRole('tab', { name: 'cURL' }).click();
|
||||
await page.getByRole('button', { name: 'Copy Code' }).click();
|
||||
const handle2 = await page.evaluateHandle(() => navigator.clipboard.readText());
|
||||
await page.getByRole("tab", { name: "Tweaks" }).click();
|
||||
await page
|
||||
.getByRole("heading", { name: "URL" })
|
||||
.locator("div")
|
||||
.first()
|
||||
.click();
|
||||
await page.getByRole("textbox", { name: "Type something..." }).click();
|
||||
await page
|
||||
.getByRole("textbox", { name: "Type something..." })
|
||||
.press("Control+a");
|
||||
await page.getByRole("textbox", { name: "Type something..." }).fill("teste");
|
||||
await page.getByRole("tab", { name: "cURL" }).click();
|
||||
await page.getByRole("button", { name: "Copy Code" }).click();
|
||||
const handle2 = await page.evaluateHandle(() =>
|
||||
navigator.clipboard.readText()
|
||||
);
|
||||
const clipboardContent2 = await handle2.jsonValue();
|
||||
const newValue = clipboardContent2;
|
||||
expect(oldValue).not.toBe(newValue);
|
||||
expect(clipboardContent2.length).toBeGreaterThan(clipboardContent.length);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue