Skip to content

Fix flaky test. #1511

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 1, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions packages/firestore/test/integration/api/server_timestamp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,12 @@ apiDescribe('Server Timestamps', persistence => {
it('can return previous value through consecutive updates', () => {
return withTestSetup(() => {
return writeInitialData()
.then(() => docRef.firestore.disableNetwork)
.then(() => docRef.firestore.disableNetwork())
.then(() => {
// We set up two consecutive writes with server timestamps.
docRef.update('a', FieldValue.serverTimestamp());
docRef.update('a', FieldValue.serverTimestamp());
// include b=1 to ensure there's a change resulting in a new snapshot.
docRef.update('a', FieldValue.serverTimestamp(), 'b', 1);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the actual fix. The rest is just making the test actually disable/re-enable the network and match the other ports.

return accumulator.awaitLocalEvents(2);
})
.then(snapshots => {
Expand All @@ -260,14 +261,19 @@ apiDescribe('Server Timestamps', persistence => {
expect(
snapshots[1].get('a', { serverTimestamps: 'previous' })
).to.equal(42);
return docRef.firestore.enableNetwork();
})
.then(() => accumulator.awaitRemoteEvent())
.then(remoteSnapshot => {
expect(remoteSnapshot.get('a')).to.be.an.instanceof(Timestamp);
});
});
});

it('uses previous value from local mutation', () => {
return withTestSetup(() => {
return writeInitialData()
.then(() => docRef.firestore.disableNetwork)
.then(() => docRef.firestore.disableNetwork())
.then(() => {
// We set up three consecutive writes.
docRef.update('a', FieldValue.serverTimestamp());
Expand All @@ -284,6 +290,11 @@ apiDescribe('Server Timestamps', persistence => {
expect(
snapshots[2].get('a', { serverTimestamps: 'previous' })
).to.equal(1337);
return docRef.firestore.enableNetwork();
})
.then(() => accumulator.awaitRemoteEvent())
.then(remoteSnapshot => {
expect(remoteSnapshot.get('a')).to.be.an.instanceof(Timestamp);
});
});
});
Expand Down