"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const test_1 = require("@playwright/test");
const _8_10_1 = require("../../fixtures/8.10");
const _setup_1 = require("../../test-setup.js");
const UtilitiesPage_1 = require("../../pages/8.10/UtilitiesPage");
const users_1 = require("../../utils/users");
const agenticDashboardHelpers_1 = require("../../utils/agenticDashboardHelpers");
const testUser = (0, users_1.getTestUser)('twentyFirstUser');
const clusterName = 'Test Cluster';
_8_10_1.test.describe.configure({ mode: 'parallel' });
_8_10_1.test.describe('Agentic Control Plane Dashboard UI Tests @agentic-dashboard-ui @8.10', () => {
    _8_10_1.test.beforeEach(async ({ page, loginPage }, testInfo) => {
        await (0, UtilitiesPage_1.loginWithRetry)(page, loginPage, testUser, (testInfo.workerIndex + 1) * 1000);
    });
    _8_10_1.test.afterEach(async ({ page }, testInfo) => {
        await (0, _setup_1.captureScreenshot)(page, testInfo);
        await (0, _setup_1.captureFailureVideo)(page, testInfo);
    });
    (0, _8_10_1.test)('Dashboard navigation and default filters render correctly', async ({ page, appsPage, optimizeHomePage, }) => {
        await (0, agenticDashboardHelpers_1.openAgenticControlPlane)(page, appsPage, optimizeHomePage, clusterName);
        const heading = page.getByRole('heading', {
            name: /agentic\s*control\s*plane/i,
        });
        // The dashboard heading confirms the Agentic Control Plane page loaded.
        await (0, test_1.expect)(heading.first()).toBeVisible({ timeout: 30000 });
        await (0, test_1.expect)(page
            .getByText(/total\s*executions|avg\s*execution\s*duration|tool\s*calls/i)
            .first()).toBeVisible({ timeout: 60000 });
        // The process scope filter defaults to the "All processes" placeholder.
        await (0, test_1.expect)(page.getByPlaceholder(/all\s*processes/i)).toBeVisible({
            timeout: 30000,
        });
    });
    (0, _8_10_1.test)('Execution KPI uses Total Executions terminology', async ({ page, appsPage, optimizeHomePage, }) => {
        await (0, agenticDashboardHelpers_1.openAgenticControlPlane)(page, appsPage, optimizeHomePage, clusterName);
        await (0, test_1.expect)(page.getByText(/total\s*executions/i).first()).toBeVisible({
            timeout: 60000,
        });
        await (0, test_1.expect)(page.getByText(/completed\s*agent\s*runs/i)).toHaveCount(0);
    });
    (0, _8_10_1.test)('Execution KPIs Delta tile is visible', async ({ page, appsPage, optimizeHomePage, }) => {
        await (0, agenticDashboardHelpers_1.openAgenticControlPlane)(page, appsPage, optimizeHomePage, clusterName);
        const deltaTile = page
            .getByText(/execution\s*kpis\s*delta|avg\s*execution\s*duration/i)
            .first();
        await (0, test_1.expect)(deltaTile).toBeVisible({ timeout: 60000 });
    });
    (0, _8_10_1.test)('Process filter switches L0 to L1 chart behavior', async ({ page, appsPage, optimizeHomePage, }) => {
        await (0, agenticDashboardHelpers_1.openAgenticControlPlane)(page, appsPage, optimizeHomePage, clusterName);
        const l0Chart = page
            .getByText(/tokens\s*by\s*process|top\s*token\s*consumers\s*by\s*process/i)
            .first();
        await (0, test_1.expect)(l0Chart).toBeVisible({ timeout: 30000 });
        const selected = await (0, agenticDashboardHelpers_1.selectSingleProcessIfPossible)(page);
        (0, test_1.expect)(selected).toBe(true);
        await (0, test_1.expect)(page.getByText(/failure\s*rate\s*by\s*process\s*version/i).first()).toBeVisible({ timeout: 60000 });
        await (0, test_1.expect)(page.getByText(/tokens\s*by\s*process|top\s*token\s*consumers\s*by\s*process/i)).toHaveCount(0);
    });
    (0, _8_10_1.test)('Tool Calls remains aggregate and out-of-scope UI controls are absent', async ({ page, appsPage, optimizeHomePage, }) => {
        await (0, agenticDashboardHelpers_1.openAgenticControlPlane)(page, appsPage, optimizeHomePage, clusterName);
        const toolCalls = page.getByText(/tool\s*calls/i).first();
        await (0, test_1.expect)(toolCalls).toBeVisible({ timeout: 30000 });
        await (0, test_1.expect)(page.getByText(/per-tool|tool\s*name\s*breakdown/i)).toHaveCount(0);
        await (0, test_1.expect)(page.getByText(/reasoning\s*tokens/i)).toHaveCount(0);
        await (0, test_1.expect)(page.getByText(/threshold|alert\s*configuration/i)).toHaveCount(0);
        await (0, test_1.expect)(page.getByText(/healthy|degraded|failing/i)).toHaveCount(0);
    });
});
