test: Update API key requirements and test configurations for frontend tests (#5752)

This commit is contained in:
Cristhian Zanforlin Lousa 2025-01-17 11:17:26 -03:00 committed by GitHub
commit 36b3289da2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 17 deletions

View file

@ -1,14 +1,8 @@
import { expect, test } from "@playwright/test";
import * as dotenv from "dotenv";
import path from "path";
import { addNewApiKeys } from "../../utils/add-new-api-keys";
import { adjustScreenView } from "../../utils/adjust-screen-view";
import { awaitBootstrapTest } from "../../utils/await-bootstrap-test";
import { getAllResponseMessage } from "../../utils/get-all-response-message";
import { initialGPTsetup } from "../../utils/initialGPTsetup";
import { removeOldApiKeys } from "../../utils/remove-old-api-keys";
import { selectGptModel } from "../../utils/select-gpt-model";
import { updateOldComponents } from "../../utils/update-old-components";
import { waitForOpenModalWithChatInput } from "../../utils/wait-for-open-modal";
test(
@ -17,7 +11,7 @@ test(
async ({ page }) => {
test.skip(
!process?.env?.ANTHROPIC_API_KEY,
"OPENAI_API_KEY required to run this test",
"ANTHROPIC_API_KEY required to run this test",
);
if (!process.env.CI) {
@ -35,16 +29,18 @@ test(
timeout: 100000,
});
await initialGPTsetup(page);
await page
.getByTestId("popover-anchor-input-api_key")
.last()
.fill(process.env.ANTHROPIC_API_KEY ?? "");
const apiKeyInput = page.getByTestId(
"popover-anchor-input-anthropic_api_key",
);
const isApiKeyInputVisible = await apiKeyInput.isVisible();
await page.waitForSelector('[data-testid="dropdown_str_model_name"]', {
timeout: 5000,
});
if (isApiKeyInputVisible) {
await apiKeyInput.fill(process.env.ANTHROPIC_API_KEY ?? "");
}
await page.getByTestId("dropdown_str_model_name").click();
await page.keyboard.press("Enter");
await page.getByTestId("button_run_chat output").click();
await page.waitForSelector("text=built successfully", { timeout: 30000 });
@ -63,7 +59,9 @@ test(
const textContents = await getAllResponseMessage(page);
expect(textContents.length).toBeGreaterThan(100);
expect(await page.getByTestId("chat-code-tab").isVisible()).toBe(true);
expect(await page.getByTestId("chat-code-tab").last().isVisible()).toBe(
true,
);
expect(textContents).toContain("langflow");
},
);

View file

@ -39,7 +39,8 @@ test(
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",
"from langflow.io import BoolInput, DictInput, DropdownInput, FloatInput, IntInput, StrInput, SliderInput\n" +
"from langflow.field_typing.range_spec import RangeSpec",
);
cleanCode = cleanCode.replace(