"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("@testing-library/react");
require("@testing-library/jest-dom");
const react_2 = require("@chakra-ui/react");
// Mock the services first
jest.mock('../../../services/api', () => ({
    enhancedApiClient: {
        uploadDocument: jest.fn().mockResolvedValue({ id: 'test-upload' }),
    },
}));
jest.mock('../../../services/bfrfp', () => ({
    bfrfpService: {
        getRecentAnalyses: jest.fn().mockResolvedValue([]),
        analyzeDocument: jest.fn(),
    },
}));
// Import component after mocking
const RFPDashboard_1 = __importDefault(require("../RFPDashboard"));
const TestWrapper = ({ children }) => ((0, jsx_runtime_1.jsx)(react_2.ChakraProvider, { children: children }));
describe('RFPDashboard Debug Test', () => {
    test('debug analysis flow', async () => {
        const { bfrfpService } = require('../../../services/bfrfp');
        // Mock the exact response structure
        bfrfpService.analyzeDocument.mockResolvedValue({
            id: 'analysis-123',
            status: 'completed',
            summary: 'Test analysis summary',
            categories: ['technical', 'financial'],
            keyRequirements: ['React expertise', 'AWS deployment'],
            riskAreas: ['tight timeline', 'complex requirements'],
            competitiveAdvantages: ['proven track record', 'innovative approach'],
            recommendedApproach: 'Agile methodology with weekly reviews',
        });
        (0, react_1.render)((0, jsx_runtime_1.jsx)(TestWrapper, { children: (0, jsx_runtime_1.jsx)(RFPDashboard_1.default, {}) }));
        // Log initial state
        console.log('Initial render complete');
        const analyzeButton = react_1.screen.getByTestId('analyze-latest-document');
        expect(analyzeButton).toBeInTheDocument();
        console.log('About to click analyze button');
        react_1.fireEvent.click(analyzeButton);
        // Wait for service call
        await (0, react_1.waitFor)(() => {
            expect(bfrfpService.analyzeDocument).toHaveBeenCalled();
        });
        console.log('Service was called');
        // Wait a bit longer for state updates
        await (0, react_1.waitFor)(() => {
            const summaryElement = react_1.screen.queryByText('Test analysis summary');
            if (!summaryElement) {
                // Check what's actually in the analyses section
                const analysesSection = react_1.screen.getByTestId('recent-analyses-list');
                expect(analysesSection.textContent).toContain('Test analysis summary');
            }
        }, { timeout: 5000 });
    });
});
//# sourceMappingURL=RFPDashboard.debug.test.js.map