diff --git a/src/core/adapters/datastore/default.ts b/src/core/adapters/datastore/default.ts index d8640a31..faa2a28a 100644 --- a/src/core/adapters/datastore/default.ts +++ b/src/core/adapters/datastore/default.ts @@ -1,5 +1,6 @@ import Dexie, { type Table } from 'dexie' +import { mockPrefixIdSu } from '@/core/adapters/queenApi/mock' import type { Paradata, SurveyUnit } from '@/core/model' import type { DataStore } from '@/core/ports/DataStore' @@ -21,7 +22,10 @@ export function createDataStore(params: { return { updateSurveyUnit: (surveyUnit) => db.surveyUnit.put(surveyUnit), deleteSurveyUnit: (id) => db.surveyUnit.delete(id), - getAllSurveyUnits: () => db.surveyUnit.toArray(), + getAllSurveyUnits: () => + db.surveyUnit + .filter(({ id }) => !id.startsWith(mockPrefixIdSu)) + .toArray(), getSurveyUnit: (id) => db.surveyUnit.get(id), getAllParadatas: () => db.paradata.toArray(), deleteParadata: (id) => db.paradata.delete(id), diff --git a/src/core/adapters/queenApi/mock.ts b/src/core/adapters/queenApi/mock.ts index bea24b3d..a2845b82 100644 --- a/src/core/adapters/queenApi/mock.ts +++ b/src/core/adapters/queenApi/mock.ts @@ -40,13 +40,15 @@ export function createApiClient(): QueenApi { } } +export const mockPrefixIdSu = 'idSU' + function createSUMocked(props: { idSu?: string idCampaign?: string }): SurveyUnit { const { idSu = 'su1', idCampaign = 'campaign1' } = props return { - id: `idSU:${idSu}`, + id: `${mockPrefixIdSu}:${idSu}`, questionnaireId: `idCampaign${idCampaign}`, personalization: [], data: {