{ "Empty queries are resolved if client goes offline": { "describeName": "Offline:", "itName": "Empty queries are resolved if client goes offline", "tags": [], "config": { "useGarbageCollection": true, "numClients": 1 }, "steps": [ { "userListen": [ 2, { "path": "collection", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "" } } } }, { "watchStreamClose": { "error": { "code": 14, "message": "Simulated Backend Error" }, "runBackoffTimer": true }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "errorCode": 0, "fromCache": true, "hasPendingWrites": false } ] }, { "watchStreamClose": { "error": { "code": 14, "message": "Simulated Backend Error" }, "runBackoffTimer": true } }, { "watchStreamClose": { "error": { "code": 14, "message": "Simulated Backend Error" }, "runBackoffTimer": true } } ] }, "A successful message delays offline status": { "describeName": "Offline:", "itName": "A successful message delays offline status", "tags": [], "config": { "useGarbageCollection": true, "numClients": 1 }, "steps": [ { "userListen": [ 2, { "path": "collection", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "" } } } }, { "watchAck": [ 2 ] }, { "watchStreamClose": { "error": { "code": 14, "message": "Simulated Backend Error" }, "runBackoffTimer": true } }, { "watchStreamClose": { "error": { "code": 14, "message": "Simulated Backend Error" }, "runBackoffTimer": true }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "errorCode": 0, "fromCache": true, "hasPendingWrites": false } ] }, { "watchStreamClose": { "error": { "code": 14, "message": "Simulated Backend Error" }, "runBackoffTimer": true } }, { "watchStreamClose": { "error": { "code": 14, "message": "Simulated Backend Error" }, "runBackoffTimer": true } } ] }, "Removing all listeners delays \"Offline\" status on next listen": { "describeName": "Offline:", "itName": "Removing all listeners delays \"Offline\" status on next listen", "tags": [ "eager-gc" ], "comment": "Marked as no-lru because when a listen is re-added, it gets a new target id rather than reusing one", "config": { "useGarbageCollection": true, "numClients": 1 }, "steps": [ { "userListen": [ 2, { "path": "collection", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "" } } } }, { "watchStreamClose": { "error": { "code": 14, "message": "Simulated Backend Error" }, "runBackoffTimer": true }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "errorCode": 0, "fromCache": true, "hasPendingWrites": false } ] }, { "userUnlisten": [ 2, { "path": "collection", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": {} } }, { "watchStreamClose": { "error": { "code": 14, "message": "Simulated Backend Error" }, "runBackoffTimer": true } }, { "userListen": [ 4, { "path": "collection", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "4": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "" } } } }, { "watchStreamClose": { "error": { "code": 14, "message": "Simulated Backend Error" }, "runBackoffTimer": true }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "errorCode": 0, "fromCache": true, "hasPendingWrites": false } ] } ] }, "Queries revert to fromCache=true when offline.": { "describeName": "Offline:", "itName": "Queries revert to fromCache=true when offline.", "tags": [], "config": { "useGarbageCollection": true, "numClients": 1 }, "steps": [ { "userListen": [ 2, { "path": "collection", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "" } } } }, { "watchAck": [ 2 ] }, { "watchEntity": { "docs": [ { "key": "collection/a", "version": 1000, "value": { "key": "a" }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] } }, { "watchCurrent": [ [ 2 ], "resume-token-1000" ] }, { "watchSnapshot": { "version": 1000, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a", "version": 1000, "value": { "key": "a" }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ] }, { "watchStreamClose": { "error": { "code": 14, "message": "Simulated Backend Error" }, "runBackoffTimer": true }, "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "resume-token-1000" } } } }, { "watchStreamClose": { "error": { "code": 14, "message": "Simulated Backend Error" }, "runBackoffTimer": true }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "errorCode": 0, "fromCache": true, "hasPendingWrites": false } ] }, { "watchAck": [ 2 ] }, { "watchEntity": { "docs": [], "targets": [ 2 ] } }, { "watchCurrent": [ [ 2 ], "resume-token-1000" ] }, { "watchSnapshot": { "version": 1000, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ] } ] }, "Queries with limbo documents handle going offline.": { "describeName": "Offline:", "itName": "Queries with limbo documents handle going offline.", "tags": [], "config": { "useGarbageCollection": true, "numClients": 1 }, "steps": [ { "userListen": [ 2, { "path": "collection", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "" } } } }, { "watchAck": [ 2 ] }, { "watchEntity": { "docs": [ { "key": "collection/a", "version": 1000, "value": { "key": "a" }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] } }, { "watchCurrent": [ [ 2 ], "resume-token-1000" ] }, { "watchSnapshot": { "version": 1000, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a", "version": 1000, "value": { "key": "a" }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ] }, { "watchReset": [ 2 ] }, { "watchCurrent": [ [ 2 ], "resume-token-1001" ] }, { "watchSnapshot": { "version": 1001, "targetIds": [] }, "expectedState": { "limboDocs": [ "collection/a" ], "activeTargets": { "1": { "queries": [ { "path": "collection/a", "filters": [], "orderBys": [] } ], "resumeToken": "" }, "2": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "" } } }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "errorCode": 0, "fromCache": true, "hasPendingWrites": false } ] }, { "watchStreamClose": { "error": { "code": 14, "message": "Simulated Backend Error" }, "runBackoffTimer": true }, "expectedState": { "activeTargets": { "1": { "queries": [ { "path": "collection/a", "filters": [], "orderBys": [] } ], "resumeToken": "" }, "2": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "resume-token-1001" } } } }, { "watchStreamClose": { "error": { "code": 14, "message": "Simulated Backend Error" }, "runBackoffTimer": true } }, { "watchAck": [ 2 ] }, { "watchEntity": { "docs": [], "targets": [ 2 ] } }, { "watchCurrent": [ [ 2 ], "resume-token-1001" ] }, { "watchSnapshot": { "version": 1001, "targetIds": [] } }, { "watchAck": [ 1 ] }, { "watchEntity": { "docs": [], "targets": [ 1 ] } }, { "watchCurrent": [ [ 1 ], "resume-token-1001" ] }, { "watchSnapshot": { "version": 1001, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "removed": [ { "key": "collection/a", "version": 1000, "value": { "key": "a" }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ], "expectedState": { "limboDocs": [], "activeTargets": { "2": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "resume-token-1001" } } } } ] }, "OnlineState timeout triggers offline behavior": { "describeName": "Offline:", "itName": "OnlineState timeout triggers offline behavior", "tags": [], "config": { "useGarbageCollection": true, "numClients": 1 }, "steps": [ { "userListen": [ 2, { "path": "collection", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "" } } } }, { "runTimer": "online_state_timeout", "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "errorCode": 0, "fromCache": true, "hasPendingWrites": false } ] }, { "watchStreamClose": { "error": { "code": 14, "message": "Simulated Backend Error" }, "runBackoffTimer": true } }, { "watchStreamClose": { "error": { "code": 14, "message": "Simulated Backend Error" }, "runBackoffTimer": true } }, { "watchAck": [ 2 ] }, { "watchEntity": { "docs": [ { "key": "collection/a", "version": 1000, "value": { "key": "a" }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] } }, { "watchCurrent": [ [ 2 ], "resume-token-1000" ] }, { "watchSnapshot": { "version": 1000, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a", "version": 1000, "value": { "key": "a" }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ] }, { "runTimer": "all" }, { "watchStreamClose": { "error": { "code": 14, "message": "Simulated Backend Error" }, "runBackoffTimer": true }, "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "resume-token-1000" } } } }, { "runTimer": "online_state_timeout", "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "errorCode": 0, "fromCache": true, "hasPendingWrites": false } ] } ] }, "New queries return immediately with fromCache=true when offline due to stream failures.": { "describeName": "Offline:", "itName": "New queries return immediately with fromCache=true when offline due to stream failures.", "tags": [], "config": { "useGarbageCollection": true, "numClients": 1 }, "steps": [ { "userListen": [ 2, { "path": "collection", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "" } } } }, { "watchStreamClose": { "error": { "code": 14, "message": "Simulated Backend Error" }, "runBackoffTimer": true }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "errorCode": 0, "fromCache": true, "hasPendingWrites": false } ] }, { "userListen": [ 4, { "path": "collection2", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "" }, "4": { "queries": [ { "path": "collection2", "filters": [], "orderBys": [] } ], "resumeToken": "" } } }, "expectedSnapshotEvents": [ { "query": { "path": "collection2", "filters": [], "orderBys": [] }, "errorCode": 0, "fromCache": true, "hasPendingWrites": false } ] } ] }, "New queries return immediately with fromCache=true when offline due to OnlineState timeout.": { "describeName": "Offline:", "itName": "New queries return immediately with fromCache=true when offline due to OnlineState timeout.", "tags": [], "config": { "useGarbageCollection": true, "numClients": 1 }, "steps": [ { "userListen": [ 2, { "path": "collection", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "" } } } }, { "runTimer": "online_state_timeout", "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "errorCode": 0, "fromCache": true, "hasPendingWrites": false } ] }, { "userListen": [ 4, { "path": "collection2", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "" }, "4": { "queries": [ { "path": "collection2", "filters": [], "orderBys": [] } ], "resumeToken": "" } } }, "expectedSnapshotEvents": [ { "query": { "path": "collection2", "filters": [], "orderBys": [] }, "errorCode": 0, "fromCache": true, "hasPendingWrites": false } ] } ] }, "Queries return from cache when network disabled": { "describeName": "Offline:", "itName": "Queries return from cache when network disabled", "tags": [ "eager-gc" ], "config": { "useGarbageCollection": true, "numClients": 1 }, "steps": [ { "enableNetwork": false, "expectedState": { "activeTargets": {}, "limboDocs": [] } }, { "userListen": [ 2, { "path": "collection", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "" } } }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "errorCode": 0, "fromCache": true, "hasPendingWrites": false } ] }, { "userUnlisten": [ 2, { "path": "collection", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": {} } }, { "userListen": [ 4, { "path": "collection", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "4": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "" } } }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "errorCode": 0, "fromCache": true, "hasPendingWrites": false } ] }, { "userUnlisten": [ 4, { "path": "collection", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": {} } } ] } }