Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
"connectionIdRequired": "مطلوب معرِّف الموَّصل",
"connectionIdRequirement": "لا يمكن أن يحتوي معرِّف الموَّصل على مسافات فقط",
"connectionTypeRequired": "مطلوب نوع الموَّصل",
"extraFields": "حقول إضافية",
"extraFieldsJson": "JSON حقول إضافية بصيغة",
"helperText": "نوع الموَّصل مفقود؟ تأكد من تثبيت حزمة Airflow المناسبة.",
"helperTextForRedactedFields": "لن تتغير الحقول المحجوبة ('***') إذا لم يتم تعديلها.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"connectionIdRequired": "L'ID de connexió és obligatori",
"connectionIdRequirement": "L'ID de connexió no pot tenir únicament espais",
"connectionTypeRequired": "El tipus de connexió és obligatori",
"extraFields": "Camps addicionals",
"extraFieldsJson": "Camps addicionals JSON",
"helperText": "Falta el tipus de connexió? Assegureu-vos d'haver instal·lat el paquet de proveïdors d'Airflow corresponent.",
"helperTextForRedactedFields": "Els camps redactats ('***') romandran sense canvis si no es modifiquen.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"connectionIdRequired": "Verbindungs-ID ist erforderlich",
"connectionIdRequirement": "Die Verbindungs-ID kann nicht nur aus Leerzeichen bestehen",
"connectionTypeRequired": "Die Auswahl eines Verbindungstyps ist erforderlich",
"extraFields": "Weitere Felder",
"extraFieldsJson": "JSON Ansicht der weiteren Felder",
"helperText": "Fehlt ein Verbindungstyp? Stellen Sie sicher, dass die notwendigen Provider-Pakete installiert sind.",
"helperTextForRedactedFields": "Unkenntlich gemachte Felder ('***') bleiben unverändert, wenn sie nicht bearbeitet werden.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"connectionIdRequired": "Το ID Σύνδεσης είναι υποχρεωτικό",
"connectionIdRequirement": "Το ID Σύνδεσης δεν μπορεί να περιέχει μόνο κενά",
"connectionTypeRequired": "Ο Τύπος Σύνδεσης είναι υποχρεωτικός",
"extraFields": "Επιπλέον Πεδία",
"extraFieldsJson": "Επιπλέον Πεδία JSON",
"helperText": "Λείπει ο Τύπος Σύνδεσης; Βεβαιωθείτε ότι έχετε εγκαταστήσει το ανάλογο πακέτο Airflow Παρόχων.",
"helperTextForRedactedFields": "Τα πεδία που έχουν αποκρυφθεί ('***') θα παραμείνουν αμετάβλητα αν δεν τροποποιηθούν.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
"form": {
"connectionIdRequired": "Connection ID is required",
"connectionIdRequirement": "Connection ID cannot contain only spaces",
"connectionTypeFields": "{{connectionType}} Fields",
"connectionTypeRequired": "Connection Type is required",
"extraFields": "Extra Fields",
"extraFieldsJson": "Extra Fields JSON",
"helperText": "Connection type missing? Make sure you have installed the corresponding Airflow Providers Package.",
"helperTextForRedactedFields": "Redacted fields ('***') will remain unchanged if not modified.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"connectionIdRequired": "El ID de la conexión es requerido",
"connectionIdRequirement": "El ID de la conexión no puede contener solo espacios",
"connectionTypeRequired": "El Tipo de Conexión es requerido",
"extraFields": "Campos Extra",
"extraFieldsJson": "Campos Extra (tipo JSON)",
"helperText": "¿Falta el Tipo de conexión? Asegúrate de haber instalado el paquete de proveedores de Airflow correspondiente.",
"helperTextForRedactedFields": "Los campos redactados ('***') permanecerán sin cambios si no se modifican.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"connectionIdRequired": "L'ID de la connexion est requis",
"connectionIdRequirement": "L'ID de la connexion ne peut pas contenir uniquement des espaces",
"connectionTypeRequired": "Le type de la connexion est requis",
"extraFields": "Champs Supplémentaires",
"extraFieldsJson": "Champs Supplémentaires JSON",
"helperText": "Le type de la connexion est manquant ? Assurez-vous d'avoir installé le package Airflow Providers correspondant.",
"helperTextForRedactedFields": "Les champs masqués ('***') resteront inchangés s'ils ne sont pas modifiés.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"connectionIdRequired": "נדרש מזהה חיבור",
"connectionIdRequirement": "מזהה חיבור אינו יכול להכיל רווחים בלבד",
"connectionTypeRequired": "נדרש סוג חיבור",
"extraFields": "שדות נוספים",
"extraFieldsJson": "שדות נוספים JSON",
"helperText": "סוג החיבור המבוקש חסר? וודא שהתקנת את חבילת העזר המתאימה",
"helperTextForRedactedFields": "שדות שהוסתרו ('***') יישארו ללא שינוי אם לא בוצע בהם עדכון",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"connectionIdRequired": "कनेक्शन ID आवश्यक है",
"connectionIdRequirement": "कनेक्शन ID में केवल अंतरिक्ष कुंजियाँ नहीं हो सकते",
"connectionTypeRequired": "कनेक्शन प्रकार आवश्यक है",
"extraFields": "अतिरिक्त फ़ील्ड",
"extraFieldsJson": "अतिरिक्त फ़ील्ड JSON",
"helperText": "कनेक्शन प्रकार गायब है? सुनिश्चित करें कि आपने संबंधित Airflow Providers Package इंस्टॉल किया है।",
"helperTextForRedactedFields": "संपादित फ़ील्ड ('***') अपरिवर्तित रहेंगे यदि संशोधित नहीं किए गए।",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"connectionIdRequired": "Kapcsolat azonosító szükséges",
"connectionIdRequirement": "Kapcsolat azonosító nem tartalmazhat szóközöket",
"connectionTypeRequired": "Kapcsolat típus szükséges",
"extraFields": "Extra mezők",
"extraFieldsJson": "Extra mezők JSON",
"helperText": "Hiányzó kapcsolat típus? Győződjön meg róla, hogy a megfelelő Airflow Providers Package telepítésre került.",
"helperTextForRedactedFields": "A kitakart mezők ('***') változatlanok maradnak, ha nem módosítja őket.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
"connectionIdRequired": "L'ID della connessione è obbligatorio",
"connectionIdRequirement": "L'ID della connessione non può contenere solo spazi",
"connectionTypeRequired": "Il tipo di connessione è obbligatorio",
"extraFields": "Campi Extra",
"extraFieldsJson": "Campi Extra JSON",
"helperText": "Il tipo di connessione è mancante? Assicurati di aver installato il pacchetto corrispondente di Airflow Providers.",
"helperTextForRedactedFields": "I campi redatti ('***') rimarranno invariati se non modificati.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
"connectionIdRequired": "接続 ID は必須です",
"connectionIdRequirement": "空白文字だけの接続 ID は認められません",
"connectionTypeRequired": "接続タイプは必須です",
"extraFields": "追加項目",
"extraFieldsJson": "追加項目 (JSON 形式)",
"helperText": "接続タイプが見つかりませんか?対応する Airflow Providers パッケージがインストールされていることを確認してください",
"helperTextForRedactedFields": "非表示の項目 ('***') は、編集しなければ以前の値がそのまま使われます",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"connectionIdRequired": "커넥션 ID는 필수 항목입니다",
"connectionIdRequirement": "커넥션 ID는 공백만으로 구성될 수 없습니다",
"connectionTypeRequired": "커넥션 유형은 필수 항목입니다",
"extraFields": "추가 필드",
"extraFieldsJson": "추가 필드 JSON",
"helperText": "커넥션 유형이 보이지 않나요? 해당 Airflow Provider 패키지가 설치되어 있는지 확인하세요.",
"helperTextForRedactedFields": "('***')로 마스킹된 필드는 수정하지 않으면 그대로 유지됩니다.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"connectionIdRequired": "Connectie ID is verplicht",
"connectionIdRequirement": "Connectie ID kan niet bestaan uit enkel spaties",
"connectionTypeRequired": "Connectie type is verplicht",
"extraFields": "Extra velden",
"extraFieldsJson": "Extra velden JSON",
"helperText": "Missend connectie type? Controller of je de bijbehorende Airflow Providers Package hebt geïnstalleerd.",
"helperTextForRedactedFields": "Gemaskeerde velden ('***') blijven onveranderd als ze niet worden gewijzigd.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
"connectionIdRequired": "Identyfikator połączenia jest wymagany",
"connectionIdRequirement": "Identyfikator połączenia nie może zawierać wyłącznie spacji",
"connectionTypeRequired": "Typ połączenia jest wymagany",
"extraFields": "Dodatkowe pola",
"extraFieldsJson": "Dodatkowe pola JSON",
"helperText": "Brakuje typu połączenia? Upewnij się, że zainstalowałeś odpowiedniego dostawcę.",
"helperTextForRedactedFields": "Ukryte pola ('***') nie bedą zapisane jeśli nie zostaną zmienione.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"connectionIdRequired": "ID da Conexão é obrigatório",
"connectionIdRequirement": "ID da Conexão não pode conter somente espaços",
"connectionTypeRequired": "Tipo de Conexão é obrigatório",
"extraFields": "Campos Extra",
"extraFieldsJson": "Campos Extra JSON",
"helperText": "Tipo de conexão faltando? Certifique-se de ter instalado o pacote do provider correspondente ao Airflow.",
"helperTextForRedactedFields": "Os campos redigidos ('***') permanecerão inalterados se não forem modificados.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"connectionIdRequired": "ID соединения обязателен",
"connectionIdRequirement": "ID соединения не может состоять только из пробелов",
"connectionTypeRequired": "Тип соединения обязателен",
"extraFields": "Дополнительные поля",
"extraFieldsJson": "Дополнительные поля JSON",
"helperText": "Отсутствует тип соединения? Убедитесь, что вы установили соответствующий пакет Airflow Providers.",
"helperTextForRedactedFields": "Скрытые поля ('***') останутся без изменений, если их не редактировать.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
"connectionIdRequired": "กรุณาระบุ ID การเชื่อมต่อ",
"connectionIdRequirement": "ID การเชื่อมต่อไม่สามารถมีช่องว่างได้",
"connectionTypeRequired": "กรุณาระบุประเภทการเชื่อมต่อ",
"extraFields": "ฟิลด์เพิ่มเติม",
"extraFieldsJson": "ฟิลด์เพิ่มเติมในรูปแบบ JSON",
"helperText": "ไม่พบประเภทการเชื่อมต่อ? โปรดตรวจสอบให้แน่ใจว่าคุณได้ติดตั้ง Airflow Providers Package ที่เกี่ยวข้องแล้ว",
"helperTextForRedactedFields": "ฟิลด์ที่ถูกซ่อน ('***') จะไม่ถูกเปลี่ยนแปลงหากไม่ได้แก้ไข",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"connectionIdRequired": "Bağlantı Kimliği gerekli",
"connectionIdRequirement": "Bağlantı Kimliği sadece boşluklardan oluşamaz",
"connectionTypeRequired": "Bağlantı Tipi gerekli",
"extraFields": "Ek Alanlar",
"extraFieldsJson": "Ek Alanlar JSON",
"helperText": "Bağlantı tipi eksik mi? İlgili Airflow Providers paketini yüklediğinizden emin olun.",
"helperTextForRedactedFields": "Gizlenmiş alanlar ('***') değiştirilmedikçe kaydedilmeyecektir.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"connectionIdRequired": "连接 ID 是必填的",
"connectionIdRequirement": "连接 ID 不能只包含空格",
"connectionTypeRequired": "连接类型是必填的",
"extraFields": "额外字段",
"extraFieldsJson": "额外字段 JSON",
"helperText": "找不到连接类型?请确保您已安装对应的 Airflow 整合套件。",
"helperTextForRedactedFields": "已遮蔽的字段 ('***') 若未修改,将保持不变。",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"connectionIdRequired": "連線 ID 是必填的",
"connectionIdRequirement": "連線 ID 不能只包含空格",
"connectionTypeRequired": "連線類型是必填的",
"extraFields": "額外欄位",
"extraFieldsJson": "額外欄位 JSON",
"helperText": "找不到連線類型?請確保您已安裝對應的 Airflow 整合套件。",
"helperTextForRedactedFields": "已遮蔽的欄位 ('***') 若未修改,將保持不變。",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
/*!
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import "@testing-library/jest-dom";
import { render, screen } from "@testing-library/react";
import { beforeEach, describe, expect, it, vi } from "vitest";

import i18n from "src/i18n/config";
import type { ConnectionMetaEntry } from "src/queries/useConnectionTypeMeta";
import { paramPlaceholder } from "src/queries/useParamStore";
import { Wrapper } from "src/utils/Wrapper";

import adminLocale from "../../../public/i18n/locales/en/admin.json";
import ConnectionForm from "./ConnectionForm";
import type { ConnectionBody } from "./Connections";

const { mockUseConnectionTypeMeta } = vi.hoisted(() => ({
mockUseConnectionTypeMeta: vi.fn(),
}));

vi.mock("src/queries/useConnectionTypeMeta", () => ({
useConnectionTypeMeta: mockUseConnectionTypeMeta,
}));

vi.mock("src/queries/useConfig.tsx", () => ({
useConfig: () => false,
}));

const pydanticAiMeta: ConnectionMetaEntry = {
connection_type: "pydanticai",
default_conn_name: "pydanticai_default",
extra_fields: {
model: {
description: "Model in provider:name format",
schema: { ...paramPlaceholder.schema, title: "Model", type: ["string", "null"] },
value: null,
},
},
hook_class_name: "airflow.providers.common.ai.hooks.pydantic_ai.PydanticAIHook",
hook_name: "Pydantic AI",
standard_fields: {},
};

const loadedMeta = {
formattedData: { pydanticai: pydanticAiMeta },
hookNames: { pydanticai: "Pydantic AI" },
isPending: false,
keysList: ["pydanticai"],
};

const pendingMeta = { formattedData: {}, hookNames: {}, isPending: true, keysList: [] };

const pydanticAiConnection: ConnectionBody = {
conn_type: "pydanticai",
connection_id: "decision_default",
description: "",
extra: JSON.stringify({ model: "openai:gpt-5" }),
host: "",
login: "",
password: "",
port: "",
schema: "",
team_name: "",
};

const renderForm = () => (
<ConnectionForm
error={undefined}
initialConnection={pydanticAiConnection}
isEditMode
isPending={false}
mutateConnection={vi.fn()}
/>
);

describe("ConnectionForm", () => {
beforeEach(() => {
i18n.addResourceBundle("en", "admin", adminLocale, true, true);
});

it("titles the provider fields section after the connection type and opens it by default", () => {
mockUseConnectionTypeMeta.mockReturnValue(loadedMeta);

render(renderForm(), { wrapper: Wrapper });

expect(screen.getByRole("button", { name: "Pydantic AI Fields" })).toHaveAttribute(
"aria-expanded",
"true",
);
expect(screen.getByRole("button", { name: "Standard Fields" })).toHaveAttribute("aria-expanded", "true");
});

it("keeps the saved extra and opens the section when hook metadata loads after the form mounts", () => {
mockUseConnectionTypeMeta.mockReturnValue(pendingMeta);
const { rerender } = render(renderForm(), { wrapper: Wrapper });

mockUseConnectionTypeMeta.mockReturnValue(loadedMeta);
rerender(renderForm());

expect(screen.getByRole("button", { name: "Pydantic AI Fields" })).toHaveAttribute(
"aria-expanded",
"true",
);
expect(document.querySelector<HTMLInputElement>("#element_model")).toHaveValue("openai:gpt-5");
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ const ConnectionForm = ({
const selectedConnType = watch("conn_type"); // Get the selected connection type
const standardFields = connectionTypeMeta[selectedConnType]?.standard_fields ?? {};
const paramsDic = { paramsDict: connectionTypeMeta[selectedConnType]?.extra_fields ?? {} };
const connectionTypeFieldsSection = translate("connections.form.connectionTypeFields", {
connectionType: hookNameMap[selectedConnType] ?? selectedConnType,
});

const [formErrors, setFormErrors] = useState(false);
const multiTeamEnabled = Boolean(useConfig("multi_team"));
Expand Down Expand Up @@ -207,10 +210,11 @@ const ConnectionForm = ({
}}
/>

{selectedConnType ? (
{selectedConnType && !isMetaPending ? (
<Accordion.Root
collapsible
defaultValue={["standardFields"]}
defaultValue={["standardFields", connectionTypeFieldsSection]}
key={selectedConnType}
mb={4}
mt={4}
size="lg"
Expand All @@ -223,9 +227,8 @@ const ConnectionForm = ({
</Accordion.ItemContent>
</Accordion.Item>
<FlexibleForm
flexibleFormDefaultSection={translate("connections.form.extraFields")}
flexibleFormDefaultSection={connectionTypeFieldsSection}
initialParamsDict={paramsDic}
key={selectedConnType}
setError={setFormErrors}
subHeader={isEditMode ? translate("connections.form.helperTextForRedactedFields") : undefined}
/>
Expand Down
Loading