refactor: Improve wait time for modals and elements in regression tests (#5141)

* feat: Improve wait time for modals and elements in regression tests

- Increase the timeout for waiting for modals and elements in regression tests to 3000ms.
- Replace the usage of `waitForTimeout` with `waitForSelector` for better reliability.

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
anovazzi1 2024-12-09 09:18:57 -03:00 • committed by GitHub
commit c9bedb21c9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -23,7 +23,9 @@ test(
while (modalCount === 0) { while (modalCount === 0) {
await page.getByText("New Flow", { exact: true }).click(); await page.getByText("New Flow", { exact: true }).click();
await page.waitForTimeout(3000); await page.waitForSelector('[data-testid="modal-title"]', {
timeout: 3000,
});
modalCount = await page.getByTestId("modal-title").count(); modalCount = await page.getByTestId("modal-title").count();
} }
@ -34,7 +36,9 @@ test(
await page.getByTestId("sidebar-search-input").click(); await page.getByTestId("sidebar-search-input").click();
await page.getByTestId("sidebar-search-input").fill("composio"); await page.getByTestId("sidebar-search-input").fill("composio");
await page.waitForTimeout(1000); await page.waitForSelector('[data-testid="composioComposio Tools"]', {
timeout: 3000,
});
const modelElement = await page.getByTestId("composioComposio Tools"); const modelElement = await page.getByTestId("composioComposio Tools");
const targetElement = await page.locator('//*[@id="react-flow-id"]'); const targetElement = await page.locator('//*[@id="react-flow-id"]');
@ -47,9 +51,10 @@ test(
await page.getByTestId("zoom_out").click(); await page.getByTestId("zoom_out").click();
await page.getByTestId("zoom_out").click(); await page.getByTestId("zoom_out").click();
await page.waitForTimeout(1000); await expect(page.getByText("api_key")).toBeVisible({
timeout: 3000,
expect(await page.getByText("api_key").isVisible()).toBe(false); visible: false,
});
}, },
); );
@ -76,7 +81,9 @@ test(
while (modalCount === 0) { while (modalCount === 0) {
await page.getByText("New Flow", { exact: true }).click(); await page.getByText("New Flow", { exact: true }).click();
await page.waitForTimeout(3000); await page.waitForSelector('[data-testid="modal-title"]', {
timeout: 3000,
});
modalCount = await page.getByTestId("modal-title").count(); modalCount = await page.getByTestId("modal-title").count();
} }
@ -87,7 +94,9 @@ test(
await page.getByTestId("sidebar-search-input").click(); await page.getByTestId("sidebar-search-input").click();
await page.getByTestId("sidebar-search-input").fill("search api"); await page.getByTestId("sidebar-search-input").fill("search api");
await page.waitForTimeout(1000); await page.waitForSelector('[data-testid="toolsSearch API"]', {
timeout: 3000,
});
let modelElement = await page.getByTestId("toolsSearch API"); let modelElement = await page.getByTestId("toolsSearch API");
let targetElement = await page.locator('//*[@id="react-flow-id"]'); let targetElement = await page.locator('//*[@id="react-flow-id"]');
@ -100,16 +109,17 @@ test(
await page.getByTestId("zoom_out").click(); await page.getByTestId("zoom_out").click();
await page.getByTestId("zoom_out").click(); await page.getByTestId("zoom_out").click();
await page.waitForTimeout(1000);
await page.getByTestId("sidebar-search-input").click(); await page.getByTestId("sidebar-search-input").click();
await page.getByTestId("sidebar-search-input").fill("tool calling agent"); await page.getByTestId("sidebar-search-input").fill("tool calling agent");
await page.waitForTimeout(1000); await page.waitForSelector(
'[data-testid="langchain_utilitiesTool Calling Agent"]',
modelElement = await page.getByTestId( {
"langchain_utilitiesTool Calling Agent", timeout: 3000,
},
); );
modelElement = page.getByTestId("langchain_utilitiesTool Calling Agent");
targetElement = await page.locator('//*[@id="react-flow-id"]'); targetElement = await page.locator('//*[@id="react-flow-id"]');
await modelElement.dragTo(targetElement); await modelElement.dragTo(targetElement);
@ -132,8 +142,6 @@ test(
await toolCallingAgentInput.hover(); await toolCallingAgentInput.hover();
await page.mouse.up(); await page.mouse.up();
await page.waitForTimeout(1000);
expect(await page.locator(".react-flow__edge-interaction").count()).toBe(1); expect(await page.locator(".react-flow__edge-interaction").count()).toBe(1);
}, },
); );