Skip to content

Disable some spec tests on mobile #1134

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 2 commits into from
Aug 17, 2018
Merged
Show file tree
Hide file tree
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
182 changes: 99 additions & 83 deletions packages/firestore/test/unit/specs/offline_spec.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,45 +23,53 @@ import { spec } from './spec_builder';
import { TimerId } from '../../../src/util/async_queue';

describeSpec('Offline:', [], () => {
specTest('Empty queries are resolved if client goes offline', [], () => {
const query = Query.atPath(path('collection'));
return (
spec()
.userListens(query)
.watchStreamCloses(Code.UNAVAILABLE)
.expectEvents(query, {
fromCache: true,
hasPendingWrites: false
})
// no further events
.watchStreamCloses(Code.UNAVAILABLE)
.watchStreamCloses(Code.UNAVAILABLE)
);
});
specTest(
'Empty queries are resolved if client goes offline',
['no-android', 'no-ios'],
() => {
const query = Query.atPath(path('collection'));
return (
spec()
.userListens(query)
.watchStreamCloses(Code.UNAVAILABLE)
.expectEvents(query, {
fromCache: true,
hasPendingWrites: false
})
// no further events
.watchStreamCloses(Code.UNAVAILABLE)
.watchStreamCloses(Code.UNAVAILABLE)
);
}
);

specTest('A successful message delays offline status', [], () => {
const query = Query.atPath(path('collection'));
return (
spec()
.userListens(query)
.watchAcks(query)
// first error triggers unknown state
.watchStreamCloses(Code.UNAVAILABLE)
// second error triggers offline state
.watchStreamCloses(Code.UNAVAILABLE)
.expectEvents(query, {
fromCache: true,
hasPendingWrites: false
})
// no further events
.watchStreamCloses(Code.UNAVAILABLE)
.watchStreamCloses(Code.UNAVAILABLE)
);
});
specTest(
'A successful message delays offline status',
['no-android', 'no-ios'],
() => {
const query = Query.atPath(path('collection'));
return (
spec()
.userListens(query)
.watchAcks(query)
// first error triggers unknown state
.watchStreamCloses(Code.UNAVAILABLE)
// second error triggers offline state
.watchStreamCloses(Code.UNAVAILABLE)
.expectEvents(query, {
fromCache: true,
hasPendingWrites: false
})
// no further events
.watchStreamCloses(Code.UNAVAILABLE)
.watchStreamCloses(Code.UNAVAILABLE)
);
}
);

specTest(
'Removing all listeners delays "Offline" status on next listen',
['eager-gc'],
['eager-gc', 'no-android', 'no-ios'],
'Marked as no-lru because when a listen is re-added, it gets a new target id rather than reusing one',
() => {
const query = Query.atPath(path('collection'));
Expand Down Expand Up @@ -91,54 +99,62 @@ describeSpec('Offline:', [], () => {
}
);

specTest('Queries revert to fromCache=true when offline.', [], () => {
const query = Query.atPath(path('collection'));
const docA = doc('collection/a', 1000, { key: 'a' });
return (
spec()
.userListens(query)
.watchAcksFull(query, 1000, docA)
.expectEvents(query, { added: [docA] })
// first error triggers unknown state
.watchStreamCloses(Code.UNAVAILABLE)
.restoreListen(query, 'resume-token-1000')
// second error triggers offline state and fromCache: true
.watchStreamCloses(Code.UNAVAILABLE)
.expectEvents(query, { fromCache: true })
// Going online and getting a CURRENT message triggers fromCache: false
.watchAcksFull(query, 1000)
.expectEvents(query, { fromCache: false })
);
});
specTest(
'Queries revert to fromCache=true when offline.',
['no-android', 'no-ios'],
() => {
const query = Query.atPath(path('collection'));
const docA = doc('collection/a', 1000, { key: 'a' });
return (
spec()
.userListens(query)
.watchAcksFull(query, 1000, docA)
.expectEvents(query, { added: [docA] })
// first error triggers unknown state
.watchStreamCloses(Code.UNAVAILABLE)
.restoreListen(query, 'resume-token-1000')
// second error triggers offline state and fromCache: true
.watchStreamCloses(Code.UNAVAILABLE)
.expectEvents(query, { fromCache: true })
// Going online and getting a CURRENT message triggers fromCache: false
.watchAcksFull(query, 1000)
.expectEvents(query, { fromCache: false })
);
}
);

specTest('Queries with limbo documents handle going offline.', [], () => {
const query = Query.atPath(path('collection'));
const docA = doc('collection/a', 1000, { key: 'a' });
const limboQuery = Query.atPath(docA.key.path);
return (
spec()
.userListens(query)
.watchAcksFull(query, 1000, docA)
.expectEvents(query, { added: [docA] })
.watchResets(query)
// No more documents
.watchCurrents(query, 'resume-token-1001')
.watchSnapshots(1001)
// docA will now be in limbo (triggering fromCache=true)
.expectLimboDocs(docA.key)
.expectEvents(query, { fromCache: true })
// first error triggers unknown state
.watchStreamCloses(Code.UNAVAILABLE)
.restoreListen(query, 'resume-token-1001')
// second error triggers offline state.
.watchStreamCloses(Code.UNAVAILABLE)
.watchAcksFull(query, 1001)
.watchAcksFull(limboQuery, 1001)
// Limbo document is resolved. No longer from cache.
.expectEvents(query, { removed: [docA], fromCache: false })
.expectLimboDocs()
);
});
specTest(
'Queries with limbo documents handle going offline.',
['no-android', 'no-ios'],
() => {
const query = Query.atPath(path('collection'));
const docA = doc('collection/a', 1000, { key: 'a' });
const limboQuery = Query.atPath(docA.key.path);
return (
spec()
.userListens(query)
.watchAcksFull(query, 1000, docA)
.expectEvents(query, { added: [docA] })
.watchResets(query)
// No more documents
.watchCurrents(query, 'resume-token-1001')
.watchSnapshots(1001)
// docA will now be in limbo (triggering fromCache=true)
.expectLimboDocs(docA.key)
.expectEvents(query, { fromCache: true })
// first error triggers unknown state
.watchStreamCloses(Code.UNAVAILABLE)
.restoreListen(query, 'resume-token-1001')
// second error triggers offline state.
.watchStreamCloses(Code.UNAVAILABLE)
.watchAcksFull(query, 1001)
.watchAcksFull(limboQuery, 1001)
// Limbo document is resolved. No longer from cache.
.expectEvents(query, { removed: [docA], fromCache: false })
.expectLimboDocs()
);
}
);

specTest('OnlineState timeout triggers offline behavior', [], () => {
const query = Query.atPath(path('collection'));
Expand Down Expand Up @@ -177,7 +193,7 @@ describeSpec('Offline:', [], () => {
specTest(
'New queries return immediately with fromCache=true when offline due to ' +
'stream failures.',
[],
['no-android', 'no-ios'],
() => {
const query1 = Query.atPath(path('collection'));
const query2 = Query.atPath(path('collection2'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describeSpec('Remote store:', [], () => {
.expectEvents(query, { added: [doc4] }); // This should work now.
});

specTest('Cleans up watch state correctly', [], () => {
specTest('Cleans up watch state correctly', ['no-android', 'no-ios'], () => {
const query = Query.atPath(path('collection'));
const doc1 = doc('collection/a', 1000, { key: 'a' });
return (
Expand Down