diff --git a/tests/e2e/src/application/repositories/account.repository.ts b/tests/e2e/src/application/repositories/account.repository.ts index c6989e3c..1f4824a2 100644 --- a/tests/e2e/src/application/repositories/account.repository.ts +++ b/tests/e2e/src/application/repositories/account.repository.ts @@ -21,6 +21,27 @@ export class AccountRepository { return account; } + async getAll(fromAccountId?: AccountId, limit?: number): Promise { + const accounts = []; + for await (const envelopes of this.accountSnapshotHandler.loadMany({ + fromId: fromAccountId, + limit, + })) { + for (const { metadata, payload } of envelopes) { + const id = AccountId.from(metadata.aggregateId); + const eventStream = EventStream.for(Account, id); + const account = this.accountSnapshotHandler.deserialize(payload); + + const eventCursor = this.eventStore.getEvents(eventStream, { fromVersion: metadata.version + 1 }); + await account.loadFromHistory(eventCursor); + + accounts.push(account); + } + } + + return accounts; + } + async save(account: Account): Promise { const events = account.commit(); const stream = EventStream.for(Account, account.id);