fix: update saveNode test mocks for docs preservation pattern

Tests now account for the SELECT query that reads existing docs
before INSERT OR REPLACE, and the 3 extra params (npm_readme,
ai_documentation_summary, ai_summary_generated_at).

Conceived by Romuald Członkowski - https://www.aiadvisors.pl/en

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
czlonkowski
2026-03-26 15:02:20 +01:00
parent ab2dc9824e
commit af2cfec668
3 changed files with 36 additions and 7 deletions

View File

@@ -119,8 +119,13 @@ class MockPreparedStatement implements PreparedStatement {
});
}
// saveNode - SELECT existing doc fields before upsert
if (this.sql.includes('SELECT npm_readme, ai_documentation_summary, ai_summary_generated_at FROM nodes')) {
this.get = vi.fn(() => undefined); // No existing row by default
}
// saveNode - INSERT OR REPLACE
if (this.sql.includes('INSERT INTO nodes')) {
if (this.sql.includes('INSERT OR REPLACE INTO nodes')) {
this.run = vi.fn((...params: any[]): RunResult => {
const nodes = this.mockData.get('community_nodes') || [];
const nodeType = params[0];