Skip to content

Commit

Permalink
Fix audit log races
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesdaniels committed Dec 12, 2024
1 parent 52eee74 commit 08c7827
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions test/firestore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,18 +299,18 @@ describe('RxFire Firestore', () => {
*/
it('should filter the trail of events by event type', (done: jest.DoneCallback) => {
seedTest(firestore).then(({colRef, davidDoc}) => {
const firstAudit = auditTrail(colRef).pipe(unwrapChange, take(1));
const modifiedAudit = auditTrail(colRef, {events: ['modified']}).pipe(unwrapChange);

firstAudit.pipe(take(1)).subscribe(() => {
updateDoc(davidDoc, {name: 'David!'});
});

modifiedAudit.pipe(take(1)).subscribe((updateList) => {
const expectedEvents = [{type: 'modified', name: 'David!'}];
expect(updateList).toEqual(expectedEvents);
done();
});

// TODO figure out the race condition here
setTimeout(() => {
updateDoc(davidDoc, {name: 'David!'});
}, 10);
});
});
});
Expand Down Expand Up @@ -348,15 +348,18 @@ describe('RxFire Firestore', () => {
*/
it('should filter the trail of events by event type', (done: jest.DoneCallback) => {
seedTest(firestore).then(({colRef, davidDoc}) => {
const firstAudit = auditTrail(colRef).pipe(unwrapChange, take(1));
const modifiedAudit = auditTrail(colRef, {events: ['modified']}).pipe(unwrapChange);

firstAudit.pipe(take(1)).subscribe(() => {
updateDoc(davidDoc, {name: 'David!'});
});

modifiedAudit.pipe(take(1)).subscribe((updateList) => {
const expectedEvents = [{type: 'modified', name: 'David!'}];
expect(updateList).toEqual(expectedEvents);
done();
});

updateDoc(davidDoc, {name: 'David!'});
});
});
});
Expand Down

0 comments on commit 08c7827

Please sign in to comment.