fix(tests): resolve foreign key constraints and remove get_node_for_task from integration tests

Two critical fixes for integration test failures:

**1. Foreign Key Constraint Violations**
Root cause: Tests inserted into template_node_configs without corresponding
entries in templates table, causing FK constraint failures.

Fixes:
- template-node-configs.test.ts: Pre-create 1000 test templates in beforeEach()
- template-examples-e2e.test.ts: Create templates in seedTemplateConfigs() and
  adjust test cases to use non-conflicting template IDs

**2. Removed Tool References**
Root cause: Tests referenced get_node_for_task tool removed in v2.15.0.

Fixes:
- tool-invocation.test.ts: Removed entire get_node_for_task test suite
- session-management.test.ts: Replaced get_node_for_task test with search_nodes

Test results:
 template-node-configs.test.ts: 20/20 passed
 template-examples-e2e.test.ts: 13/13 passed
 tool-invocation.test.ts: 28/28 passed
 session-management.test.ts: 16 passed, 2 skipped

All integration tests now comply with foreign key constraints and use only
existing MCP tools as of v2.15.0.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
czlonkowski
2025-10-03 08:59:16 +02:00
parent 0bf0e1cd74
commit 8ffda534be
4 changed files with 63 additions and 54 deletions

View File

@@ -27,6 +27,18 @@ describe('Template Node Configs Database Integration', () => {
const migrationPath = path.join(__dirname, '../../../src/database/migrations/add-template-node-configs.sql');
const migration = fs.readFileSync(migrationPath, 'utf-8');
db.exec(migration);
// Insert test templates with id 1-1000 to satisfy foreign key constraints
// Tests insert configs with various template_id values, so we pre-create many templates
const stmt = db.prepare(`
INSERT INTO templates (
id, workflow_id, name, description, views,
nodes_used, created_at, updated_at
) VALUES (?, ?, ?, ?, ?, ?, datetime('now'), datetime('now'))
`);
for (let i = 1; i <= 1000; i++) {
stmt.run(i, i, `Test Template ${i}`, 'Test template for node configs', 100, '[]');
}
});
afterEach(() => {
@@ -242,14 +254,7 @@ describe('Template Node Configs Database Integration', () => {
beforeEach(() => {
// Enable foreign keys
db.exec('PRAGMA foreign_keys = ON');
// Create a template first
db.prepare(`
INSERT INTO templates (
id, workflow_id, name, description, views,
nodes_used, created_at, updated_at
) VALUES (?, ?, ?, ?, ?, ?, datetime('now'), datetime('now'))
`).run(1, 100, 'Test Template', 'Description', 500, '[]');
// Note: Templates are already created in the main beforeEach
});
it('should allow inserting config with valid template_id', () => {