* refactor: Remove CustomHeader component from AppWrapperPage * refactor: Remove unused code and fix formatting in MainPage component - Remove commented out code and unused imports - Fix indentation and formatting issues in the component * colors update and component building * refactor: Update grid and list components in MainPage - Update grid component in MainPage to use custom navigation hook - Add folderId parameter to editFlowLink in grid component - Update list component in MainPage to use custom navigation hook - Add folderId parameter to editFlowLink in list component Refactor the grid and list components in MainPage to use the custom navigation hook instead of the react-router-dom's useNavigate hook. This allows for better control and customization of navigation within the components. Additionally, the editFlowLink now includes the folderId parameter when navigating to the flow edit page. Closes #<issue_number> * refactor: Update grid and list components in MainPage Refactor the grid and list components in the MainPage to improve performance and enhance user experience. This includes updating the styling, optimizing code, and fixing formatting issues. * Refactor header component to dynamically display folder name * Refactor CSS styles and button component - Update CSS styles in applies.css to adjust the position of the header notifications dot. - Refactor the button component in button.tsx to fix a typo in the class names. Closes #4259 * Refactor folder store and sidebar components * Refactor header component to dynamically toggle folder sidebar visibility * Refactor CSS styles and button component * Refactor CSS styles and button component * Refactor CSS styles to adjust the width of the text container * Refactor dropdown and grid components to handle playground click * Refactor folder sidebar and list components * Refactor CSS styles and components for HeaderMenu, GridComponent, and ListComponent * Refactor CSS styles and components for HeaderMenu, GridComponent, ListComponent, dropdown, and button * Refactor CSS styles to adjust the width of the text container in ListComponent * refactor: Update folder name display in EmptyPage component * refactor: Update folder name display in FlowMenu component * refactor: Update folder name display in AccountMenu and EmptyPage components * refactor: Update folder name display in AccountMenu, EmptyPage, and FlowMenu components * refactor: Update folder name display in AppHeader, DashboardWrapperPage, and HomePage components * refactor: Update folder name display in MainPage components - Update folder name display in AppHeader, DashboardWrapperPage, and HomePage components - Update folder name display in AccountMenu, EmptyPage, and FlowMenu components - Update folder name display in AccountMenu and EmptyPage components - Update folder name display in FlowMenu component - Update folder name display in EmptyPage component Update the folder name display in various components of the MainPage. This ensures that the folder names are correctly displayed in the UI. The affected components include AppHeader, DashboardWrapperPage, HomePage, AccountMenu, EmptyPage, and FlowMenu. This refactor improves the consistency and user experience of the application. * refactor: Update folder name display in EmptyPage and HomePage components * refactor: Update folder name display in AppHeader, DashboardWrapperPage, and HomePage components * refactor: Update folder name display in MainPage components * file organization * Refactor folder name display in MainPage, ListComponent, and HomePage components * Refactor folder name display in MainPage components * test fixes * test fixes part 2
163 lines
5.1 KiB
TypeScript
163 lines
5.1 KiB
TypeScript
import { expect, Page, test } from "@playwright/test";
|
|
import uaParser from "ua-parser-js";
|
|
|
|
// TODO: This component doesn't have slider needs updating
|
|
test.skip("user should be able to use slider input", async ({ page }) => {
|
|
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 Flow", { exact: true }).click();
|
|
await page.waitForTimeout(3000);
|
|
modalCount = await page.getByTestId("modal-title")?.count();
|
|
}
|
|
|
|
const getUA = await page.evaluate(() => navigator.userAgent);
|
|
const userAgentInfo = uaParser(getUA);
|
|
let control = "Control";
|
|
|
|
if (userAgentInfo.os.name.includes("Mac")) {
|
|
control = "Meta";
|
|
}
|
|
|
|
await page.waitForSelector('[data-testid="blank-flow"]', {
|
|
timeout: 30000,
|
|
});
|
|
await page.getByTestId("blank-flow").click();
|
|
await page.getByTestId("sidebar-search-input").click();
|
|
await page.getByTestId("sidebar-search-input").fill("ollama");
|
|
|
|
await page.waitForTimeout(1000);
|
|
|
|
await page
|
|
.getByTestId("modelsOllama")
|
|
.dragTo(page.locator('//*[@id="react-flow-id"]'));
|
|
await page.mouse.up();
|
|
await page.mouse.down();
|
|
await page.getByTestId("fit_view").click();
|
|
await page.getByTestId("zoom_out").click();
|
|
await page.getByTestId("zoom_out").click();
|
|
|
|
await page.getByTestId("title-Ollama").click();
|
|
await page.getByTestId("code-button-modal").click();
|
|
|
|
let cleanCode = await extractAndCleanCode(page);
|
|
|
|
// Replace the import statement
|
|
cleanCode = cleanCode.replace("FloatInput(", "SliderInput(");
|
|
cleanCode = cleanCode.replace(
|
|
"from langflow.io import BoolInput, DictInput, DropdownInput, FloatInput, IntInput, StrInput",
|
|
"from langflow.io import BoolInput, DictInput, DropdownInput, FloatInput, IntInput, StrInput, SliderInput",
|
|
);
|
|
|
|
cleanCode = cleanCode.replace(
|
|
"value=0.2,",
|
|
"value=0.2, range_spec=RangeSpec(min=3, max=30, step=1), min_label='test', max_label='test2', min_label_icon='pencil-ruler', max_label_icon='palette', slider_buttons=False, slider_buttons_options=[], slider_input=False,",
|
|
);
|
|
|
|
await page.locator("textarea").last().press(`${control}+a`);
|
|
await page.keyboard.press("Backspace");
|
|
await page.locator("textarea").last().fill(cleanCode);
|
|
await page.locator('//*[@id="checkAndSaveBtn"]').click();
|
|
await page.waitForTimeout(500);
|
|
|
|
await page.getByTestId("fit_view").click();
|
|
|
|
await mutualValidation(page);
|
|
|
|
await moveSlider(page, "right", false);
|
|
|
|
await page.waitForTimeout(500);
|
|
|
|
await page.getByTestId("zoom_out").click();
|
|
|
|
await page.getByTestId("more-options-modal").click();
|
|
await page.getByText("Controls", { exact: true }).last().click();
|
|
await expect(
|
|
page.getByTestId("default_slider_display_value_advanced"),
|
|
).toHaveText("19.00");
|
|
|
|
await moveSlider(page, "left", true);
|
|
// Wait for any potential updates
|
|
await page.waitForTimeout(500);
|
|
|
|
await expect(
|
|
page.getByTestId("default_slider_display_value_advanced"),
|
|
).toHaveText("14.00");
|
|
|
|
await page.getByText("Close").last().click();
|
|
|
|
await expect(page.getByTestId("default_slider_display_value")).toHaveText(
|
|
"14.00",
|
|
);
|
|
});
|
|
|
|
async function extractAndCleanCode(page: Page): Promise<string> {
|
|
const outerHTML = await page
|
|
.locator('//*[@id="codeValue"]')
|
|
.evaluate((el) => el.outerHTML);
|
|
|
|
const valueMatch = outerHTML.match(/value="([\s\S]*?)"/);
|
|
if (!valueMatch) {
|
|
throw new Error("Could not find value attribute in the HTML");
|
|
}
|
|
|
|
let codeContent = valueMatch[1]
|
|
.replace(/"/g, '"')
|
|
.replace(/&/g, "&")
|
|
.replace(/</g, "<")
|
|
.replace(/>/g, ">")
|
|
.replace(/'/g, "'")
|
|
.replace(///g, "/");
|
|
|
|
return codeContent;
|
|
}
|
|
|
|
async function mutualValidation(page: Page) {
|
|
await expect(page.getByTestId("default_slider_display_value")).toHaveText(
|
|
"3.00",
|
|
);
|
|
await expect(page.getByTestId("min_label")).toHaveText("test");
|
|
await expect(page.getByTestId("max_label")).toHaveText("test2");
|
|
await expect(page.getByTestId("icon-pencil-ruler")).toBeVisible();
|
|
await expect(page.getByTestId("icon-palette")).toBeVisible();
|
|
}
|
|
async function moveSlider(
|
|
page: Page,
|
|
side: "left" | "right",
|
|
advanced: boolean = false,
|
|
) {
|
|
const thumbSelector = `slider_thumb${advanced ? "_advanced" : ""}`;
|
|
const trackSelector = `slider_track${advanced ? "_advanced" : ""}`;
|
|
|
|
await page.getByTestId(thumbSelector).click();
|
|
|
|
const trackBoundingBox = await page.getByTestId(trackSelector).boundingBox();
|
|
|
|
if (trackBoundingBox) {
|
|
const moveDistance =
|
|
trackBoundingBox.width * 0.1 * (side === "left" ? -1 : 1);
|
|
const centerX = trackBoundingBox.x + trackBoundingBox.width / 2;
|
|
const centerY = trackBoundingBox.y + trackBoundingBox.height / 2;
|
|
|
|
await page.mouse.move(centerX + moveDistance, centerY);
|
|
await page.mouse.down();
|
|
await page.mouse.up();
|
|
}
|
|
}
|