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
105 lines
3.7 KiB
JavaScript
105 lines
3.7 KiB
JavaScript
/**
|
|
* Settings Save Functionality UI Test
|
|
*
|
|
* Tests the complete settings save workflow by monitoring network requests,
|
|
* console messages, and response handling. Specifically tests the save_all_settings
|
|
* endpoint and validates proper error handling and success feedback.
|
|
*
|
|
* What this tests:
|
|
* - Settings save button functionality
|
|
* - Network request monitoring for save operations
|
|
* - API response validation (200 vs 4xx/5xx errors)
|
|
* - Success/error message display
|
|
* - Console logging during save operations
|
|
* - Form submission workflow
|
|
*
|
|
* Prerequisites: Web server running on http://127.0.0.1:5000
|
|
*
|
|
* Usage: node tests/ui_tests/test_settings_save.js
|
|
*/
|
|
|
|
const { setupTest, teardownTest, navigateTo } = require('./test_lib');
|
|
|
|
async function testSettingsSave() {
|
|
const ctx = await setupTest({ authenticate: true });
|
|
const { browser, page } = ctx;
|
|
const baseUrl = ctx.config.baseUrl;
|
|
|
|
// Monitor console errors
|
|
page.on('console', msg => {
|
|
if (msg.type() === 'error') {
|
|
console.log(` Browser error: ${msg.text()}`);
|
|
}
|
|
});
|
|
|
|
// Monitor network responses (no request interception — it can hang
|
|
// page.goto in CI environments when set up before the first navigation).
|
|
page.on('response', response => {
|
|
if (response.url().includes('/settings/')) {
|
|
console.log('← RESPONSE:', response.status(), response.url());
|
|
if (response.status() >= 400) {
|
|
console.log('❌ ERROR RESPONSE:', response.status(), response.statusText());
|
|
}
|
|
}
|
|
});
|
|
|
|
let failed = false;
|
|
|
|
try {
|
|
console.log('🔧 Testing settings save functionality...');
|
|
await navigateTo(page, `${baseUrl}/settings/`);
|
|
|
|
// Wait for page to load completely
|
|
await page.waitForSelector('#save-all-btn, button[type="submit"]', { timeout: 15000 });
|
|
|
|
console.log('🔍 Looking for save button...');
|
|
|
|
// Look for save buttons
|
|
const saveButtons = await page.$$('button[type="submit"], .save-btn, button[onclick*="save"], #save-all-btn');
|
|
console.log(`Found ${saveButtons.length} save buttons`);
|
|
|
|
if (saveButtons.length > 0) {
|
|
console.log('✅ Clicking save button...');
|
|
|
|
// Start listening for the save response BEFORE clicking
|
|
const responsePromise = page.waitForResponse(
|
|
r => r.url().includes('/save_all_settings'),
|
|
{ timeout: 15000 }
|
|
);
|
|
await saveButtons[0].click();
|
|
|
|
// Wait for the save response
|
|
console.log('⏳ Waiting for save response...');
|
|
try {
|
|
await responsePromise;
|
|
} catch {
|
|
console.log('⚠️ Save response not captured (endpoint may differ)');
|
|
}
|
|
|
|
// Check for success/error messages
|
|
const messages = await page.$$('.alert, .message, .notification, .success, .error');
|
|
if (messages.length > 0) {
|
|
console.log(`📝 Found ${messages.length} message elements:`);
|
|
for (let i = 0; i < messages.length; i++) {
|
|
const text = await page.evaluate(el => ({
|
|
text: el.textContent.trim(),
|
|
className: el.className
|
|
}), messages[i]);
|
|
console.log(` ${i + 1}. [${text.className}]: ${text.text}`);
|
|
}
|
|
}
|
|
} else {
|
|
console.log('❌ No save buttons found');
|
|
}
|
|
|
|
} catch (error) {
|
|
console.error('❌ Test error:', error);
|
|
failed = true;
|
|
} finally {
|
|
await teardownTest(ctx);
|
|
process.exit(failed ? 1 : 0);
|
|
}
|
|
}
|
|
|
|
testSettingsSave().catch(err => { console.error(err); process.exit(1); });
|