fix(nightly): refactor freeze-path feature test (#5557)

This commit is contained in:
Cristhian Zanforlin Lousa 2025-01-06 15:59:29 -03:00 committed by GitHub
commit 2ed0b10679
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 47 additions and 6 deletions

View file

@ -216,6 +216,7 @@ export default function SliderComponent({
onKeyDown={handleKeyDown}
className="relative bottom-[1px] w-full cursor-text rounded-sm bg-transparent text-center font-mono text-[0.88rem] arrow-hide"
autoFocus
data-testid="slider_input"
/>
) : (
<span

View file

@ -2,6 +2,7 @@ import { expect, test } from "@playwright/test";
import * as dotenv from "dotenv";
import path from "path";
import { awaitBootstrapTest } from "../../utils/await-bootstrap-test";
import { evaluateReactStateChanges } from "../../utils/evaluate-input-react-state-changes";
import { initialGPTsetup } from "../../utils/initialGPTsetup";
test(
@ -35,11 +36,22 @@ test(
await page.getByTestId("dropdown_str_model_name").click();
await page.getByTestId("gpt-4o-1-option").click();
await page.waitForSelector('[data-testid="float_float_temperature"]', {
await page.waitForSelector('[data-testid="default_slider_display_value"]', {
timeout: 1000,
});
await page.getByTestId("float_float_temperature").fill("1.0");
await page.getByTestId("fit_view").click();
await page
.getByTestId("default_slider_display_value")
.click({ force: true });
await evaluateReactStateChanges(
page,
'[data-testid="slider_input"]',
"1.0",
);
await page.keyboard.press("Enter");
await page.waitForSelector('[data-testid="button_run_chat output"]', {
timeout: 1000,
@ -62,12 +74,15 @@ test(
await page.getByText("Close").first().click();
await page.waitForSelector('[data-testid="float_float_temperature"]', {
timeout: 3000,
await page.waitForSelector('[data-testid="default_slider_display_value"]', {
timeout: 1000,
});
await page.getByTestId("float_float_temperature").fill("");
await page.getByTestId("float_float_temperature").fill("1.2");
await evaluateReactStateChanges(
page,
'[data-testid="slider_input"]',
"1.2",
);
await page.waitForSelector('[data-testid="button_run_chat output"]', {
timeout: 1000,

View file

@ -0,0 +1,25 @@
import { Page } from "playwright/test";
export const evaluateReactStateChanges = async (
page: Page,
selector: string,
value: string,
) => {
await page.evaluate(
({ selector, value }) => {
const inputElement = document.querySelector(selector) as HTMLInputElement;
if (inputElement) {
const prototype = Object.getPrototypeOf(inputElement);
const nativeInputValueSetter = Object.getOwnPropertyDescriptor(
prototype,
"value",
)?.set;
if (nativeInputValueSetter) {
nativeInputValueSetter.call(inputElement, value);
inputElement.dispatchEvent(new Event("input", { bubbles: true }));
}
}
},
{ selector, value },
);
};