feature: add edit option to global variables table (#3712)

* first attempt to edit variables on the data table

* refactor: Rename AddNewVariableButton to GlobalVariableModal and update its usage

The component AddNewVariableButton has been renamed to GlobalVariableModal to better reflect its purpose. The component is now used in multiple places, including the GlobalVariablesPage and InputGlobalComponent. This change improves code clarity and consistency.

* fix: fix apply to fields on table edit option

* refactor: Trim field names before checking for availability in GlobalVariableModal and GlobalVariablesPage

Trim field names before checking for availability in GlobalVariableModal and GlobalVariablesPage to ensure consistent comparison and avoid any potential issues with leading or trailing spaces.

* Refactor GlobalVariablesPage to remove unused cellRenderer in the "value" field

* [autofix.ci] apply automated fixes

* Add validation for 'value' field in VariableRead model and import CREDENTIAL_TYPE

- Introduced a field validator for the 'value' field in the VariableRead model to handle cases where the variable type is CREDENTIAL_TYPE.
- Added necessary import for CREDENTIAL_TYPE.
- Removed an unnecessary blank line in the variable API.

* Add constants for credential and generic types in variable service

* Refactor import statements in `kubernetes.py` to improve module organization

* Refactor imports in test_service.py for better organization

* refactor: Update import statements in variable.py for better organization

* Refactor import and reorder fields in VariableRead model

- Changed import of `CREDENTIAL_TYPE` from `service` to `constants` module.
- Reordered fields in `VariableRead` model to place `type` before `value`.

* ✨ (userSettings.spec.ts): Add additional randomName variables for testing purposes
📝 (userSettings.spec.ts): Update test to interact with global variables and improve readability and maintainability of the code

* test: fix test_create_variable

---------
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
Co-authored-by: cristhianzl <cristhian.lousa@gmail.com>
Co-authored-by: italojohnny <italojohnnydosanjos@gmail.com>
This commit is contained in:
anovazzi1 2024-09-09 10:48:04 -03:00 • committed by GitHub
commit d3b8f6cd7e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 186 additions and 68 deletions

View file

@ -21,6 +21,8 @@ test("should see general profile gradient", async ({ page }) => {
test("should interact with global variables", async ({ page }) => {
const randomName = Math.random().toString(36).substring(2);
const randomName2 = Math.random().toString(36).substring(2);
const randomName3 = Math.random().toString(36).substring(2);
await page.goto("/");
await page.waitForTimeout(1000);
@ -50,29 +52,64 @@ test("should interact with global variables", async ({ page }) => {
.fill("testtesttesttesttesttesttesttest");
await page.getByTestId("popover-anchor-apply-to-fields").click();
await page.waitForTimeout(3000);
await page.waitForTimeout(1000);
await page.getByPlaceholder("Search options...").fill("System Message");
await page.getByPlaceholder("Search options...").fill("System");
await page.waitForSelector("text=System Message", { timeout: 30000 });
await page.waitForTimeout(500);
await page.getByText("System Message").first().click();
await page.waitForSelector("text=System", { timeout: 30000 });
await page.waitForTimeout(500);
await page.getByText("System").last().click();
await page.getByPlaceholder("Search options...").fill("openAI");
await page.waitForSelector("text=OpenAI API Base", { timeout: 30000 });
await page.waitForSelector("text=openai", { timeout: 30000 });
await page.getByText("OpenAI API Base").first().click();
await page.waitForTimeout(500);
await page.getByPlaceholder("Search options...").fill("llama");
await page.getByText("openai").last().click();
await page.getByText("Ollama").first().click();
await page.waitForTimeout(500);
await page.getByPlaceholder("Search options...").fill("ollama");
await page.waitForSelector("text=ollama", { timeout: 30000 });
await page.getByText("ollama").first().click();
await page.keyboard.press("Escape");
await page.getByText("Save Variable", { exact: true }).click();
await page.getByText(randomName).last().isVisible();
await page.getByText(randomName).last().click();
await page.getByText(randomName).last().click();
await page.waitForTimeout(500);
await page
.getByPlaceholder("Insert a name for the variable...")
.fill(randomName2);
await page.getByText("Update Variable", { exact: true }).last().click();
await page.getByText(randomName2).last().isVisible();
await page.getByText(randomName2).last().click();
await page.waitForTimeout(500);
await page
.getByPlaceholder("Insert a name for the variable...")
.fill(randomName3);
await page.getByText("Update Variable", { exact: true }).last().click();
await page.getByText(randomName3).last().isVisible();
const focusElementsOnBoard = async ({ page }) => {
await page.waitForSelector(
'[aria-label="Press Space to toggle all rows selection (unchecked)"]',