7a0da7932b
OSV-Scanner (Scheduled) / scan-scheduled (push) Failing after 0s
Create Release / test-gate (push) Has been cancelled
Create Release / release-gate (push) Has been cancelled
Create Release / ci-gate (push) Has been cancelled
Create Release / version-check (push) Has been cancelled
Create Release / e2e-test-gate (push) Has been cancelled
Create Release / responsive-test-gate (push) Has been cancelled
Create Release / compat-test-gate (push) Has been cancelled
Create Release / compose-integration-gate (push) Has been cancelled
Create Release / vulture-gate (push) Has been cancelled
Create Release / build (push) Has been cancelled
Create Release / provenance (push) Has been cancelled
Create Release / prerelease-docker (push) Has been cancelled
Create Release / publish-docker (push) Has been cancelled
Create Release / create-release (push) Has been cancelled
Create Release / cleanup-changelog (push) Has been cancelled
Create Release / trigger-pypi (push) Has been cancelled
Create Release / monitor-pypi (push) Has been cancelled
Create Release / Clean up orphan prerelease tags and signatures (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-form] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-metrics] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-workflow] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [settings-core] (push) Has been cancelled
CodeQL Advanced / Analyze (javascript-typescript) (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [history-news] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [library] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [link-analytics] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [chat-core] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [chat-lifecycle] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [error-benchmark] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [settings-pages] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) (push) Has been cancelled
Docker Tests (Consolidated) / Accessibility Tests (push) Has been cancelled
Docker Tests (Consolidated) / LLM Unit Tests (push) Has been cancelled
Docker Tests (Consolidated) / LLM Example Tests (push) Has been cancelled
Docker Tests (Consolidated) / Production Image Smoke Test (push) Has been cancelled
Docker Tests (Consolidated) / Infrastructure Tests (push) Has been cancelled
OSSF Scorecard / OSSF Security Scorecard Analysis (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [mobile] (push) Has been cancelled
Backwards Compatibility / Verify Encryption Constants (push) Has been cancelled
Backwards Compatibility / PyPI Version Compatibility (push) Has been cancelled
Backwards Compatibility / Database Migration Tests (push) Has been cancelled
CodeQL Advanced / Analyze (python) (push) Has been cancelled
Docker Tests (Consolidated) / detect-changes (push) Has been cancelled
Docker Tests (Consolidated) / Build Test Image (push) Has been cancelled
Docker Tests (Consolidated) / All Pytest Tests + Coverage (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [accessibility] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [api-crud] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-login] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-pages] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-register] (push) Has been cancelled
209 lines
6.6 KiB
JavaScript
209 lines
6.6 KiB
JavaScript
/**
|
|
* E2E Tests for Chat Page Navigation
|
|
* Tests basic page loading and navigation for the chat feature
|
|
*
|
|
* Prerequisites: Web server running on http://127.0.0.1:5000
|
|
*/
|
|
|
|
const puppeteer = require('puppeteer');
|
|
const AuthHelper = require('../auth_helper');
|
|
const { getPuppeteerLaunchOptions } = require('../puppeteer_config');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const BASE_URL = process.env.BASE_URL || 'http://127.0.0.1:5000';
|
|
const isCI = !!process.env.CI;
|
|
|
|
// Timeouts adjusted for CI environment
|
|
const TIMEOUTS = {
|
|
navigation: isCI ? 60000 : 30000,
|
|
selector: isCI ? 30000 : 10000,
|
|
element: isCI ? 10000 : 5000,
|
|
};
|
|
|
|
async function testChatPageNavigation() {
|
|
console.log(`🧪 Running chat page navigation test (CI mode: ${isCI})`);
|
|
|
|
// Create screenshots directory if it doesn't exist
|
|
const screenshotsDir = path.join(__dirname, '..', 'screenshots');
|
|
if (!fs.existsSync(screenshotsDir)) {
|
|
fs.mkdirSync(screenshotsDir, { recursive: true });
|
|
}
|
|
|
|
const browser = await puppeteer.launch(getPuppeteerLaunchOptions());
|
|
const page = await browser.newPage();
|
|
|
|
// Set viewport
|
|
await page.setViewport({ width: 1280, height: 800 });
|
|
|
|
// Set timeouts
|
|
if (isCI) {
|
|
page.setDefaultTimeout(60000);
|
|
page.setDefaultNavigationTimeout(60000);
|
|
}
|
|
|
|
// Enable console logging for debugging
|
|
page.on('console', msg => {
|
|
if (msg.type() === 'error') {
|
|
console.log(`BROWSER ERROR: ${msg.text()}`);
|
|
}
|
|
});
|
|
|
|
page.on('pageerror', error => {
|
|
console.log('PAGE ERROR:', error.message);
|
|
});
|
|
|
|
const authHelper = new AuthHelper(page, BASE_URL);
|
|
|
|
let testsPassed = 0;
|
|
let testsFailed = 0;
|
|
|
|
try {
|
|
// Ensure we're logged in
|
|
console.log('🔐 Ensuring authentication...');
|
|
await authHelper.ensureAuthenticated();
|
|
console.log('✅ Authentication verified\n');
|
|
|
|
// Test 1: Chat page loads successfully
|
|
console.log('📋 Test 1: Chat page loads successfully');
|
|
try {
|
|
await page.goto(`${BASE_URL}/chat/`, {
|
|
waitUntil: 'domcontentloaded',
|
|
timeout: TIMEOUTS.navigation
|
|
});
|
|
|
|
const chatContainer = await page.waitForSelector('.ldr-chat-container', {
|
|
timeout: TIMEOUTS.selector
|
|
});
|
|
|
|
if (!chatContainer) {
|
|
throw new Error('Chat container not found');
|
|
}
|
|
|
|
const currentUrl = page.url();
|
|
if (!currentUrl.includes('/chat')) {
|
|
throw new Error(`Expected URL to contain /chat, got: ${currentUrl}`);
|
|
}
|
|
|
|
console.log('✅ Test 1 PASSED: Chat page loaded successfully\n');
|
|
testsPassed++;
|
|
} catch (error) {
|
|
console.log(`❌ Test 1 FAILED: ${error.message}\n`);
|
|
await page.screenshot({ path: path.join(screenshotsDir, 'chat_page_load_failed.png') });
|
|
testsFailed++;
|
|
}
|
|
|
|
// Test 2: Chat page has input area
|
|
console.log('📋 Test 2: Chat page has input area');
|
|
try {
|
|
await page.goto(`${BASE_URL}/chat/`, {
|
|
waitUntil: 'domcontentloaded',
|
|
timeout: TIMEOUTS.navigation
|
|
});
|
|
|
|
await page.waitForSelector('.ldr-chat-container', {
|
|
timeout: TIMEOUTS.selector
|
|
});
|
|
|
|
// Look for input field for sending messages
|
|
const inputSelectors = [
|
|
'textarea.chat-input',
|
|
'input.chat-input',
|
|
'#chat-input',
|
|
'[data-testid="chat-input"]',
|
|
'.ldr-chat-input textarea',
|
|
'.ldr-chat-input input',
|
|
'.ldr-chat-container textarea',
|
|
'.ldr-chat-container input[type="text"]'
|
|
];
|
|
|
|
let inputFound = false;
|
|
for (const selector of inputSelectors) {
|
|
const input = await page.$(selector);
|
|
if (input) {
|
|
inputFound = true;
|
|
console.log(` Found input with selector: ${selector}`);
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!inputFound) {
|
|
throw new Error('No chat input field found');
|
|
}
|
|
|
|
console.log('✅ Test 2 PASSED: Chat input area found\n');
|
|
testsPassed++;
|
|
} catch (error) {
|
|
console.log(`❌ Test 2 FAILED: ${error.message}\n`);
|
|
await page.screenshot({ path: path.join(screenshotsDir, 'chat_input_not_found.png') });
|
|
testsFailed++;
|
|
}
|
|
|
|
// Test 3: Chat page has send button or submit mechanism
|
|
console.log('📋 Test 3: Chat page has send button');
|
|
try {
|
|
await page.goto(`${BASE_URL}/chat/`, {
|
|
waitUntil: 'domcontentloaded',
|
|
timeout: TIMEOUTS.navigation
|
|
});
|
|
|
|
await page.waitForSelector('.ldr-chat-container', {
|
|
timeout: TIMEOUTS.selector
|
|
});
|
|
|
|
// Look for send button
|
|
const buttonSelectors = [
|
|
'button.chat-send',
|
|
'#chat-send-btn',
|
|
'[data-testid="chat-send"]',
|
|
'.ldr-chat-send',
|
|
'button[type="submit"]',
|
|
'.ldr-chat-container button'
|
|
];
|
|
|
|
let buttonFound = false;
|
|
for (const selector of buttonSelectors) {
|
|
const button = await page.$(selector);
|
|
if (button) {
|
|
buttonFound = true;
|
|
console.log(` Found button with selector: ${selector}`);
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!buttonFound) {
|
|
throw new Error('No send button found');
|
|
}
|
|
|
|
console.log('✅ Test 3 PASSED: Send button found\n');
|
|
testsPassed++;
|
|
} catch (error) {
|
|
console.log(`❌ Test 3 FAILED: ${error.message}\n`);
|
|
await page.screenshot({ path: path.join(screenshotsDir, 'chat_button_not_found.png') });
|
|
testsFailed++;
|
|
}
|
|
|
|
} catch (error) {
|
|
console.log(`💥 Test suite error: ${error.message}`);
|
|
testsFailed++;
|
|
} finally {
|
|
await browser.close();
|
|
}
|
|
|
|
// Print summary
|
|
console.log('─'.repeat(50));
|
|
console.log(`📊 Chat Page Navigation Tests Summary`);
|
|
console.log(` ✅ Passed: ${testsPassed}`);
|
|
console.log(` ❌ Failed: ${testsFailed}`);
|
|
console.log('─'.repeat(50));
|
|
|
|
if (testsFailed > 0) {
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
testChatPageNavigation().catch(error => {
|
|
console.error('💥 Test runner error:', error);
|
|
process.exit(1);
|
|
});
|