Files
rxminder/tests/integration/production.test.js
William Valentin b4a9318324 test: enhance E2E and integration testing infrastructure
- Add comprehensive TypeScript types to E2E test helpers
- Improve medication, auth, modal, and wait helper classes with proper typing
- Enhance test data with readonly type assertions for better immutability
- Update integration tests with better error handling and assertions
- Improve Playwright type definitions for better IDE support
- Add environment variable support to manual test scripts
2025-09-07 15:22:33 -07:00

101 lines
3.0 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const fetch = require('node-fetch');
describe('Production Environment', () => {
jest.setTimeout(30000);
test('CouchDB is accessible', async () => {
console.log('1⃣ Testing CouchDB connection...');
try {
const response = await fetch('http://localhost:5984/', {
headers: {
Authorization:
'Basic ' + Buffer.from('admin:password').toString('base64'),
},
});
if (response.ok) {
const data = await response.json();
console.log('✅ CouchDB is accessible');
console.log(` Version: ${data.version}`);
expect(data.version).toBeDefined();
} else {
console.log('❌ CouchDB connection failed');
fail('CouchDB connection failed');
}
} catch (error) {
console.log('❌ CouchDB connection error:', error.message);
throw error;
}
});
test('Required databases exist', async () => {
console.log('2⃣ Checking databases...');
try {
const response = await fetch('http://localhost:5984/_all_dbs', {
headers: {
Authorization:
'Basic ' + Buffer.from('admin:password').toString('base64'),
},
});
if (response.ok) {
const databases = await response.json();
console.log('✅ Available databases:', databases);
const requiredDbs = [
'users',
'medications',
'settings',
'taken_doses',
'reminders',
];
const missing = requiredDbs.filter(db => !databases.includes(db));
if (missing.length === 0) {
console.log('✅ All required databases exist');
expect(missing).toHaveLength(0);
} else {
console.log('⚠️ Missing databases:', missing);
console.warn(`Missing databases: ${missing.join(', ')}`);
}
} else {
fail('Failed to fetch database list');
}
} catch (error) {
console.log('❌ Database check error:', error.message);
throw error;
}
});
test('Frontend is accessible', async () => {
console.log('3⃣ Testing frontend accessibility...');
try {
const response = await fetch('http://localhost:8080/');
if (response.ok) {
console.log('✅ Frontend is accessible at http://localhost:8080');
expect(response.status).toBe(200);
} else {
console.log('❌ Frontend connection failed');
console.warn('Frontend may not be running');
}
} catch (error) {
console.log('❌ Frontend connection error:', error.message);
console.warn('Frontend may not be running');
}
});
afterAll(() => {
console.log('\n🎯 Production Environment Test Summary:');
console.log(' • CouchDB: http://localhost:5984');
console.log(' • Frontend: http://localhost:8080');
console.log(' • Admin Login: admin@localhost / admin123!');
console.log(
'\n🚀 Your medication reminder app is ready for production testing!'
);
});
});