* add-note * notes * vector-store-rag-notes * vector-store-rag-notes * comma * comma * revert * add-notes * another-way * revert * revert * fix * descriptions * lightbulb * deployed-size * size * size * resizing-is-true * targethandle * double * set-components * pin * notes * fix * dont-change-code * cleanup * update example * fix postion on example * fix-descriptions * swap-link * newline-and-lightbulb * another-docs-link * play-button * remove-double * update NODE_FORMAT_ATTRIBUTES to prevent description updates on examples * Update AstraDB documentation link * update documentation on code * ✨ (chatInputOutputUser-shard-0.spec.ts): update the test to click on the last element with the text "Playground" to ensure correct element is clicked * 🐛 (Basic Prompting.spec.ts): fix clicking on "Playground" element by selecting the last occurrence to ensure correct element is clicked * ✨ (Blog Writer.spec.ts): update test to click on the last element with text "Playground" to ensure correct element is clicked on the page * ✨ (Dynamic Agent.spec.ts): update test to click on the last element with text "Playground" to ensure correct element is clicked on the page * 🐛 (decisionFlow.spec.ts): fix clicking on "Playground" button by selecting the last element with the text "Playground" to ensure correct element is clicked * 🐛 (generalBugs-shard-3.spec.ts): fix clicking on "Playground" button by selecting the last occurrence to prevent ambiguity * 🐛 (generalBugs-shard-0.spec.ts): fix clicking on "Playground" button by selecting the last element with the text "Playground" to ensure correct element is clicked * 🐛 (general-bugs-shard-3836.spec.ts): fix clicking on "Playground" button by selecting the last element with the text "Playground" to ensure correct element is clicked * ✨ (chatInputOutputUser-shard-2.spec.ts): update test to click on the last element with text "Playground" to ensure correct interaction with chat input/output feature * ✨ (stop-button-playground.spec.ts): update test to click on the last occurrence of the text "Playground" to ensure correct element is clicked * 🐛 (limit-file-size-upload.spec.ts): fix selector to click on the last element with text "Playground" instead of the first one * ✨ (fileUploadComponent.spec.ts): update test to click on the last element with text "Playground" to ensure correct element is clicked on the page * ✨ (chatInputOutput.spec.ts): update test to click on the last occurrence of the "Playground" text to ensure correct element is clicked * 🐛 (generalBugs-shard-9.spec.ts): fix clicking on "Playground" element by selecting the last occurrence to prevent flakiness in tests * 🐛 (Document QA.spec.ts): fix clicking on "Playground" element by selecting the last occurrence to ensure correct element is clicked * ✨ (similarity.spec.ts): update click method to target the last occurrence of "Playground" text to ensure correct element is clicked * 🐛 (Simple Agent.spec.ts): fix clicking on "Playground" button by selecting the last element with the text to avoid ambiguity * ✨ (textInputOutput.spec.ts): update test script to target the last occurrence of the "Playground" text element to ensure correct interaction with the UI. * ✨ (Travel Planning Agent.spec.ts): Update the selector for the "Playground" text to ensure the correct element is clicked on the page. * 🐛 (Vector Store.spec.ts): fix clicking on "Playground" element by selecting the last one to avoid ambiguity * ✨ (generalBugs-shard-9.spec.ts): add click action on the last element with test id "title-Prompt" to improve test coverage and interaction with the page --------- Co-authored-by: anovazzi1 <otavio2204@gmail.com> Co-authored-by: cristhianzl <cristhian.lousa@gmail.com>
239 lines
6.6 KiB
TypeScript
239 lines
6.6 KiB
TypeScript
import { expect, test } from "@playwright/test";
|
|
import * as dotenv from "dotenv";
|
|
import path from "path";
|
|
|
|
test("TextInputOutputComponent", async ({ page }) => {
|
|
test.skip(
|
|
!process?.env?.OPENAI_API_KEY,
|
|
"OPENAI_API_KEY required to run this test",
|
|
);
|
|
|
|
if (!process.env.CI) {
|
|
dotenv.config({ path: path.resolve(__dirname, "../../.env") });
|
|
}
|
|
|
|
await page.goto("/");
|
|
await page.waitForSelector('[data-testid="mainpage_title"]', {
|
|
timeout: 30000,
|
|
});
|
|
|
|
await page.waitForSelector('[id="new-project-btn"]', {
|
|
timeout: 30000,
|
|
});
|
|
|
|
let modalCount = 0;
|
|
try {
|
|
const modalTitleElement = await page?.getByTestId("modal-title");
|
|
if (modalTitleElement) {
|
|
modalCount = await modalTitleElement.count();
|
|
}
|
|
} catch (error) {
|
|
modalCount = 0;
|
|
}
|
|
|
|
while (modalCount === 0) {
|
|
await page.getByText("New Project", { exact: true }).click();
|
|
await page.waitForTimeout(3000);
|
|
modalCount = await page.getByTestId("modal-title")?.count();
|
|
}
|
|
|
|
await page.waitForSelector('[data-testid="blank-flow"]', {
|
|
timeout: 30000,
|
|
});
|
|
await page.getByTestId("blank-flow").click();
|
|
await page.waitForSelector('[data-testid="extended-disclosure"]', {
|
|
timeout: 30000,
|
|
});
|
|
|
|
const focusElementsOnBoard = async ({ page }) => {
|
|
const focusElements = await page.getByTestId("extended-disclosure");
|
|
focusElements.click();
|
|
};
|
|
|
|
await focusElementsOnBoard({ page });
|
|
|
|
await page.getByPlaceholder("Search").click();
|
|
await page.getByPlaceholder("Search").fill("text input");
|
|
await page.waitForTimeout(1000);
|
|
|
|
await page
|
|
.getByTestId("inputsText Input")
|
|
.dragTo(page.locator('//*[@id="react-flow-id"]'));
|
|
await page.mouse.up();
|
|
await page.mouse.down();
|
|
|
|
await page.getByPlaceholder("Search").click();
|
|
await page.getByPlaceholder("Search").fill("openai");
|
|
await page.waitForTimeout(1000);
|
|
|
|
await page
|
|
.getByTestId("modelsOpenAI")
|
|
.dragTo(page.locator('//*[@id="react-flow-id"]'));
|
|
await page.mouse.up();
|
|
await page.mouse.down();
|
|
|
|
await page.waitForSelector('[title="fit view"]', {
|
|
timeout: 100000,
|
|
});
|
|
|
|
await page.getByTitle("fit view").click();
|
|
await page.getByTitle("zoom out").click();
|
|
await page.getByTitle("zoom out").click();
|
|
await page.getByTitle("zoom out").click();
|
|
|
|
let visibleElementHandle;
|
|
|
|
const elementsTextInputOutput = await page
|
|
.getByTestId("handle-textinput-shownode-text-right")
|
|
.all();
|
|
|
|
for (const element of elementsTextInputOutput) {
|
|
if (await element.isVisible()) {
|
|
visibleElementHandle = element;
|
|
break;
|
|
}
|
|
}
|
|
|
|
await visibleElementHandle.waitFor({
|
|
state: "visible",
|
|
timeout: 30000,
|
|
});
|
|
|
|
await visibleElementHandle.hover();
|
|
await page.mouse.down();
|
|
|
|
for (const element of elementsTextInputOutput) {
|
|
if (await element.isVisible()) {
|
|
visibleElementHandle = element;
|
|
break;
|
|
}
|
|
}
|
|
|
|
await visibleElementHandle.waitFor({
|
|
state: "visible",
|
|
timeout: 30000,
|
|
});
|
|
|
|
// Move to the second element
|
|
await visibleElementHandle.hover();
|
|
|
|
// Release the mouse
|
|
await page.mouse.up();
|
|
|
|
await page.getByPlaceholder("Search").click();
|
|
await page.getByPlaceholder("Search").fill("text output");
|
|
|
|
await page
|
|
.getByTestId("outputsText Output")
|
|
.dragTo(page.locator('//*[@id="react-flow-id"]'));
|
|
await page.mouse.up();
|
|
await page.mouse.down();
|
|
|
|
await page.waitForSelector('[title="fit view"]', {
|
|
timeout: 100000,
|
|
});
|
|
|
|
await page.getByTitle("zoom out").click();
|
|
await page.getByTitle("zoom out").click();
|
|
await page.getByTitle("zoom out").click();
|
|
await page.getByTitle("zoom out").click();
|
|
await page.getByTitle("zoom out").click();
|
|
await page.getByTitle("zoom out").click();
|
|
|
|
const elementsOpenAiOutput = await page
|
|
.getByTestId("handle-openaimodel-shownode-text-right")
|
|
.all();
|
|
|
|
for (const element of elementsOpenAiOutput) {
|
|
if (await element.isVisible()) {
|
|
visibleElementHandle = element;
|
|
break;
|
|
}
|
|
}
|
|
|
|
await visibleElementHandle.waitFor({
|
|
state: "visible",
|
|
timeout: 30000,
|
|
});
|
|
|
|
// Click and hold on the first element
|
|
await visibleElementHandle.hover();
|
|
await page.mouse.down();
|
|
|
|
const elementTextOutputInput = await page
|
|
.getByTestId("handle-textoutput-shownode-text-left")
|
|
.all();
|
|
|
|
for (const element of elementTextOutputInput) {
|
|
if (await element.isVisible()) {
|
|
visibleElementHandle = element;
|
|
break;
|
|
}
|
|
}
|
|
|
|
await visibleElementHandle.waitFor({
|
|
state: "visible",
|
|
timeout: 30000,
|
|
});
|
|
|
|
// Move to the second element
|
|
await visibleElementHandle.hover();
|
|
|
|
// Release the mouse
|
|
await page.mouse.up();
|
|
|
|
await page
|
|
.getByTestId(/^rf__node-TextInput-[a-zA-Z0-9]+$/)
|
|
.getByTestId("textarea_str_input_value")
|
|
.fill("This is a test!");
|
|
|
|
let outdatedComponents = await page.getByTestId("icon-AlertTriangle").count();
|
|
|
|
while (outdatedComponents > 0) {
|
|
await page.getByTestId("icon-AlertTriangle").first().click();
|
|
await page.waitForTimeout(1000);
|
|
outdatedComponents = await page.getByTestId("icon-AlertTriangle").count();
|
|
}
|
|
|
|
await page
|
|
.getByTestId("popover-anchor-input-api_key")
|
|
.fill(process.env.OPENAI_API_KEY ?? "");
|
|
|
|
await page.getByTestId("dropdown_str_model_name").click();
|
|
await page.getByTestId("gpt-4o-1-option").click();
|
|
|
|
await page.waitForTimeout(1000);
|
|
await page.getByText("Playground", { exact: true }).last().click();
|
|
await page.getByText("Run Flow", { exact: true }).click();
|
|
|
|
await page.waitForTimeout(5000);
|
|
|
|
let textInputContent = await page
|
|
.getByPlaceholder("Enter text...")
|
|
.textContent();
|
|
expect(textInputContent).toBe("This is a test!");
|
|
|
|
await page.getByText("Outputs", { exact: true }).nth(1).click();
|
|
await page.getByText("Text Output", { exact: true }).nth(2).click();
|
|
let contentOutput = await page.getByPlaceholder("Enter text...").inputValue();
|
|
expect(contentOutput).not.toBe(null);
|
|
|
|
await page.keyboard.press("Escape");
|
|
|
|
await page
|
|
.getByTestId(/^rf__node-TextInput-[a-zA-Z0-9]+$/)
|
|
.getByTestId("textarea_str_input_value")
|
|
.fill("This is a test, again just to be sure!");
|
|
await page.getByText("Playground", { exact: true }).last().click();
|
|
await page.getByText("Run Flow", { exact: true }).click();
|
|
|
|
await page.waitForTimeout(5000);
|
|
|
|
textInputContent = await page.getByPlaceholder("Enter text...").textContent();
|
|
expect(textInputContent).toBe("This is a test, again just to be sure!");
|
|
|
|
await page.getByText("Outputs", { exact: true }).nth(1).click();
|
|
await page.getByText("Text Output", { exact: true }).nth(2).click();
|
|
contentOutput = await page.getByPlaceholder("Enter text...").inputValue();
|
|
expect(contentOutput).not.toBe(null);
|
|
});
|