import { expect, test } from "./utils/test"; import { getTenantCredentials, loginAsTenantUser } from "./utils/auth"; import { skipIfUnavailable } from "./utils/navigation"; import { skipOrFailWhenE2eFixtureMissing, skipOrFailWhenE2eInputsMissing } from "./utils/readiness"; const credentials = getTenantCredentials(); const dashboardPath = process.env.E2E_TENANT_DASHBOARD_PATH; const importPath = process.env.E2E_TENANT_KWP_PROJECT_IMPORT_PATH ?? dashboardPath?.replace(/\/dashboard\/?$/u, "/settings/integrations/kwp/import"); const readOnlyQuery = process.env.E2E_KWP_PROJECT_QUERY?.trim(); test.describe("VR-P32 KWP project import interim smoke", () => { test.beforeEach(() => { skipOrFailWhenE2eInputsMissing(["E2E_TENANT_EMAIL", "E2E_TENANT_PASSWORD", "E2E_TENANT_DASHBOARD_PATH"], "KWP project import smoke inputs not configured"); }); test("opens the import flow and optionally executes a read-only targeted search", async ({ page }) => { if (!importPath) { skipOrFailWhenE2eFixtureMissing("KWP project import path is not derivable"); } await loginAsTenantUser(page, credentials!); const response = await page.goto(importPath!, { waitUntil: "domcontentloaded" }); await skipIfUnavailable(page, response, `KWP project import path ${importPath}`); await expect(page.locator('[data-ui-id="ui.integrations.kwp.project-import"]')).toBeVisible(); if (!readOnlyQuery || readOnlyQuery.length < 2) { await expect( page .getByText(/Kein KWP-Projekt ausgewählt|No KWP project selected/iu) .or(page.getByText(/Keine KWP-Verbindung|No KWP connection/iu)) .first() ).toBeVisible(); return; } await page.getByLabel(/Suchbegriff|Search term/iu).fill(readOnlyQuery); await page.getByRole("button", { name: /Suchen|Search/iu }).click(); await page.waitForLoadState("domcontentloaded"); await expect(page.locator('[data-ui-id="ui.integrations.kwp.project-import"]')).toBeVisible(); await expect(page.locator('[data-ui-id="ui.integrations.kwp.project-import.results"]')).toBeVisible(); }); });