fix(test): update seed scripts to require valid plan handle IDs

- Replace placeholder plan IDs with explicit warnings
  - Change from test_project_X to PLACEHOLDER_ID_X
  - Add validation to prevent seeding with placeholders
  - Add helpful error messages with usage examples

- Add comprehensive guide for getting valid plan IDs
  - Methods: Create projects, query database, check account settings
  - Format examples: UUID, hash, custom formats
  - Step-by-step instructions for each method
  - Troubleshooting common issues

- Update test-user-zero.ts with placeholder warnings
  - Clear instructions on how to get real plan IDs
  - Links to documentation
  - Notes about plan ID format variations

- Improve test server startup
  - Warn when using placeholder IDs
  - Allow plan IDs via command line argument
  - Provide guidance on updating config

The previous test_project_X IDs were not valid for real TimeSafari
databases. Users must now provide actual plan handle IDs from their
TimeSafari setup, making testing more realistic and avoiding silent
failures with invalid IDs.
This commit is contained in:
Matthew Raymer
2025-10-29 12:18:10 +00:00
parent f5dca34e84
commit 7a19a56ea2
4 changed files with 263 additions and 12 deletions

View File

@@ -38,11 +38,33 @@ app.use((req, res, next) => {
* Seed test projects on startup
*/
function seedProjects(projectIds = DEFAULT_TEST_PROJECT_IDS) {
// Check if using placeholder IDs
if (projectIds.some(id => id.startsWith('PLACEHOLDER'))) {
console.warn('');
console.warn('⚠️ WARNING: Using placeholder plan handle IDs!');
console.warn(' The test server will work, but you need to:');
console.warn(' 1. Get valid plan handle IDs from your TimeSafari database');
console.warn(' 2. Update test-user-zero.ts with real plan IDs');
console.warn(' 3. Or provide valid IDs via command line:');
console.warn(' node scripts/test-api-server-with-seed.js [port] "id1,id2,id3"');
console.warn('');
console.warn(' For now, the server will use placeholder IDs for testing structure only.');
console.warn('');
}
seededProjects = generateAllTestProjects(projectIds);
console.log(`🌱 Seeded ${seededProjects.length} test projects:`);
seededProjects.forEach((project, index) => {
console.log(` ${index + 1}. ${project.planSummary.handleId} - ${project.planSummary.name}`);
});
if (projectIds.some(id => id.startsWith('PLACEHOLDER'))) {
console.log('');
console.log('📝 To use real plan IDs, update:');
console.log(' test-apps/daily-notification-test/src/config/test-user-zero.ts');
console.log(' starredProjects.planIds = ["your", "real", "plan", "ids"]');
console.log('');
}
}
/**
@@ -143,7 +165,11 @@ app.get('/api/test/health', (req, res) => {
});
// Start server
seedProjects(); // Seed on startup
// Allow plan IDs to be passed as command line argument
const planIdsArg = process.argv[3];
const planIdsToUse = planIdsArg ? planIdsArg.split(',') : DEFAULT_TEST_PROJECT_IDS;
seedProjects(planIdsToUse); // Seed on startup
app.listen(PORT, () => {
console.log('');