- Create Economist SubmissionTracking package correctly: * mainArticle = full blog post content * coverLetter = 216-word SIR— letter * Links to blog post via blogPostId - Archive 'Letter to The Economist' from blog posts (it's the cover letter) - Fix date display on article cards (use published_at) - Target publication already displaying via blue badge Database changes: - Make blogPostId optional in SubmissionTracking model - Economist package ID: 68fa85ae49d4900e7f2ecd83 - Le Monde package ID: 68fa2abd2e6acd5691932150 Next: Enhanced modal with tabs, validation, export 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
200 lines
8.1 KiB
JavaScript
Executable file
200 lines
8.1 KiB
JavaScript
Executable file
#!/usr/bin/env node
|
|
/**
|
|
* Automated test for vault edit functionality
|
|
*/
|
|
|
|
const WebSocket = require('ws');
|
|
const readline = require('readline');
|
|
|
|
const rl = readline.createInterface({
|
|
input: process.stdin,
|
|
output: process.stdout
|
|
});
|
|
|
|
function question(prompt) {
|
|
return new Promise((resolve) => {
|
|
rl.question(prompt, resolve);
|
|
});
|
|
}
|
|
|
|
async function testVaultEdit() {
|
|
console.log('════════════════════════════════════════════════════');
|
|
console.log(' VAULT EDIT FUNCTIONALITY TEST');
|
|
console.log('════════════════════════════════════════════════════\n');
|
|
|
|
const vaultPassword = await question('Enter vault master password: ');
|
|
console.log('');
|
|
|
|
const ws = new WebSocket('ws://127.0.0.1:8888');
|
|
let sessionId = null;
|
|
|
|
return new Promise((resolve, reject) => {
|
|
const timeout = setTimeout(() => {
|
|
ws.close();
|
|
reject(new Error('Test timed out'));
|
|
}, 30000);
|
|
|
|
ws.on('open', () => {
|
|
console.log('✓ Connected to vault server\n');
|
|
|
|
// Step 1: Unlock vault
|
|
console.log('Step 1: Unlocking vault...');
|
|
ws.send(JSON.stringify({
|
|
type: 'unlock',
|
|
password: vaultPassword
|
|
}));
|
|
});
|
|
|
|
ws.on('message', (data) => {
|
|
const msg = JSON.parse(data);
|
|
console.log('← Received:', msg.type);
|
|
|
|
switch (msg.type) {
|
|
case 'unlocked':
|
|
sessionId = msg.sessionId;
|
|
console.log(`✓ Vault unlocked (session: ${sessionId.substring(0, 8)}...)\n`);
|
|
|
|
// Step 2: List credentials in /tractatus
|
|
console.log('Step 2: Listing /tractatus credentials...');
|
|
ws.send(JSON.stringify({
|
|
type: 'list',
|
|
folder: '/tractatus'
|
|
}));
|
|
break;
|
|
|
|
case 'list':
|
|
console.log(`✓ Found ${msg.entries.length} credentials`);
|
|
|
|
// Find TEST_EDIT_CREDENTIAL or create it
|
|
const testEntry = msg.entries.find(e => e === 'TEST_EDIT_CREDENTIAL');
|
|
|
|
if (testEntry) {
|
|
console.log(`✓ Test entry exists\n`);
|
|
|
|
// Step 3: Show original credential
|
|
console.log('Step 3: Fetching original credential data...');
|
|
ws.send(JSON.stringify({
|
|
type: 'show',
|
|
entry: '/tractatus/TEST_EDIT_CREDENTIAL'
|
|
}));
|
|
} else {
|
|
console.log(`⚠ Test entry doesn't exist, creating it...\n`);
|
|
|
|
// Create test entry
|
|
ws.send(JSON.stringify({
|
|
type: 'add',
|
|
folder: '/tractatus',
|
|
name: 'TEST_EDIT_CREDENTIAL',
|
|
username: 'original-user',
|
|
password: 'original-password-12345',
|
|
url: 'https://example.com',
|
|
notes: 'Original notes for testing'
|
|
}));
|
|
}
|
|
break;
|
|
|
|
case 'added':
|
|
console.log(`✓ ${msg.message}\n`);
|
|
|
|
// Now fetch it
|
|
console.log('Step 3: Fetching newly created credential...');
|
|
ws.send(JSON.stringify({
|
|
type: 'show',
|
|
entry: '/tractatus/TEST_EDIT_CREDENTIAL'
|
|
}));
|
|
break;
|
|
|
|
case 'show':
|
|
console.log('✓ Credential data received:');
|
|
console.log(` Username: ${msg.credential.username || '(empty)'}`);
|
|
console.log(` Password: ${msg.credential.password ? '***' + msg.credential.password.slice(-4) : '(empty)'}`);
|
|
console.log(` URL: ${msg.credential.url || '(empty)'}`);
|
|
console.log(` Notes: ${msg.credential.notes || '(empty)'}\n`);
|
|
|
|
// Step 4: Edit the credential
|
|
console.log('Step 4: Editing credential (changing password and notes)...');
|
|
ws.send(JSON.stringify({
|
|
type: 'edit',
|
|
folder: '/tractatus',
|
|
name: 'TEST_EDIT_CREDENTIAL',
|
|
username: msg.credential.username || '',
|
|
password: 'UPDATED-PASSWORD-99999',
|
|
url: msg.credential.url || '',
|
|
notes: 'UPDATED notes via automated test'
|
|
}));
|
|
break;
|
|
|
|
case 'edited':
|
|
console.log(`✓ ${msg.message}\n`);
|
|
|
|
// Step 5: Verify the edit worked
|
|
console.log('Step 5: Verifying changes...');
|
|
ws.send(JSON.stringify({
|
|
type: 'show',
|
|
entry: '/tractatus/TEST_EDIT_CREDENTIAL'
|
|
}));
|
|
|
|
// Mark that we're now verifying
|
|
ws._verifying = true;
|
|
break;
|
|
|
|
case 'error':
|
|
console.error(`✗ Error: ${msg.message}\n`);
|
|
clearTimeout(timeout);
|
|
ws.close();
|
|
reject(new Error(msg.message));
|
|
break;
|
|
}
|
|
|
|
// If we're verifying and got show response
|
|
if (ws._verifying && msg.type === 'show') {
|
|
console.log('✓ Verified updated credential:');
|
|
console.log(` Username: ${msg.credential.username || '(empty)'}`);
|
|
console.log(` Password: ${msg.credential.password ? '***' + msg.credential.password.slice(-4) : '(empty)'}`);
|
|
console.log(` URL: ${msg.credential.url || '(empty)'}`);
|
|
console.log(` Notes: ${msg.credential.notes || '(empty)'}\n`);
|
|
|
|
const success = msg.credential.password === 'UPDATED-PASSWORD-99999' &&
|
|
msg.credential.notes === 'UPDATED notes via automated test';
|
|
|
|
if (success) {
|
|
console.log('════════════════════════════════════════════════════');
|
|
console.log(' ✅ ALL TESTS PASSED!');
|
|
console.log(' Edit functionality is working correctly.');
|
|
console.log('════════════════════════════════════════════════════\n');
|
|
} else {
|
|
console.log('════════════════════════════════════════════════════');
|
|
console.log(' ✗ TEST FAILED!');
|
|
console.log(' Changes were not saved correctly.');
|
|
console.log('════════════════════════════════════════════════════\n');
|
|
}
|
|
|
|
clearTimeout(timeout);
|
|
ws.close();
|
|
rl.close();
|
|
resolve(success);
|
|
}
|
|
});
|
|
|
|
ws.on('error', (error) => {
|
|
console.error('WebSocket error:', error.message);
|
|
clearTimeout(timeout);
|
|
reject(error);
|
|
});
|
|
|
|
ws.on('close', () => {
|
|
console.log('Disconnected from vault server');
|
|
rl.close();
|
|
});
|
|
});
|
|
}
|
|
|
|
testVaultEdit()
|
|
.then((success) => {
|
|
process.exit(success ? 0 : 1);
|
|
})
|
|
.catch((error) => {
|
|
console.error('\nTest failed with error:', error.message);
|
|
rl.close();
|
|
process.exit(1);
|
|
});
|