Skip to content

OpenRAG is a comprehensive, single package Retrieval-Augmented Generation platform built on Langflow, Docling, and Opensearch.

Python
3.5 KB
Raw Blame
import path from "path";
import { AZURE_CONFIG } from "../config/provider";
import { expect, test } from "../utils/fixtures";
import { navigateToSettings } from "../utils/navigation";

const testDocumentPath = path.join(
  __dirname,
  "../test-data/Leave.Policy.Test.Doc.pdf",
);
const testDocumentName = "Leave.Policy.Test.Doc.pdf";
const verificationQuestion =
  "How many Earned Leaves are there per calendar year?";

/**
 * Test: Switch model providers using watsonx.ai and Azure OpenAI
 * Verify user is able to switch model providers
 */
test.describe("Update model providers to watsonx.ai and Azure OpenAI @33219219, @33219229, @33219231", () => {
  test.beforeEach(() => {
    test.skip(
      !process.env.WATSONX_API_KEY ||
        !process.env.WATSONX_PROJECT_ID ||
        !process.env.WATSONX_ENDPOINT,
      "Watsonx credentials not set",
    );
  });

  test("Verify user is able to switch to watsonx.ai provider", async ({
    page,
    settings,
    knowledge,
    chat,
  }) => {
    await navigateToSettings(page);
    await settings.clickTab("Providers");
    await settings.configureWatsonxai();
    await settings.removeModelProviderSetup("azure", "Azure OpenAI");
    await settings.clickTab("Agent");
    await settings.selectModel("Language model", "ibm/granite-4-h-small");
    await settings.clickTab("Ingestion");
    await settings.selectModel(
      "Embedding model",
      "ibm/slate-125m-english-rtrvr-v2",
    );
    await knowledge.deleteDocument(testDocumentName);
    await knowledge.ingestFile(testDocumentPath);
    await knowledge.verifyDocumentActive(testDocumentName);
    await chat.open();
    const responseWatsonx = await chat.askQuestion(
      verificationQuestion,
      120000,
    );
    expect(
      ["18 days", "Leave.Policy.Test.Doc.pdf"].every((keyword) =>
        responseWatsonx.includes(keyword),
      ),
    ).toBe(true);
  });

  test("Restore Azure OpenAI provider and verify functionality", async ({
    settings,
    chat,
    page,
    knowledge,
  }) => {
    await navigateToSettings(page);
    await settings.clickTab("Providers");
    await settings.configureAzureOpenAI();
    await settings.removeModelProviderSetup("watsonx", "IBM watsonx.ai");
    await settings.clickTab("Agent");
    await settings.selectModel("Language model", AZURE_CONFIG.language);
    await settings.clickTab("Ingestion");
    await settings.selectModel("Embedding model", AZURE_CONFIG.embedding);
    await knowledge.deleteDocument(testDocumentName);
    await knowledge.ingestFile(testDocumentPath);
    await knowledge.verifyDocumentActive(testDocumentName);
    await chat.open();
    await chat.openNewChat();
    const responseAzure = await chat.askQuestion(verificationQuestion, 120000);
    expect(
      ["18 days", "Leave.Policy.Test.Doc.pdf"].every((keyword) =>
        responseAzure.includes(keyword),
      ),
    ).toBe(true);
  });
});

/**
 * Test: Verify invalid credentials are not accepted for watsonx.ai
 */
test.describe("Verify invalid credentials are not accepted for watsonx.ai @34581239", () => {
  test("Verify invalid credentials are not accepted for watsonx.ai", async ({
    page,
    settings,
  }) => {
    await navigateToSettings(page);
    await settings.clickTab("Providers");
    //Remove existing watsonx.ai setup if present
    await settings.removeModelProviderSetup("watsonx", "IBM watsonx.ai");
    await settings.configureWatsonxaiInvalidCredentials(
      "https://us-south.ml.cloud.ibm.com",
      "4865-b94f-d0a80ad0f62a",
      "Z79J_MUqLtVY",
    );
  });
});