From ac7751056a8d23bc03fc1d712589f14f8e37a6cb Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Fri, 24 Sep 2021 16:04:38 +0200 Subject: [PATCH] catalog-backend: added regression test for disappearing references Signed-off-by: Patrik Oldsberg --- .../DefaultProcessingDatabase.test.ts | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/plugins/catalog-backend/src/next/database/DefaultProcessingDatabase.test.ts b/plugins/catalog-backend/src/next/database/DefaultProcessingDatabase.test.ts index 4bc828d4e6..05c10da188 100644 --- a/plugins/catalog-backend/src/next/database/DefaultProcessingDatabase.test.ts +++ b/plugins/catalog-backend/src/next/database/DefaultProcessingDatabase.test.ts @@ -747,6 +747,14 @@ describe('Default Processing Database', () => { 'should add new locations using the delta options, %p', async databaseId => { const { knex, db } = await createDatabase(databaseId); + + // Existing state and references should stay + await createLocations(knex, ['location:default/existing']); + await insertRefRow(knex, { + source_key: 'lols', + target_entity_ref: 'location:default/existing', + }); + await db.transaction(async tx => { await db.replaceUnprocessedEntities(tx, { type: 'delta', @@ -788,6 +796,20 @@ describe('Default Processing Database', () => { t.target_entity_ref === 'location:default/new-root', ), ).toBeTruthy(); + + expect( + currentRefreshState.some( + t => t.entity_ref === 'location:default/existing', + ), + ).toBeTruthy(); + + expect( + currentRefRowState.some( + t => + t.source_key === 'lols' && + t.target_entity_ref === 'location:default/existing', + ), + ).toBeTruthy(); }, 60_000, );