langflow/src/frontend/tests/extended/integrations/chatInputOutputUser-shard-1.spec.ts
Edwin Jose fd73cdcd7e
ref: URL and File components with Dataframe output (#8117)
* url component update.

* update to url component and tests

* Make directory component legacy

* Only output dataframe from file component

* Update base_file.py

* Update description and output

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* Deprecate Processing Components.

* Move Tool and CQL Astra to bundle

* Comprehensive improvements to Save to File

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* Clean up description, dont unlink file

* Remove print statement

* fix: Clean up the text output of the URL component (#8158)

* Clean text output from url component

* [autofix.ci] apply automated fixes

* Update data.py

* Make a visible function

* URL component cleaning refactor

* Update data.py

* [autofix.ci] apply automated fixes

* Update with chat output fixes and template updates

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes

* Fix linting issues

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>

* revert datastax component bundle

* Restore the two tools as well

* Two more template updates

* Update Vector Store RAG.json

* Update Vector Store RAG.json

* Update __init__.py

* Update directory.py

* Update url.py

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* Update test_basic_prompting.py

* Unit test updates

* Fix unit tests one more time

* Fix conversion in safe convert

* Update chat.py

* Temporary disabling of save to file tests

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* Fix some more unit tests

* Update test_split_text_component.py

* [autofix.ci] apply automated fixes

* Update test_url_component.py

* Update file component outputs in tests

* Fix starter projects with old data to message

* Update test_split_text_component.py

* fix slider inputs

* Update data.py

* [autofix.ci] apply automated fixes

* Update data.py

* 🐛 (typescript_test.yml): increase the maximum shard count to 40 to improve test distribution and performance

* Rename safe file component

* [autofix.ci] apply automated fixes

* Make sure we import the right save to file

* 🔧 (freeze.spec.ts): update test description to match the changed element's test ID
🔧 (Blog Writer.spec.ts): add click event to test file input element
🔧 (edit-tools.spec.ts): update assertion to check if rowsCount is greater than 2 instead of 3
🔧 (loop-component.spec.ts): add import statement for uploadFile function
🔧 (tool-mode.spec.ts): update targetPosition coordinates for dragTo action
🔧 (chatInputOutputUser-shard-1.spec.ts): update test description to match the changed element's test ID

*  (stop-building.spec.ts): update click target for better test coverage and accuracy
 (fileUploadComponent.spec.ts): adjust drag target position and update click targets for improved testing flow and coverage

* 🐛 (typescript_test.yml): adjust the maximum shard count to 10 to prevent excessive parallelization and improve test performance

* Two url component types

* Update ruff formatting

* [autofix.ci] apply automated fixes

* Revert name of method

* 🐛 (typescript_test.yml): increase the maximum shard count to 40 to improve test distribution and performance

*  (freeze.spec.ts): update test to use correct testid for element
 (stop-building.spec.ts): update test to use correct testid for element
 (loop-component.spec.ts): update test to use correct testid for element
 (chatInputOutputUser-shard-1.spec.ts): update tests to use correct testid for element

*  (freeze.spec.ts, stop-building.spec.ts, loop-component.spec.ts, chatInputOutputUser-shard-1.spec.ts): update test selectors to match changes in the frontend UI, improving test reliability and maintainability.

*  (stop-building.spec.ts): update test to use correct testId for clicking element
 (loop-component.spec.ts): update test to use correct testId for clicking element
 (chatInputOutputUser-shard-1.spec.ts): update multiple tests to use correct testId for clicking element

* 📝 (freeze.spec.ts): update test selector to match the correct element on the page for better test accuracy

* 🔧 (typescript_test.yml): adjust optimal shard count calculation to ensure a maximum of 10 shards for test execution
🔧 (chatInputOutputUser-shard-1.spec.ts): update test selectors to match changes in the frontend output structure for integration tests

*  (chatInputOutputUser-shard-1.spec.ts): update test selectors for better clarity and consistency in the integration tests.

---------

Co-authored-by: Eric Hare <ericrhare@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: cristhianzl <cristhian.lousa@gmail.com>
2025-05-30 21:56:14 +00:00

219 lines
6.3 KiB
TypeScript

import { expect, test } from "@playwright/test";
import * as dotenv from "dotenv";
import path from "path";
import { awaitBootstrapTest } from "../../utils/await-bootstrap-test";
import { initialGPTsetup } from "../../utils/initialGPTsetup";
test(
"user must be able to see output inspection",
{ tag: ["@release", "@components"] },
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 awaitBootstrapTest(page);
await page.getByTestId("side_nav_options_all-templates").click();
await page.getByRole("heading", { name: "Basic Prompting" }).click();
await page.waitForSelector('[data-testid="fit_view"]', {
timeout: 100000,
});
await initialGPTsetup(page);
await page.getByTestId("button_run_chat output").last().click();
await page.waitForTimeout(600);
await page.waitForSelector("text=built successfully", {
timeout: 30000 * 3,
});
await page.waitForSelector('[data-testid="icon-TextSearchIcon"]', {
timeout: 30000,
});
await page.getByTestId("icon-TextSearchIcon").nth(2).click();
await page.getByText("Sender", { exact: true }).isVisible();
await page.getByText("Type", { exact: true }).isVisible();
await page.getByText("User", { exact: true }).last().isVisible();
},
);
test(
"user must be able to see output inspection using 'o' shortcut",
{ tag: ["@release", "@components"] },
async ({ page }) => {
await awaitBootstrapTest(page);
await page.getByTestId("blank-flow").click();
// Add URL component
await page.getByTestId("sidebar-search-input").click();
await page.getByTestId("sidebar-search-input").fill("url");
await page.waitForSelector('[data-testid="dataURL"]', {
timeout: 3000,
});
await page
.getByTestId("dataURL")
.dragTo(page.locator('//*[@id="react-flow-id"]'), {
targetPosition: { x: 300, y: 200 },
});
await page.waitForTimeout(1000);
// Get URL node ID
const urlNode = await page.locator(".react-flow__node").first();
const urlNodeId = await urlNode.getAttribute("data-id");
// Add two chat outputs
await page.getByTestId("sidebar-search-input").click();
await page.getByTestId("sidebar-search-input").fill("chat output");
await page.waitForSelector('[data-testid="input_outputChat Output"]', {
timeout: 1000,
});
await page.waitForTimeout(1000);
await page
.getByTestId("input_outputChat Output")
.dragTo(page.locator('//*[@id="react-flow-id"]'), {
targetPosition: { x: 700, y: 200 },
});
await page.waitForTimeout(1000);
await page
.getByTestId("input_outputChat Output")
.dragTo(page.locator('//*[@id="react-flow-id"]'), {
targetPosition: { x: 700, y: 400 },
});
await page.getByTestId("fit_view").click();
// Fill URL input
await page
.getByTestId("inputlist_str_urls_0")
.fill("https://www.example.com");
await page.getByTestId("handle-urlcomponent-shownode-result-right").click();
await page.waitForTimeout(600);
await page
.getByTestId("handle-chatoutput-noshownode-text-target")
.nth(0)
.click();
await page.waitForTimeout(1000);
// Run flow and test text output inspection
await page.getByTestId("button_run_url").first().click();
await page.waitForSelector("text=built successfully", {
timeout: 30000 * 3,
});
await page.keyboard.press("o");
await page.getByText(`Inspect the output of the component below.`, {
exact: true,
});
await page.getByText(`Component Output`, {
exact: true,
});
await page.getByText("Close").first().click();
await page.getByTestId("handle-urlcomponent-shownode-result-right").click();
await page
.getByTestId("handle-chatoutput-noshownode-text-target")
.nth(1)
.click();
await page.waitForTimeout(2000);
// Run and verify text output is still shown
await page.getByTestId("button_run_url").first().click();
await page.waitForSelector("text=built successfully", {
timeout: 30000 * 3,
});
await page.getByTestId("handle-urlcomponent-shownode-result-right").click();
await page.waitForTimeout(600);
await page.getByTestId("handle-urlcomponent-shownode-result-right").click();
await page
.getByTestId("output-inspection-result-urlcomponent")
.nth(0)
.click();
await page.getByText(`Inspect the output of the component below.`, {
exact: true,
});
await page.getByText(`Component Output`, {
exact: true,
});
await page.getByText("Close").first().click();
await page.waitForTimeout(600);
await page
.getByTestId("handle-urlcomponent-shownode-result-right")
.nth(0)
.click();
await page
.getByTestId("handle-chatoutput-noshownode-text-target")
.nth(1)
.click();
// Run and verify dataframe output is now shown
await page.getByTestId("button_run_url").first().click();
await page.waitForSelector("text=built successfully", {
timeout: 30000 * 3,
});
await page.waitForTimeout(600);
await page.getByTestId("output-inspection-result-urlcomponent").click();
await page.getByText(`Inspect the output of the component below.`, {
exact: true,
});
await page.getByText(`Component Output`, {
exact: true,
});
await page.getByText("Close").first().click();
await page.waitForTimeout(600);
// Remove all connections
const dataEdge = await page.locator(".react-flow__edge").first();
await dataEdge.click();
await page.keyboard.press("Backspace");
await page.waitForTimeout(5000);
// Run and verify data output is shown
await page.getByTestId("button_run_url").first().click();
await page.waitForSelector("text=built successfully", {
timeout: 30000 * 3,
});
await page.waitForTimeout(600);
await page.keyboard.press("o");
await page.getByText(`Inspect the output of the component below.`, {
exact: true,
});
await page.getByText(`Component Output`, {
exact: true,
});
const closeButton = await page
.getByText(`Close`, {
exact: true,
})
.count();
expect(closeButton).toBeGreaterThanOrEqual(0);
},
);