{
  "Deleted Document in limbo in full limit query": {
    "describeName": "Limits:",
    "itName": "Deleted Document in limbo in full limit query",
    "tags": [
    ],
    "config": {
      "numClients": 1,
      "useEagerGCForMemory": true
    },
    "steps": [
      {
        "userListen": {
          "query": {
            "filters": [
            ],
            "limit": 2,
            "limitType": "LimitToFirst",
            "orderBys": [
            ],
            "path": "collection"
          },
          "targetId": 2
        },
        "expectedState": {
          "activeTargets": {
            "2": {
              "queries": [
                {
                  "filters": [
                  ],
                  "limit": 2,
                  "limitType": "LimitToFirst",
                  "orderBys": [
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": ""
            }
          }
        }
      },
      {
        "watchAck": [
          2
        ]
      },
      {
        "watchEntity": {
          "docs": [
            {
              "createTime": 0,
              "key": "collection/a",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "key": "a"
              },
              "version": 1000
            },
            {
              "createTime": 0,
              "key": "collection/b",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "key": "b"
              },
              "version": 1001
            }
          ],
          "targets": [
            2
          ]
        }
      },
      {
        "watchCurrent": [
          [
            2
          ],
          "resume-token-1002"
        ]
      },
      {
        "watchSnapshot": {
          "targetIds": [
          ],
          "version": 1002
        },
        "expectedSnapshotEvents": [
          {
            "added": [
              {
                "createTime": 0,
                "key": "collection/a",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "a"
                },
                "version": 1000
              },
              {
                "createTime": 0,
                "key": "collection/b",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "b"
                },
                "version": 1001
              }
            ],
            "errorCode": 0,
            "fromCache": false,
            "hasPendingWrites": false,
            "query": {
              "filters": [
              ],
              "limit": 2,
              "limitType": "LimitToFirst",
              "orderBys": [
              ],
              "path": "collection"
            }
          }
        ]
      },
      {
        "watchReset": [
          2
        ]
      },
      {
        "watchEntity": {
          "docs": [
            {
              "createTime": 0,
              "key": "collection/b",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "key": "b"
              },
              "version": 1001
            },
            {
              "createTime": 0,
              "key": "collection/c",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "key": "c"
              },
              "version": 1002
            }
          ],
          "targets": [
            2
          ]
        }
      },
      {
        "watchCurrent": [
          [
            2
          ],
          "resume-token-2000"
        ]
      },
      {
        "watchSnapshot": {
          "targetIds": [
          ],
          "version": 2000
        },
        "expectedSnapshotEvents": [
          {
            "errorCode": 0,
            "fromCache": true,
            "hasPendingWrites": false,
            "query": {
              "filters": [
              ],
              "limit": 2,
              "limitType": "LimitToFirst",
              "orderBys": [
              ],
              "path": "collection"
            }
          }
        ],
        "expectedState": {
          "activeLimboDocs": [
            "collection/a"
          ],
          "activeTargets": {
            "1": {
              "queries": [
                {
                  "filters": [
                  ],
                  "orderBys": [
                  ],
                  "path": "collection/a"
                }
              ],
              "resumeToken": "",
              "targetPurpose": "TargetPurposeLimboResolution"
            },
            "2": {
              "queries": [
                {
                  "filters": [
                  ],
                  "limit": 2,
                  "limitType": "LimitToFirst",
                  "orderBys": [
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": ""
            }
          }
        }
      },
      {
        "watchAck": [
          1
        ]
      },
      {
        "watchCurrent": [
          [
            1
          ],
          "resume-token-2000"
        ]
      },
      {
        "watchSnapshot": {
          "targetIds": [
          ],
          "version": 2000
        },
        "expectedSnapshotEvents": [
          {
            "added": [
              {
                "createTime": 0,
                "key": "collection/c",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "c"
                },
                "version": 1002
              }
            ],
            "errorCode": 0,
            "fromCache": false,
            "hasPendingWrites": false,
            "query": {
              "filters": [
              ],
              "limit": 2,
              "limitType": "LimitToFirst",
              "orderBys": [
              ],
              "path": "collection"
            },
            "removed": [
              {
                "createTime": 0,
                "key": "collection/a",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "a"
                },
                "version": 1000
              }
            ]
          }
        ],
        "expectedState": {
          "activeLimboDocs": [
          ],
          "activeTargets": {
            "2": {
              "queries": [
                {
                  "filters": [
                  ],
                  "limit": 2,
                  "limitType": "LimitToFirst",
                  "orderBys": [
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": ""
            }
          }
        }
      }
    ]
  },
  "Documents in limit are can handle removed messages for only one of many query": {
    "describeName": "Limits:",
    "itName": "Documents in limit are can handle removed messages for only one of many query",
    "tags": [
    ],
    "config": {
      "numClients": 1,
      "useEagerGCForMemory": true
    },
    "steps": [
      {
        "userListen": {
          "query": {
            "filters": [
            ],
            "limit": 2,
            "limitType": "LimitToFirst",
            "orderBys": [
            ],
            "path": "collection"
          },
          "targetId": 2
        },
        "expectedState": {
          "activeTargets": {
            "2": {
              "queries": [
                {
                  "filters": [
                  ],
                  "limit": 2,
                  "limitType": "LimitToFirst",
                  "orderBys": [
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": ""
            }
          }
        }
      },
      {
        "userListen": {
          "query": {
            "filters": [
            ],
            "limit": 3,
            "limitType": "LimitToFirst",
            "orderBys": [
            ],
            "path": "collection"
          },
          "targetId": 4
        },
        "expectedState": {
          "activeTargets": {
            "2": {
              "queries": [
                {
                  "filters": [
                  ],
                  "limit": 2,
                  "limitType": "LimitToFirst",
                  "orderBys": [
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": ""
            },
            "4": {
              "queries": [
                {
                  "filters": [
                  ],
                  "limit": 3,
                  "limitType": "LimitToFirst",
                  "orderBys": [
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": ""
            }
          }
        }
      },
      {
        "watchAck": [
          2
        ]
      },
      {
        "watchAck": [
          4
        ]
      },
      {
        "watchEntity": {
          "docs": [
            {
              "createTime": 0,
              "key": "collection/a",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "key": "a"
              },
              "version": 1000
            },
            {
              "createTime": 0,
              "key": "collection/c",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "key": "c"
              },
              "version": 1001
            }
          ],
          "targets": [
            2
          ]
        }
      },
      {
        "watchEntity": {
          "docs": [
            {
              "createTime": 0,
              "key": "collection/a",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "key": "a"
              },
              "version": 1000
            },
            {
              "createTime": 0,
              "key": "collection/c",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "key": "c"
              },
              "version": 1001
            }
          ],
          "targets": [
            4
          ]
        }
      },
      {
        "watchCurrent": [
          [
            2
          ],
          "resume-token-1001"
        ]
      },
      {
        "watchCurrent": [
          [
            4
          ],
          "resume-token-1001"
        ]
      },
      {
        "watchSnapshot": {
          "targetIds": [
          ],
          "version": 1001
        },
        "expectedSnapshotEvents": [
          {
            "added": [
              {
                "createTime": 0,
                "key": "collection/a",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "a"
                },
                "version": 1000
              },
              {
                "createTime": 0,
                "key": "collection/c",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "c"
                },
                "version": 1001
              }
            ],
            "errorCode": 0,
            "fromCache": false,
            "hasPendingWrites": false,
            "query": {
              "filters": [
              ],
              "limit": 2,
              "limitType": "LimitToFirst",
              "orderBys": [
              ],
              "path": "collection"
            }
          },
          {
            "added": [
              {
                "createTime": 0,
                "key": "collection/a",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "a"
                },
                "version": 1000
              },
              {
                "createTime": 0,
                "key": "collection/c",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "c"
                },
                "version": 1001
              }
            ],
            "errorCode": 0,
            "fromCache": false,
            "hasPendingWrites": false,
            "query": {
              "filters": [
              ],
              "limit": 3,
              "limitType": "LimitToFirst",
              "orderBys": [
              ],
              "path": "collection"
            }
          }
        ]
      },
      {
        "watchEntity": {
          "docs": [
            {
              "createTime": 0,
              "key": "collection/b",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "key": "b"
              },
              "version": 1002
            }
          ],
          "targets": [
            2,
            4
          ]
        }
      },
      {
        "watchEntity": {
          "key": "collection/c",
          "removedTargets": [
            2
          ]
        }
      },
      {
        "watchSnapshot": {
          "targetIds": [
          ],
          "version": 1002
        },
        "expectedSnapshotEvents": [
          {
            "added": [
              {
                "createTime": 0,
                "key": "collection/b",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "b"
                },
                "version": 1002
              }
            ],
            "errorCode": 0,
            "fromCache": false,
            "hasPendingWrites": false,
            "query": {
              "filters": [
              ],
              "limit": 2,
              "limitType": "LimitToFirst",
              "orderBys": [
              ],
              "path": "collection"
            },
            "removed": [
              {
                "createTime": 0,
                "key": "collection/c",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "c"
                },
                "version": 1001
              }
            ]
          },
          {
            "added": [
              {
                "createTime": 0,
                "key": "collection/b",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "b"
                },
                "version": 1002
              }
            ],
            "errorCode": 0,
            "fromCache": false,
            "hasPendingWrites": false,
            "query": {
              "filters": [
              ],
              "limit": 3,
              "limitType": "LimitToFirst",
              "orderBys": [
              ],
              "path": "collection"
            }
          }
        ],
        "expectedState": {
          "activeLimboDocs": [
          ],
          "activeTargets": {
            "2": {
              "queries": [
                {
                  "filters": [
                  ],
                  "limit": 2,
                  "limitType": "LimitToFirst",
                  "orderBys": [
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": ""
            },
            "4": {
              "queries": [
                {
                  "filters": [
                  ],
                  "limit": 3,
                  "limitType": "LimitToFirst",
                  "orderBys": [
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": ""
            }
          }
        }
      }
    ]
  },
  "Documents in limit are replaced by remote event": {
    "describeName": "Limits:",
    "itName": "Documents in limit are replaced by remote event",
    "tags": [
    ],
    "config": {
      "numClients": 1,
      "useEagerGCForMemory": true
    },
    "steps": [
      {
        "userListen": {
          "query": {
            "filters": [
            ],
            "limit": 2,
            "limitType": "LimitToFirst",
            "orderBys": [
            ],
            "path": "collection"
          },
          "targetId": 2
        },
        "expectedState": {
          "activeTargets": {
            "2": {
              "queries": [
                {
                  "filters": [
                  ],
                  "limit": 2,
                  "limitType": "LimitToFirst",
                  "orderBys": [
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": ""
            }
          }
        }
      },
      {
        "watchAck": [
          2
        ]
      },
      {
        "watchEntity": {
          "docs": [
            {
              "createTime": 0,
              "key": "collection/a",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "key": "a"
              },
              "version": 1000
            },
            {
              "createTime": 0,
              "key": "collection/c",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "key": "c"
              },
              "version": 1001
            }
          ],
          "targets": [
            2
          ]
        }
      },
      {
        "watchCurrent": [
          [
            2
          ],
          "resume-token-1001"
        ]
      },
      {
        "watchSnapshot": {
          "targetIds": [
          ],
          "version": 1001
        },
        "expectedSnapshotEvents": [
          {
            "added": [
              {
                "createTime": 0,
                "key": "collection/a",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "a"
                },
                "version": 1000
              },
              {
                "createTime": 0,
                "key": "collection/c",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "c"
                },
                "version": 1001
              }
            ],
            "errorCode": 0,
            "fromCache": false,
            "hasPendingWrites": false,
            "query": {
              "filters": [
              ],
              "limit": 2,
              "limitType": "LimitToFirst",
              "orderBys": [
              ],
              "path": "collection"
            }
          }
        ]
      },
      {
        "watchEntity": {
          "docs": [
            {
              "createTime": 0,
              "key": "collection/b",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "key": "b"
              },
              "version": 1002
            }
          ],
          "targets": [
            2
          ]
        }
      },
      {
        "watchEntity": {
          "docs": [
            {
              "createTime": 0,
              "key": "collection/c",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "key": "c"
              },
              "version": 1001
            }
          ],
          "removedTargets": [
            2
          ]
        }
      },
      {
        "watchSnapshot": {
          "targetIds": [
          ],
          "version": 1002
        },
        "expectedSnapshotEvents": [
          {
            "added": [
              {
                "createTime": 0,
                "key": "collection/b",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "b"
                },
                "version": 1002
              }
            ],
            "errorCode": 0,
            "fromCache": false,
            "hasPendingWrites": false,
            "query": {
              "filters": [
              ],
              "limit": 2,
              "limitType": "LimitToFirst",
              "orderBys": [
              ],
              "path": "collection"
            },
            "removed": [
              {
                "createTime": 0,
                "key": "collection/c",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "c"
                },
                "version": 1001
              }
            ]
          }
        ]
      }
    ]
  },
  "Documents in limit can handle removed messages": {
    "describeName": "Limits:",
    "itName": "Documents in limit can handle removed messages",
    "tags": [
    ],
    "config": {
      "numClients": 1,
      "useEagerGCForMemory": true
    },
    "steps": [
      {
        "userListen": {
          "query": {
            "filters": [
            ],
            "limit": 2,
            "limitType": "LimitToFirst",
            "orderBys": [
            ],
            "path": "collection"
          },
          "targetId": 2
        },
        "expectedState": {
          "activeTargets": {
            "2": {
              "queries": [
                {
                  "filters": [
                  ],
                  "limit": 2,
                  "limitType": "LimitToFirst",
                  "orderBys": [
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": ""
            }
          }
        }
      },
      {
        "watchAck": [
          2
        ]
      },
      {
        "watchEntity": {
          "docs": [
            {
              "createTime": 0,
              "key": "collection/a",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "key": "a"
              },
              "version": 1000
            },
            {
              "createTime": 0,
              "key": "collection/c",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "key": "c"
              },
              "version": 1001
            }
          ],
          "targets": [
            2
          ]
        }
      },
      {
        "watchCurrent": [
          [
            2
          ],
          "resume-token-1001"
        ]
      },
      {
        "watchSnapshot": {
          "targetIds": [
          ],
          "version": 1001
        },
        "expectedSnapshotEvents": [
          {
            "added": [
              {
                "createTime": 0,
                "key": "collection/a",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "a"
                },
                "version": 1000
              },
              {
                "createTime": 0,
                "key": "collection/c",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "c"
                },
                "version": 1001
              }
            ],
            "errorCode": 0,
            "fromCache": false,
            "hasPendingWrites": false,
            "query": {
              "filters": [
              ],
              "limit": 2,
              "limitType": "LimitToFirst",
              "orderBys": [
              ],
              "path": "collection"
            }
          }
        ]
      },
      {
        "watchEntity": {
          "docs": [
            {
              "createTime": 0,
              "key": "collection/b",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "key": "b"
              },
              "version": 1002
            }
          ],
          "targets": [
            2
          ]
        }
      },
      {
        "watchEntity": {
          "key": "collection/c",
          "removedTargets": [
            2
          ]
        }
      },
      {
        "watchSnapshot": {
          "targetIds": [
          ],
          "version": 1002
        },
        "expectedSnapshotEvents": [
          {
            "added": [
              {
                "createTime": 0,
                "key": "collection/b",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "b"
                },
                "version": 1002
              }
            ],
            "errorCode": 0,
            "fromCache": false,
            "hasPendingWrites": false,
            "query": {
              "filters": [
              ],
              "limit": 2,
              "limitType": "LimitToFirst",
              "orderBys": [
              ],
              "path": "collection"
            },
            "removed": [
              {
                "createTime": 0,
                "key": "collection/c",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "c"
                },
                "version": 1001
              }
            ]
          }
        ],
        "expectedState": {
          "activeLimboDocs": [
          ],
          "activeTargets": {
            "2": {
              "queries": [
                {
                  "filters": [
                  ],
                  "limit": 2,
                  "limitType": "LimitToFirst",
                  "orderBys": [
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": ""
            }
          }
        }
      }
    ]
  },
  "Documents outside of limit don't raise hasPendingWrites": {
    "describeName": "Limits:",
    "itName": "Documents outside of limit don't raise hasPendingWrites",
    "tags": [
    ],
    "config": {
      "numClients": 1,
      "useEagerGCForMemory": false
    },
    "steps": [
      {
        "userListen": {
          "query": {
            "filters": [
            ],
            "limit": 2,
            "limitType": "LimitToFirst",
            "orderBys": [
            ],
            "path": "collection"
          },
          "targetId": 2
        },
        "expectedState": {
          "activeTargets": {
            "2": {
              "queries": [
                {
                  "filters": [
                  ],
                  "limit": 2,
                  "limitType": "LimitToFirst",
                  "orderBys": [
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": ""
            }
          }
        }
      },
      {
        "watchAck": [
          2
        ]
      },
      {
        "watchEntity": {
          "docs": [
            {
              "createTime": 0,
              "key": "collection/a",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "key": "a"
              },
              "version": 1000
            },
            {
              "createTime": 0,
              "key": "collection/b",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "key": "b"
              },
              "version": 1000
            }
          ],
          "targets": [
            2
          ]
        }
      },
      {
        "watchCurrent": [
          [
            2
          ],
          "resume-token-1000"
        ]
      },
      {
        "watchSnapshot": {
          "targetIds": [
          ],
          "version": 1000
        },
        "expectedSnapshotEvents": [
          {
            "added": [
              {
                "createTime": 0,
                "key": "collection/a",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "a"
                },
                "version": 1000
              },
              {
                "createTime": 0,
                "key": "collection/b",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "b"
                },
                "version": 1000
              }
            ],
            "errorCode": 0,
            "fromCache": false,
            "hasPendingWrites": false,
            "query": {
              "filters": [
              ],
              "limit": 2,
              "limitType": "LimitToFirst",
              "orderBys": [
              ],
              "path": "collection"
            }
          }
        ]
      },
      {
        "userUnlisten": [
          2,
          {
            "filters": [
            ],
            "limit": 2,
            "limitType": "LimitToFirst",
            "orderBys": [
            ],
            "path": "collection"
          }
        ],
        "expectedState": {
          "activeTargets": {
          }
        }
      },
      {
        "userSet": [
          "collection/c",
          {
            "key": "c"
          }
        ]
      },
      {
        "userListen": {
          "query": {
            "filters": [
            ],
            "limit": 2,
            "limitType": "LimitToFirst",
            "orderBys": [
            ],
            "path": "collection"
          },
          "targetId": 2
        },
        "expectedSnapshotEvents": [
          {
            "added": [
              {
                "createTime": 0,
                "key": "collection/a",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "a"
                },
                "version": 1000
              },
              {
                "createTime": 0,
                "key": "collection/b",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "b"
                },
                "version": 1000
              }
            ],
            "errorCode": 0,
            "fromCache": true,
            "hasPendingWrites": false,
            "query": {
              "filters": [
              ],
              "limit": 2,
              "limitType": "LimitToFirst",
              "orderBys": [
              ],
              "path": "collection"
            }
          }
        ],
        "expectedState": {
          "activeTargets": {
            "2": {
              "queries": [
                {
                  "filters": [
                  ],
                  "limit": 2,
                  "limitType": "LimitToFirst",
                  "orderBys": [
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": "resume-token-1000"
            }
          }
        }
      }
    ]
  },
  "Initial snapshots for limit queries are re-filled from cache (with latency-compensated edit)": {
    "describeName": "Limits:",
    "itName": "Initial snapshots for limit queries are re-filled from cache (with latency-compensated edit)",
    "tags": [
    ],
    "config": {
      "numClients": 1,
      "useEagerGCForMemory": false
    },
    "steps": [
      {
        "userListen": {
          "query": {
            "filters": [
            ],
            "orderBys": [
            ],
            "path": "collection"
          },
          "targetId": 2
        },
        "expectedState": {
          "activeTargets": {
            "2": {
              "queries": [
                {
                  "filters": [
                  ],
                  "orderBys": [
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": ""
            }
          }
        }
      },
      {
        "watchAck": [
          2
        ]
      },
      {
        "watchEntity": {
          "docs": [
            {
              "createTime": 0,
              "key": "collection/a",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "pos": 1
              },
              "version": 1001
            },
            {
              "createTime": 0,
              "key": "collection/b",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "pos": 2
              },
              "version": 1002
            },
            {
              "createTime": 0,
              "key": "collection/c",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "pos": 3
              },
              "version": 1003
            }
          ],
          "targets": [
            2
          ]
        }
      },
      {
        "watchCurrent": [
          [
            2
          ],
          "resume-token-1003"
        ]
      },
      {
        "watchSnapshot": {
          "targetIds": [
          ],
          "version": 1003
        },
        "expectedSnapshotEvents": [
          {
            "added": [
              {
                "createTime": 0,
                "key": "collection/a",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "pos": 1
                },
                "version": 1001
              },
              {
                "createTime": 0,
                "key": "collection/b",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "pos": 2
                },
                "version": 1002
              },
              {
                "createTime": 0,
                "key": "collection/c",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "pos": 3
                },
                "version": 1003
              }
            ],
            "errorCode": 0,
            "fromCache": false,
            "hasPendingWrites": false,
            "query": {
              "filters": [
              ],
              "orderBys": [
              ],
              "path": "collection"
            }
          }
        ]
      },
      {
        "userUnlisten": [
          2,
          {
            "filters": [
            ],
            "orderBys": [
            ],
            "path": "collection"
          }
        ],
        "expectedState": {
          "activeTargets": {
          }
        }
      },
      {
        "watchRemove": {
          "targetIds": [
            2
          ]
        }
      },
      {
        "userListen": {
          "query": {
            "filters": [
            ],
            "limit": 2,
            "limitType": "LimitToFirst",
            "orderBys": [
              [
                "pos",
                "asc"
              ]
            ],
            "path": "collection"
          },
          "targetId": 4
        },
        "expectedSnapshotEvents": [
          {
            "added": [
              {
                "createTime": 0,
                "key": "collection/a",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "pos": 1
                },
                "version": 1001
              },
              {
                "createTime": 0,
                "key": "collection/b",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "pos": 2
                },
                "version": 1002
              }
            ],
            "errorCode": 0,
            "fromCache": true,
            "hasPendingWrites": false,
            "query": {
              "filters": [
              ],
              "limit": 2,
              "limitType": "LimitToFirst",
              "orderBys": [
                [
                  "pos",
                  "asc"
                ]
              ],
              "path": "collection"
            }
          }
        ],
        "expectedState": {
          "activeTargets": {
            "4": {
              "queries": [
                {
                  "filters": [
                  ],
                  "limit": 2,
                  "limitType": "LimitToFirst",
                  "orderBys": [
                    [
                      "pos",
                      "asc"
                    ]
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": ""
            }
          }
        }
      },
      {
        "watchAck": [
          4
        ]
      },
      {
        "watchEntity": {
          "docs": [
            {
              "createTime": 0,
              "key": "collection/a",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "pos": 1
              },
              "version": 1001
            },
            {
              "createTime": 0,
              "key": "collection/b",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "pos": 2
              },
              "version": 1002
            }
          ],
          "targets": [
            4
          ]
        }
      },
      {
        "watchCurrent": [
          [
            4
          ],
          "resume-token-1004"
        ]
      },
      {
        "watchSnapshot": {
          "targetIds": [
          ],
          "version": 1004
        },
        "expectedSnapshotEvents": [
          {
            "errorCode": 0,
            "fromCache": false,
            "hasPendingWrites": false,
            "query": {
              "filters": [
              ],
              "limit": 2,
              "limitType": "LimitToFirst",
              "orderBys": [
                [
                  "pos",
                  "asc"
                ]
              ],
              "path": "collection"
            }
          }
        ]
      },
      {
        "userUnlisten": [
          4,
          {
            "filters": [
            ],
            "limit": 2,
            "limitType": "LimitToFirst",
            "orderBys": [
              [
                "pos",
                "asc"
              ]
            ],
            "path": "collection"
          }
        ],
        "expectedState": {
          "activeTargets": {
          }
        }
      },
      {
        "watchRemove": {
          "targetIds": [
            4
          ]
        }
      },
      {
        "userSet": [
          "collection/a",
          {
            "pos": 4
          }
        ]
      },
      {
        "userListen": {
          "query": {
            "filters": [
            ],
            "limit": 2,
            "limitType": "LimitToFirst",
            "orderBys": [
              [
                "pos",
                "asc"
              ]
            ],
            "path": "collection"
          },
          "targetId": 4
        },
        "expectedSnapshotEvents": [
          {
            "added": [
              {
                "createTime": 0,
                "key": "collection/b",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "pos": 2
                },
                "version": 1002
              },
              {
                "createTime": 0,
                "key": "collection/c",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "pos": 3
                },
                "version": 1003
              }
            ],
            "errorCode": 0,
            "fromCache": true,
            "hasPendingWrites": false,
            "query": {
              "filters": [
              ],
              "limit": 2,
              "limitType": "LimitToFirst",
              "orderBys": [
                [
                  "pos",
                  "asc"
                ]
              ],
              "path": "collection"
            }
          }
        ],
        "expectedState": {
          "activeTargets": {
            "4": {
              "queries": [
                {
                  "filters": [
                  ],
                  "limit": 2,
                  "limitType": "LimitToFirst",
                  "orderBys": [
                    [
                      "pos",
                      "asc"
                    ]
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": "resume-token-1004"
            }
          }
        }
      }
    ]
  },
  "Initial snapshots for limit queries are re-filled from cache (with removal)": {
    "describeName": "Limits:",
    "itName": "Initial snapshots for limit queries are re-filled from cache (with removal)",
    "tags": [
    ],
    "config": {
      "numClients": 1,
      "useEagerGCForMemory": false
    },
    "steps": [
      {
        "userListen": {
          "query": {
            "filters": [
              [
                "matches",
                "==",
                true
              ]
            ],
            "orderBys": [
            ],
            "path": "collection"
          },
          "targetId": 2
        },
        "expectedState": {
          "activeTargets": {
            "2": {
              "queries": [
                {
                  "filters": [
                    [
                      "matches",
                      "==",
                      true
                    ]
                  ],
                  "orderBys": [
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": ""
            }
          }
        }
      },
      {
        "watchAck": [
          2
        ]
      },
      {
        "watchEntity": {
          "docs": [
            {
              "createTime": 0,
              "key": "collection/a",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "matches": true
              },
              "version": 1001
            },
            {
              "createTime": 0,
              "key": "collection/b",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "matches": true
              },
              "version": 1002
            },
            {
              "createTime": 0,
              "key": "collection/c",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "matches": true
              },
              "version": 1003
            }
          ],
          "targets": [
            2
          ]
        }
      },
      {
        "watchCurrent": [
          [
            2
          ],
          "resume-token-1003"
        ]
      },
      {
        "watchSnapshot": {
          "targetIds": [
          ],
          "version": 1003
        },
        "expectedSnapshotEvents": [
          {
            "added": [
              {
                "createTime": 0,
                "key": "collection/a",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "matches": true
                },
                "version": 1001
              },
              {
                "createTime": 0,
                "key": "collection/b",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "matches": true
                },
                "version": 1002
              },
              {
                "createTime": 0,
                "key": "collection/c",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "matches": true
                },
                "version": 1003
              }
            ],
            "errorCode": 0,
            "fromCache": false,
            "hasPendingWrites": false,
            "query": {
              "filters": [
                [
                  "matches",
                  "==",
                  true
                ]
              ],
              "orderBys": [
              ],
              "path": "collection"
            }
          }
        ]
      },
      {
        "userUnlisten": [
          2,
          {
            "filters": [
              [
                "matches",
                "==",
                true
              ]
            ],
            "orderBys": [
            ],
            "path": "collection"
          }
        ],
        "expectedState": {
          "activeTargets": {
          }
        }
      },
      {
        "userListen": {
          "query": {
            "filters": [
              [
                "matches",
                "==",
                true
              ]
            ],
            "limit": 2,
            "limitType": "LimitToFirst",
            "orderBys": [
            ],
            "path": "collection"
          },
          "targetId": 4
        },
        "expectedSnapshotEvents": [
          {
            "added": [
              {
                "createTime": 0,
                "key": "collection/a",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "matches": true
                },
                "version": 1001
              },
              {
                "createTime": 0,
                "key": "collection/b",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "matches": true
                },
                "version": 1002
              }
            ],
            "errorCode": 0,
            "fromCache": true,
            "hasPendingWrites": false,
            "query": {
              "filters": [
                [
                  "matches",
                  "==",
                  true
                ]
              ],
              "limit": 2,
              "limitType": "LimitToFirst",
              "orderBys": [
              ],
              "path": "collection"
            }
          }
        ],
        "expectedState": {
          "activeTargets": {
            "4": {
              "queries": [
                {
                  "filters": [
                    [
                      "matches",
                      "==",
                      true
                    ]
                  ],
                  "limit": 2,
                  "limitType": "LimitToFirst",
                  "orderBys": [
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": ""
            }
          }
        }
      },
      {
        "watchAck": [
          4
        ]
      },
      {
        "watchEntity": {
          "docs": [
            {
              "createTime": 0,
              "key": "collection/a",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "matches": true
              },
              "version": 1001
            },
            {
              "createTime": 0,
              "key": "collection/b",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "matches": true
              },
              "version": 1002
            }
          ],
          "targets": [
            4
          ]
        }
      },
      {
        "watchCurrent": [
          [
            4
          ],
          "resume-token-1004"
        ]
      },
      {
        "watchSnapshot": {
          "targetIds": [
          ],
          "version": 1004
        },
        "expectedSnapshotEvents": [
          {
            "errorCode": 0,
            "fromCache": false,
            "hasPendingWrites": false,
            "query": {
              "filters": [
                [
                  "matches",
                  "==",
                  true
                ]
              ],
              "limit": 2,
              "limitType": "LimitToFirst",
              "orderBys": [
              ],
              "path": "collection"
            }
          }
        ]
      },
      {
        "userUnlisten": [
          4,
          {
            "filters": [
              [
                "matches",
                "==",
                true
              ]
            ],
            "limit": 2,
            "limitType": "LimitToFirst",
            "orderBys": [
            ],
            "path": "collection"
          }
        ],
        "expectedState": {
          "activeTargets": {
          }
        }
      },
      {
        "watchRemove": {
          "targetIds": [
            4
          ]
        }
      },
      {
        "userSet": [
          "collection/a",
          {
            "matches": false
          }
        ]
      },
      {
        "userListen": {
          "query": {
            "filters": [
              [
                "matches",
                "==",
                true
              ]
            ],
            "limit": 2,
            "limitType": "LimitToFirst",
            "orderBys": [
            ],
            "path": "collection"
          },
          "targetId": 4
        },
        "expectedSnapshotEvents": [
          {
            "added": [
              {
                "createTime": 0,
                "key": "collection/b",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "matches": true
                },
                "version": 1002
              },
              {
                "createTime": 0,
                "key": "collection/c",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "matches": true
                },
                "version": 1003
              }
            ],
            "errorCode": 0,
            "fromCache": true,
            "hasPendingWrites": false,
            "query": {
              "filters": [
                [
                  "matches",
                  "==",
                  true
                ]
              ],
              "limit": 2,
              "limitType": "LimitToFirst",
              "orderBys": [
              ],
              "path": "collection"
            }
          }
        ],
        "expectedState": {
          "activeTargets": {
            "4": {
              "queries": [
                {
                  "filters": [
                    [
                      "matches",
                      "==",
                      true
                    ]
                  ],
                  "limit": 2,
                  "limitType": "LimitToFirst",
                  "orderBys": [
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": "resume-token-1004"
            }
          }
        }
      }
    ]
  },
  "Initial snapshots for limit queries are re-filled from cache (with update from backend)": {
    "describeName": "Limits:",
    "itName": "Initial snapshots for limit queries are re-filled from cache (with update from backend)",
    "tags": [
    ],
    "config": {
      "numClients": 1,
      "useEagerGCForMemory": false
    },
    "steps": [
      {
        "userListen": {
          "query": {
            "filters": [
            ],
            "orderBys": [
            ],
            "path": "collection"
          },
          "targetId": 2
        },
        "expectedState": {
          "activeTargets": {
            "2": {
              "queries": [
                {
                  "filters": [
                  ],
                  "orderBys": [
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": ""
            }
          }
        }
      },
      {
        "watchAck": [
          2
        ]
      },
      {
        "watchEntity": {
          "docs": [
            {
              "createTime": 0,
              "key": "collection/a",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "pos": 1
              },
              "version": 1001
            },
            {
              "createTime": 0,
              "key": "collection/b",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "pos": 2
              },
              "version": 1002
            },
            {
              "createTime": 0,
              "key": "collection/c",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "pos": 3
              },
              "version": 1003
            }
          ],
          "targets": [
            2
          ]
        }
      },
      {
        "watchCurrent": [
          [
            2
          ],
          "resume-token-1003"
        ]
      },
      {
        "watchSnapshot": {
          "targetIds": [
          ],
          "version": 1003
        },
        "expectedSnapshotEvents": [
          {
            "added": [
              {
                "createTime": 0,
                "key": "collection/a",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "pos": 1
                },
                "version": 1001
              },
              {
                "createTime": 0,
                "key": "collection/b",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "pos": 2
                },
                "version": 1002
              },
              {
                "createTime": 0,
                "key": "collection/c",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "pos": 3
                },
                "version": 1003
              }
            ],
            "errorCode": 0,
            "fromCache": false,
            "hasPendingWrites": false,
            "query": {
              "filters": [
              ],
              "orderBys": [
              ],
              "path": "collection"
            }
          }
        ]
      },
      {
        "userUnlisten": [
          2,
          {
            "filters": [
            ],
            "orderBys": [
            ],
            "path": "collection"
          }
        ],
        "expectedState": {
          "activeTargets": {
          }
        }
      },
      {
        "watchRemove": {
          "targetIds": [
            2
          ]
        }
      },
      {
        "userListen": {
          "query": {
            "filters": [
            ],
            "limit": 2,
            "limitType": "LimitToFirst",
            "orderBys": [
              [
                "pos",
                "asc"
              ]
            ],
            "path": "collection"
          },
          "targetId": 4
        },
        "expectedSnapshotEvents": [
          {
            "added": [
              {
                "createTime": 0,
                "key": "collection/a",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "pos": 1
                },
                "version": 1001
              },
              {
                "createTime": 0,
                "key": "collection/b",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "pos": 2
                },
                "version": 1002
              }
            ],
            "errorCode": 0,
            "fromCache": true,
            "hasPendingWrites": false,
            "query": {
              "filters": [
              ],
              "limit": 2,
              "limitType": "LimitToFirst",
              "orderBys": [
                [
                  "pos",
                  "asc"
                ]
              ],
              "path": "collection"
            }
          }
        ],
        "expectedState": {
          "activeTargets": {
            "4": {
              "queries": [
                {
                  "filters": [
                  ],
                  "limit": 2,
                  "limitType": "LimitToFirst",
                  "orderBys": [
                    [
                      "pos",
                      "asc"
                    ]
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": ""
            }
          }
        }
      },
      {
        "watchAck": [
          4
        ]
      },
      {
        "watchEntity": {
          "docs": [
            {
              "createTime": 0,
              "key": "collection/a",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "pos": 1
              },
              "version": 1001
            },
            {
              "createTime": 0,
              "key": "collection/b",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "pos": 2
              },
              "version": 1002
            }
          ],
          "targets": [
            4
          ]
        }
      },
      {
        "watchCurrent": [
          [
            4
          ],
          "resume-token-1004"
        ]
      },
      {
        "watchSnapshot": {
          "targetIds": [
          ],
          "version": 1004
        },
        "expectedSnapshotEvents": [
          {
            "errorCode": 0,
            "fromCache": false,
            "hasPendingWrites": false,
            "query": {
              "filters": [
              ],
              "limit": 2,
              "limitType": "LimitToFirst",
              "orderBys": [
                [
                  "pos",
                  "asc"
                ]
              ],
              "path": "collection"
            }
          }
        ]
      },
      {
        "userUnlisten": [
          4,
          {
            "filters": [
            ],
            "limit": 2,
            "limitType": "LimitToFirst",
            "orderBys": [
              [
                "pos",
                "asc"
              ]
            ],
            "path": "collection"
          }
        ],
        "expectedState": {
          "activeTargets": {
          }
        }
      },
      {
        "watchRemove": {
          "targetIds": [
            4
          ]
        }
      },
      {
        "userListen": {
          "query": {
            "filters": [
            ],
            "orderBys": [
            ],
            "path": "collection"
          },
          "targetId": 2
        },
        "expectedSnapshotEvents": [
          {
            "added": [
              {
                "createTime": 0,
                "key": "collection/a",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "pos": 1
                },
                "version": 1001
              },
              {
                "createTime": 0,
                "key": "collection/b",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "pos": 2
                },
                "version": 1002
              },
              {
                "createTime": 0,
                "key": "collection/c",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "pos": 3
                },
                "version": 1003
              }
            ],
            "errorCode": 0,
            "fromCache": true,
            "hasPendingWrites": false,
            "query": {
              "filters": [
              ],
              "orderBys": [
              ],
              "path": "collection"
            }
          }
        ],
        "expectedState": {
          "activeTargets": {
            "2": {
              "queries": [
                {
                  "filters": [
                  ],
                  "orderBys": [
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": "resume-token-1003"
            }
          }
        }
      },
      {
        "watchAck": [
          2
        ]
      },
      {
        "watchEntity": {
          "docs": [
            {
              "createTime": 0,
              "key": "collection/a",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "pos": 4
              },
              "version": 1005
            }
          ],
          "targets": [
            2
          ]
        }
      },
      {
        "watchCurrent": [
          [
            2
          ],
          "resume-token-1005"
        ]
      },
      {
        "watchSnapshot": {
          "targetIds": [
          ],
          "version": 1005
        },
        "expectedSnapshotEvents": [
          {
            "errorCode": 0,
            "fromCache": false,
            "hasPendingWrites": false,
            "modified": [
              {
                "createTime": 0,
                "key": "collection/a",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "pos": 4
                },
                "version": 1005
              }
            ],
            "query": {
              "filters": [
              ],
              "orderBys": [
              ],
              "path": "collection"
            }
          }
        ]
      },
      {
        "userListen": {
          "query": {
            "filters": [
            ],
            "limit": 2,
            "limitType": "LimitToFirst",
            "orderBys": [
              [
                "pos",
                "asc"
              ]
            ],
            "path": "collection"
          },
          "targetId": 4
        },
        "expectedSnapshotEvents": [
          {
            "added": [
              {
                "createTime": 0,
                "key": "collection/b",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "pos": 2
                },
                "version": 1002
              },
              {
                "createTime": 0,
                "key": "collection/c",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "pos": 3
                },
                "version": 1003
              }
            ],
            "errorCode": 0,
            "fromCache": true,
            "hasPendingWrites": false,
            "query": {
              "filters": [
              ],
              "limit": 2,
              "limitType": "LimitToFirst",
              "orderBys": [
                [
                  "pos",
                  "asc"
                ]
              ],
              "path": "collection"
            }
          }
        ],
        "expectedState": {
          "activeTargets": {
            "2": {
              "queries": [
                {
                  "filters": [
                  ],
                  "orderBys": [
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": "resume-token-1003"
            },
            "4": {
              "queries": [
                {
                  "filters": [
                  ],
                  "limit": 2,
                  "limitType": "LimitToFirst",
                  "orderBys": [
                    [
                      "pos",
                      "asc"
                    ]
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": "resume-token-1004"
            }
          }
        }
      }
    ]
  },
  "Limit query includes write from secondary client ": {
    "describeName": "Limits:",
    "itName": "Limit query includes write from secondary client ",
    "tags": [
      "multi-client"
    ],
    "config": {
      "numClients": 3,
      "useEagerGCForMemory": false
    },
    "steps": [
      {
        "clientIndex": 0,
        "drainQueue": true
      },
      {
        "applyClientState": {
          "visibility": "visible"
        },
        "clientIndex": 0
      },
      {
        "clientIndex": 1,
        "drainQueue": true
      },
      {
        "clientIndex": 1,
        "userListen": {
          "query": {
            "filters": [
            ],
            "limit": 2,
            "limitType": "LimitToFirst",
            "orderBys": [
            ],
            "path": "collection"
          },
          "targetId": 2
        },
        "expectedState": {
          "activeTargets": {
            "2": {
              "queries": [
                {
                  "filters": [
                  ],
                  "limit": 2,
                  "limitType": "LimitToFirst",
                  "orderBys": [
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": ""
            }
          }
        }
      },
      {
        "clientIndex": 0,
        "drainQueue": true,
        "expectedState": {
          "activeTargets": {
            "2": {
              "queries": [
                {
                  "filters": [
                  ],
                  "limit": 2,
                  "limitType": "LimitToFirst",
                  "orderBys": [
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": ""
            }
          }
        }
      },
      {
        "clientIndex": 0,
        "watchAck": [
          2
        ]
      },
      {
        "clientIndex": 0,
        "watchEntity": {
          "docs": [
            {
              "createTime": 0,
              "key": "collection/b",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "key": "b"
              },
              "version": 1001
            },
            {
              "createTime": 0,
              "key": "collection/c",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "key": "c"
              },
              "version": 1002
            }
          ],
          "targets": [
            2
          ]
        }
      },
      {
        "clientIndex": 0,
        "watchCurrent": [
          [
            2
          ],
          "resume-token-1002"
        ]
      },
      {
        "clientIndex": 0,
        "watchSnapshot": {
          "targetIds": [
          ],
          "version": 1002
        }
      },
      {
        "clientIndex": 1,
        "drainQueue": true,
        "expectedSnapshotEvents": [
          {
            "added": [
              {
                "createTime": 0,
                "key": "collection/b",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "b"
                },
                "version": 1001
              },
              {
                "createTime": 0,
                "key": "collection/c",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "c"
                },
                "version": 1002
              }
            ],
            "errorCode": 0,
            "fromCache": false,
            "hasPendingWrites": false,
            "query": {
              "filters": [
              ],
              "limit": 2,
              "limitType": "LimitToFirst",
              "orderBys": [
              ],
              "path": "collection"
            }
          }
        ]
      },
      {
        "clientIndex": 2,
        "drainQueue": true
      },
      {
        "clientIndex": 2,
        "userSet": [
          "collection/a",
          {
            "key": "a"
          }
        ]
      },
      {
        "clientIndex": 1,
        "drainQueue": true,
        "expectedSnapshotEvents": [
          {
            "added": [
              {
                "createTime": 0,
                "key": "collection/a",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": true
                },
                "value": {
                  "key": "a"
                },
                "version": 0
              }
            ],
            "errorCode": 0,
            "fromCache": false,
            "hasPendingWrites": true,
            "query": {
              "filters": [
              ],
              "limit": 2,
              "limitType": "LimitToFirst",
              "orderBys": [
              ],
              "path": "collection"
            },
            "removed": [
              {
                "createTime": 0,
                "key": "collection/c",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "c"
                },
                "version": 1002
              }
            ]
          }
        ]
      },
      {
        "clientIndex": 0,
        "drainQueue": true
      },
      {
        "clientIndex": 0,
        "writeAck": {
          "version": 1003
        }
      },
      {
        "clientIndex": 0,
        "watchEntity": {
          "docs": [
            {
              "createTime": 0,
              "key": "collection/a",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "key": "a"
              },
              "version": 1003
            }
          ],
          "targets": [
            2
          ]
        }
      },
      {
        "clientIndex": 0,
        "watchEntity": {
          "docs": [
            {
              "createTime": 0,
              "key": "collection/c",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "key": "c"
              },
              "version": 1002
            }
          ],
          "removedTargets": [
            2
          ]
        }
      },
      {
        "clientIndex": 0,
        "watchSnapshot": {
          "targetIds": [
          ],
          "version": 1003
        }
      },
      {
        "clientIndex": 1,
        "drainQueue": true,
        "expectedSnapshotEvents": [
          {
            "errorCode": 0,
            "fromCache": false,
            "hasPendingWrites": false,
            "metadata": [
              {
                "createTime": 0,
                "key": "collection/a",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "a"
                },
                "version": 1003
              }
            ],
            "query": {
              "filters": [
              ],
              "limit": 2,
              "limitType": "LimitToFirst",
              "orderBys": [
              ],
              "path": "collection"
            }
          }
        ]
      },
      {
        "clientIndex": 2,
        "drainQueue": true,
        "expectedState": {
          "userCallbacks": {
            "acknowledgedDocs": [
              "collection/a"
            ],
            "rejectedDocs": [
            ]
          }
        }
      }
    ]
  },
  "Limit query is refilled by primary client": {
    "describeName": "Limits:",
    "itName": "Limit query is refilled by primary client",
    "tags": [
      "multi-client"
    ],
    "config": {
      "numClients": 2,
      "useEagerGCForMemory": false
    },
    "steps": [
      {
        "clientIndex": 0,
        "drainQueue": true
      },
      {
        "applyClientState": {
          "visibility": "visible"
        },
        "clientIndex": 0
      },
      {
        "clientIndex": 1,
        "drainQueue": true
      },
      {
        "clientIndex": 1,
        "userListen": {
          "query": {
            "filters": [
            ],
            "limit": 2,
            "limitType": "LimitToFirst",
            "orderBys": [
            ],
            "path": "collection"
          },
          "targetId": 2
        },
        "expectedState": {
          "activeTargets": {
            "2": {
              "queries": [
                {
                  "filters": [
                  ],
                  "limit": 2,
                  "limitType": "LimitToFirst",
                  "orderBys": [
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": ""
            }
          }
        }
      },
      {
        "clientIndex": 0,
        "drainQueue": true,
        "expectedState": {
          "activeTargets": {
            "2": {
              "queries": [
                {
                  "filters": [
                  ],
                  "limit": 2,
                  "limitType": "LimitToFirst",
                  "orderBys": [
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": ""
            }
          }
        }
      },
      {
        "clientIndex": 0,
        "watchAck": [
          2
        ]
      },
      {
        "clientIndex": 0,
        "watchEntity": {
          "docs": [
            {
              "createTime": 0,
              "key": "collection/a",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "key": "a"
              },
              "version": 1000
            },
            {
              "createTime": 0,
              "key": "collection/c",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "key": "c"
              },
              "version": 1001
            }
          ],
          "targets": [
            2
          ]
        }
      },
      {
        "clientIndex": 0,
        "watchCurrent": [
          [
            2
          ],
          "resume-token-1001"
        ]
      },
      {
        "clientIndex": 0,
        "watchSnapshot": {
          "targetIds": [
          ],
          "version": 1001
        }
      },
      {
        "clientIndex": 1,
        "drainQueue": true,
        "expectedSnapshotEvents": [
          {
            "added": [
              {
                "createTime": 0,
                "key": "collection/a",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "a"
                },
                "version": 1000
              },
              {
                "createTime": 0,
                "key": "collection/c",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "c"
                },
                "version": 1001
              }
            ],
            "errorCode": 0,
            "fromCache": false,
            "hasPendingWrites": false,
            "query": {
              "filters": [
              ],
              "limit": 2,
              "limitType": "LimitToFirst",
              "orderBys": [
              ],
              "path": "collection"
            }
          }
        ]
      },
      {
        "clientIndex": 0,
        "drainQueue": true
      },
      {
        "clientIndex": 0,
        "watchEntity": {
          "docs": [
            {
              "createTime": 0,
              "key": "collection/b",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "key": "b"
              },
              "version": 1002
            }
          ],
          "targets": [
            2
          ]
        }
      },
      {
        "clientIndex": 0,
        "watchEntity": {
          "docs": [
            {
              "createTime": 0,
              "key": "collection/c",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "key": "c"
              },
              "version": 1001
            }
          ],
          "removedTargets": [
            2
          ]
        }
      },
      {
        "clientIndex": 0,
        "watchSnapshot": {
          "targetIds": [
          ],
          "version": 1002
        }
      },
      {
        "clientIndex": 1,
        "drainQueue": true,
        "expectedSnapshotEvents": [
          {
            "added": [
              {
                "createTime": 0,
                "key": "collection/b",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "b"
                },
                "version": 1002
              }
            ],
            "errorCode": 0,
            "fromCache": false,
            "hasPendingWrites": false,
            "query": {
              "filters": [
              ],
              "limit": 2,
              "limitType": "LimitToFirst",
              "orderBys": [
              ],
              "path": "collection"
            },
            "removed": [
              {
                "createTime": 0,
                "key": "collection/c",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "c"
                },
                "version": 1001
              }
            ]
          }
        ]
      }
    ]
  },
  "Limits are re-filled from cache": {
    "describeName": "Limits:",
    "itName": "Limits are re-filled from cache",
    "tags": [
    ],
    "config": {
      "numClients": 1,
      "useEagerGCForMemory": false
    },
    "steps": [
      {
        "userListen": {
          "query": {
            "filters": [
              [
                "matches",
                "==",
                true
              ]
            ],
            "orderBys": [
            ],
            "path": "collection"
          },
          "targetId": 2
        },
        "expectedState": {
          "activeTargets": {
            "2": {
              "queries": [
                {
                  "filters": [
                    [
                      "matches",
                      "==",
                      true
                    ]
                  ],
                  "orderBys": [
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": ""
            }
          }
        }
      },
      {
        "watchAck": [
          2
        ]
      },
      {
        "watchEntity": {
          "docs": [
            {
              "createTime": 0,
              "key": "collection/a",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "matches": true
              },
              "version": 1001
            },
            {
              "createTime": 0,
              "key": "collection/b",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "matches": true
              },
              "version": 1002
            },
            {
              "createTime": 0,
              "key": "collection/c",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "matches": true
              },
              "version": 1000
            }
          ],
          "targets": [
            2
          ]
        }
      },
      {
        "watchCurrent": [
          [
            2
          ],
          "resume-token-1002"
        ]
      },
      {
        "watchSnapshot": {
          "targetIds": [
          ],
          "version": 1002
        },
        "expectedSnapshotEvents": [
          {
            "added": [
              {
                "createTime": 0,
                "key": "collection/a",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "matches": true
                },
                "version": 1001
              },
              {
                "createTime": 0,
                "key": "collection/b",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "matches": true
                },
                "version": 1002
              },
              {
                "createTime": 0,
                "key": "collection/c",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "matches": true
                },
                "version": 1000
              }
            ],
            "errorCode": 0,
            "fromCache": false,
            "hasPendingWrites": false,
            "query": {
              "filters": [
                [
                  "matches",
                  "==",
                  true
                ]
              ],
              "orderBys": [
              ],
              "path": "collection"
            }
          }
        ]
      },
      {
        "userUnlisten": [
          2,
          {
            "filters": [
              [
                "matches",
                "==",
                true
              ]
            ],
            "orderBys": [
            ],
            "path": "collection"
          }
        ],
        "expectedState": {
          "activeTargets": {
          }
        }
      },
      {
        "userListen": {
          "query": {
            "filters": [
              [
                "matches",
                "==",
                true
              ]
            ],
            "limit": 2,
            "limitType": "LimitToFirst",
            "orderBys": [
            ],
            "path": "collection"
          },
          "targetId": 4
        },
        "expectedSnapshotEvents": [
          {
            "added": [
              {
                "createTime": 0,
                "key": "collection/a",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "matches": true
                },
                "version": 1001
              },
              {
                "createTime": 0,
                "key": "collection/b",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "matches": true
                },
                "version": 1002
              }
            ],
            "errorCode": 0,
            "fromCache": true,
            "hasPendingWrites": false,
            "query": {
              "filters": [
                [
                  "matches",
                  "==",
                  true
                ]
              ],
              "limit": 2,
              "limitType": "LimitToFirst",
              "orderBys": [
              ],
              "path": "collection"
            }
          }
        ],
        "expectedState": {
          "activeTargets": {
            "4": {
              "queries": [
                {
                  "filters": [
                    [
                      "matches",
                      "==",
                      true
                    ]
                  ],
                  "limit": 2,
                  "limitType": "LimitToFirst",
                  "orderBys": [
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": ""
            }
          }
        }
      },
      {
        "userSet": [
          "collection/a",
          {
            "matches": false
          }
        ],
        "expectedSnapshotEvents": [
          {
            "added": [
              {
                "createTime": 0,
                "key": "collection/c",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "matches": true
                },
                "version": 1000
              }
            ],
            "errorCode": 0,
            "fromCache": true,
            "hasPendingWrites": false,
            "query": {
              "filters": [
                [
                  "matches",
                  "==",
                  true
                ]
              ],
              "limit": 2,
              "limitType": "LimitToFirst",
              "orderBys": [
              ],
              "path": "collection"
            },
            "removed": [
              {
                "createTime": 0,
                "key": "collection/a",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "matches": true
                },
                "version": 1001
              }
            ]
          }
        ]
      }
    ]
  },
  "Multiple docs in limbo in full limit query": {
    "describeName": "Limits:",
    "itName": "Multiple docs in limbo in full limit query",
    "tags": [
    ],
    "config": {
      "numClients": 1,
      "useEagerGCForMemory": true
    },
    "steps": [
      {
        "userListen": {
          "query": {
            "filters": [
            ],
            "limit": 2,
            "limitType": "LimitToFirst",
            "orderBys": [
            ],
            "path": "collection"
          },
          "targetId": 2
        },
        "expectedState": {
          "activeTargets": {
            "2": {
              "queries": [
                {
                  "filters": [
                  ],
                  "limit": 2,
                  "limitType": "LimitToFirst",
                  "orderBys": [
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": ""
            }
          }
        }
      },
      {
        "watchAck": [
          2
        ]
      },
      {
        "watchEntity": {
          "docs": [
            {
              "createTime": 0,
              "key": "collection/a",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "key": "a"
              },
              "version": 1000
            },
            {
              "createTime": 0,
              "key": "collection/b",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "key": "b"
              },
              "version": 1001
            }
          ],
          "targets": [
            2
          ]
        }
      },
      {
        "watchCurrent": [
          [
            2
          ],
          "resume-token-1001"
        ]
      },
      {
        "watchSnapshot": {
          "targetIds": [
          ],
          "version": 1001
        },
        "expectedSnapshotEvents": [
          {
            "added": [
              {
                "createTime": 0,
                "key": "collection/a",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "a"
                },
                "version": 1000
              },
              {
                "createTime": 0,
                "key": "collection/b",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "b"
                },
                "version": 1001
              }
            ],
            "errorCode": 0,
            "fromCache": false,
            "hasPendingWrites": false,
            "query": {
              "filters": [
              ],
              "limit": 2,
              "limitType": "LimitToFirst",
              "orderBys": [
              ],
              "path": "collection"
            }
          }
        ]
      },
      {
        "userListen": {
          "query": {
            "filters": [
            ],
            "orderBys": [
            ],
            "path": "collection"
          },
          "targetId": 4
        },
        "expectedSnapshotEvents": [
          {
            "added": [
              {
                "createTime": 0,
                "key": "collection/a",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "a"
                },
                "version": 1000
              },
              {
                "createTime": 0,
                "key": "collection/b",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "b"
                },
                "version": 1001
              }
            ],
            "errorCode": 0,
            "fromCache": true,
            "hasPendingWrites": false,
            "query": {
              "filters": [
              ],
              "orderBys": [
              ],
              "path": "collection"
            }
          }
        ],
        "expectedState": {
          "activeTargets": {
            "2": {
              "queries": [
                {
                  "filters": [
                  ],
                  "limit": 2,
                  "limitType": "LimitToFirst",
                  "orderBys": [
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": ""
            },
            "4": {
              "queries": [
                {
                  "filters": [
                  ],
                  "orderBys": [
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": ""
            }
          }
        }
      },
      {
        "watchAck": [
          4
        ]
      },
      {
        "watchEntity": {
          "docs": [
            {
              "createTime": 0,
              "key": "collection/a",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "key": "a"
              },
              "version": 1000
            },
            {
              "createTime": 0,
              "key": "collection/b",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "key": "b"
              },
              "version": 1001
            },
            {
              "createTime": 0,
              "key": "collection/c",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "key": "c"
              },
              "version": 1002
            },
            {
              "createTime": 0,
              "key": "collection/d",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "key": "d"
              },
              "version": 1003
            },
            {
              "createTime": 0,
              "key": "collection/e",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "key": "e"
              },
              "version": 1004
            },
            {
              "createTime": 0,
              "key": "collection/f",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "key": "f"
              },
              "version": 1005
            }
          ],
          "targets": [
            4
          ]
        }
      },
      {
        "watchCurrent": [
          [
            4
          ],
          "resume-token-1005"
        ]
      },
      {
        "watchSnapshot": {
          "targetIds": [
          ],
          "version": 1005
        },
        "expectedSnapshotEvents": [
          {
            "added": [
              {
                "createTime": 0,
                "key": "collection/c",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "c"
                },
                "version": 1002
              },
              {
                "createTime": 0,
                "key": "collection/d",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "d"
                },
                "version": 1003
              },
              {
                "createTime": 0,
                "key": "collection/e",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "e"
                },
                "version": 1004
              },
              {
                "createTime": 0,
                "key": "collection/f",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "f"
                },
                "version": 1005
              }
            ],
            "errorCode": 0,
            "fromCache": false,
            "hasPendingWrites": false,
            "query": {
              "filters": [
              ],
              "orderBys": [
              ],
              "path": "collection"
            }
          }
        ]
      },
      {
        "watchReset": [
          2
        ]
      },
      {
        "watchEntity": {
          "docs": [
            {
              "createTime": 0,
              "key": "collection/e",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "key": "e"
              },
              "version": 1004
            },
            {
              "createTime": 0,
              "key": "collection/f",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "key": "f"
              },
              "version": 1005
            }
          ],
          "targets": [
            2
          ]
        }
      },
      {
        "watchCurrent": [
          [
            2
          ],
          "resume-token-2000"
        ]
      },
      {
        "watchSnapshot": {
          "targetIds": [
          ],
          "version": 2000
        },
        "expectedSnapshotEvents": [
          {
            "errorCode": 0,
            "fromCache": true,
            "hasPendingWrites": false,
            "query": {
              "filters": [
              ],
              "limit": 2,
              "limitType": "LimitToFirst",
              "orderBys": [
              ],
              "path": "collection"
            }
          }
        ],
        "expectedState": {
          "activeLimboDocs": [
            "collection/a",
            "collection/b"
          ],
          "activeTargets": {
            "1": {
              "queries": [
                {
                  "filters": [
                  ],
                  "orderBys": [
                  ],
                  "path": "collection/a"
                }
              ],
              "resumeToken": "",
              "targetPurpose": "TargetPurposeLimboResolution"
            },
            "2": {
              "queries": [
                {
                  "filters": [
                  ],
                  "limit": 2,
                  "limitType": "LimitToFirst",
                  "orderBys": [
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": ""
            },
            "3": {
              "queries": [
                {
                  "filters": [
                  ],
                  "orderBys": [
                  ],
                  "path": "collection/b"
                }
              ],
              "resumeToken": "",
              "targetPurpose": "TargetPurposeLimboResolution"
            },
            "4": {
              "queries": [
                {
                  "filters": [
                  ],
                  "orderBys": [
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": ""
            }
          }
        }
      },
      {
        "watchAck": [
          1
        ]
      },
      {
        "watchCurrent": [
          [
            1
          ],
          "resume-token-2000"
        ]
      },
      {
        "watchSnapshot": {
          "targetIds": [
          ],
          "version": 2000
        },
        "expectedSnapshotEvents": [
          {
            "errorCode": 0,
            "fromCache": false,
            "hasPendingWrites": false,
            "query": {
              "filters": [
              ],
              "orderBys": [
              ],
              "path": "collection"
            },
            "removed": [
              {
                "createTime": 0,
                "key": "collection/a",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "a"
                },
                "version": 1000
              }
            ]
          },
          {
            "added": [
              {
                "createTime": 0,
                "key": "collection/c",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "c"
                },
                "version": 1002
              }
            ],
            "errorCode": 0,
            "fromCache": true,
            "hasPendingWrites": false,
            "query": {
              "filters": [
              ],
              "limit": 2,
              "limitType": "LimitToFirst",
              "orderBys": [
              ],
              "path": "collection"
            },
            "removed": [
              {
                "createTime": 0,
                "key": "collection/a",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "a"
                },
                "version": 1000
              }
            ]
          }
        ],
        "expectedState": {
          "activeLimboDocs": [
            "collection/b",
            "collection/c"
          ],
          "activeTargets": {
            "2": {
              "queries": [
                {
                  "filters": [
                  ],
                  "limit": 2,
                  "limitType": "LimitToFirst",
                  "orderBys": [
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": ""
            },
            "3": {
              "queries": [
                {
                  "filters": [
                  ],
                  "orderBys": [
                  ],
                  "path": "collection/b"
                }
              ],
              "resumeToken": "",
              "targetPurpose": "TargetPurposeLimboResolution"
            },
            "4": {
              "queries": [
                {
                  "filters": [
                  ],
                  "orderBys": [
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": ""
            },
            "5": {
              "queries": [
                {
                  "filters": [
                  ],
                  "orderBys": [
                  ],
                  "path": "collection/c"
                }
              ],
              "resumeToken": "",
              "targetPurpose": "TargetPurposeLimboResolution"
            }
          }
        }
      },
      {
        "watchRemove": {
          "targetIds": [
            1
          ]
        }
      },
      {
        "watchAck": [
          3
        ]
      },
      {
        "watchCurrent": [
          [
            3
          ],
          "resume-token-2001"
        ]
      },
      {
        "watchSnapshot": {
          "targetIds": [
          ],
          "version": 2001
        },
        "expectedSnapshotEvents": [
          {
            "errorCode": 0,
            "fromCache": false,
            "hasPendingWrites": false,
            "query": {
              "filters": [
              ],
              "orderBys": [
              ],
              "path": "collection"
            },
            "removed": [
              {
                "createTime": 0,
                "key": "collection/b",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "b"
                },
                "version": 1001
              }
            ]
          },
          {
            "added": [
              {
                "createTime": 0,
                "key": "collection/d",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "d"
                },
                "version": 1003
              }
            ],
            "errorCode": 0,
            "fromCache": true,
            "hasPendingWrites": false,
            "query": {
              "filters": [
              ],
              "limit": 2,
              "limitType": "LimitToFirst",
              "orderBys": [
              ],
              "path": "collection"
            },
            "removed": [
              {
                "createTime": 0,
                "key": "collection/b",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "b"
                },
                "version": 1001
              }
            ]
          }
        ],
        "expectedState": {
          "activeLimboDocs": [
            "collection/c",
            "collection/d"
          ],
          "activeTargets": {
            "2": {
              "queries": [
                {
                  "filters": [
                  ],
                  "limit": 2,
                  "limitType": "LimitToFirst",
                  "orderBys": [
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": ""
            },
            "4": {
              "queries": [
                {
                  "filters": [
                  ],
                  "orderBys": [
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": ""
            },
            "5": {
              "queries": [
                {
                  "filters": [
                  ],
                  "orderBys": [
                  ],
                  "path": "collection/c"
                }
              ],
              "resumeToken": "",
              "targetPurpose": "TargetPurposeLimboResolution"
            },
            "7": {
              "queries": [
                {
                  "filters": [
                  ],
                  "orderBys": [
                  ],
                  "path": "collection/d"
                }
              ],
              "resumeToken": "",
              "targetPurpose": "TargetPurposeLimboResolution"
            }
          }
        }
      },
      {
        "watchRemove": {
          "targetIds": [
            3
          ]
        }
      },
      {
        "watchAck": [
          5
        ]
      },
      {
        "watchCurrent": [
          [
            5
          ],
          "resume-token-2002"
        ]
      },
      {
        "watchSnapshot": {
          "targetIds": [
          ],
          "version": 2002
        },
        "expectedSnapshotEvents": [
          {
            "errorCode": 0,
            "fromCache": false,
            "hasPendingWrites": false,
            "query": {
              "filters": [
              ],
              "orderBys": [
              ],
              "path": "collection"
            },
            "removed": [
              {
                "createTime": 0,
                "key": "collection/c",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "c"
                },
                "version": 1002
              }
            ]
          },
          {
            "added": [
              {
                "createTime": 0,
                "key": "collection/e",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "e"
                },
                "version": 1004
              }
            ],
            "errorCode": 0,
            "fromCache": true,
            "hasPendingWrites": false,
            "query": {
              "filters": [
              ],
              "limit": 2,
              "limitType": "LimitToFirst",
              "orderBys": [
              ],
              "path": "collection"
            },
            "removed": [
              {
                "createTime": 0,
                "key": "collection/c",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "c"
                },
                "version": 1002
              }
            ]
          }
        ],
        "expectedState": {
          "activeLimboDocs": [
            "collection/d"
          ],
          "activeTargets": {
            "2": {
              "queries": [
                {
                  "filters": [
                  ],
                  "limit": 2,
                  "limitType": "LimitToFirst",
                  "orderBys": [
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": ""
            },
            "4": {
              "queries": [
                {
                  "filters": [
                  ],
                  "orderBys": [
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": ""
            },
            "7": {
              "queries": [
                {
                  "filters": [
                  ],
                  "orderBys": [
                  ],
                  "path": "collection/d"
                }
              ],
              "resumeToken": "",
              "targetPurpose": "TargetPurposeLimboResolution"
            }
          }
        }
      },
      {
        "watchRemove": {
          "targetIds": [
            5
          ]
        }
      },
      {
        "watchAck": [
          7
        ]
      },
      {
        "watchCurrent": [
          [
            7
          ],
          "resume-token-2003"
        ]
      },
      {
        "watchSnapshot": {
          "targetIds": [
          ],
          "version": 2003
        },
        "expectedSnapshotEvents": [
          {
            "errorCode": 0,
            "fromCache": false,
            "hasPendingWrites": false,
            "query": {
              "filters": [
              ],
              "orderBys": [
              ],
              "path": "collection"
            },
            "removed": [
              {
                "createTime": 0,
                "key": "collection/d",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "d"
                },
                "version": 1003
              }
            ]
          },
          {
            "added": [
              {
                "createTime": 0,
                "key": "collection/f",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "f"
                },
                "version": 1005
              }
            ],
            "errorCode": 0,
            "fromCache": false,
            "hasPendingWrites": false,
            "query": {
              "filters": [
              ],
              "limit": 2,
              "limitType": "LimitToFirst",
              "orderBys": [
              ],
              "path": "collection"
            },
            "removed": [
              {
                "createTime": 0,
                "key": "collection/d",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "key": "d"
                },
                "version": 1003
              }
            ]
          }
        ],
        "expectedState": {
          "activeLimboDocs": [
          ],
          "activeTargets": {
            "2": {
              "queries": [
                {
                  "filters": [
                  ],
                  "limit": 2,
                  "limitType": "LimitToFirst",
                  "orderBys": [
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": ""
            },
            "4": {
              "queries": [
                {
                  "filters": [
                  ],
                  "orderBys": [
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": ""
            }
          }
        }
      },
      {
        "watchRemove": {
          "targetIds": [
            7
          ]
        }
      }
    ]
  },
  "Resumed limit queries exclude deleted documents ": {
    "describeName": "Limits:",
    "itName": "Resumed limit queries exclude deleted documents ",
    "tags": [
      "durable-persistence"
    ],
    "config": {
      "numClients": 1,
      "useEagerGCForMemory": false
    },
    "steps": [
      {
        "userListen": {
          "query": {
            "filters": [
            ],
            "limit": 1,
            "limitType": "LimitToFirst",
            "orderBys": [
              [
                "a",
                "asc"
              ]
            ],
            "path": "collection"
          },
          "targetId": 2
        },
        "expectedState": {
          "activeTargets": {
            "2": {
              "queries": [
                {
                  "filters": [
                  ],
                  "limit": 1,
                  "limitType": "LimitToFirst",
                  "orderBys": [
                    [
                      "a",
                      "asc"
                    ]
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": ""
            }
          }
        }
      },
      {
        "watchAck": [
          2
        ]
      },
      {
        "watchEntity": {
          "docs": [
            {
              "createTime": 0,
              "key": "collection/a",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "a": 1
              },
              "version": 1001
            }
          ],
          "targets": [
            2
          ]
        }
      },
      {
        "watchCurrent": [
          [
            2
          ],
          "resume-token-1001"
        ]
      },
      {
        "watchSnapshot": {
          "targetIds": [
          ],
          "version": 1001
        },
        "expectedSnapshotEvents": [
          {
            "added": [
              {
                "createTime": 0,
                "key": "collection/a",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "a": 1
                },
                "version": 1001
              }
            ],
            "errorCode": 0,
            "fromCache": false,
            "hasPendingWrites": false,
            "query": {
              "filters": [
              ],
              "limit": 1,
              "limitType": "LimitToFirst",
              "orderBys": [
                [
                  "a",
                  "asc"
                ]
              ],
              "path": "collection"
            }
          }
        ]
      },
      {
        "userUnlisten": [
          2,
          {
            "filters": [
            ],
            "limit": 1,
            "limitType": "LimitToFirst",
            "orderBys": [
              [
                "a",
                "asc"
              ]
            ],
            "path": "collection"
          }
        ],
        "expectedState": {
          "activeTargets": {
          }
        }
      },
      {
        "watchRemove": {
          "targetIds": [
            2
          ]
        }
      },
      {
        "userListen": {
          "query": {
            "filters": [
            ],
            "orderBys": [
              [
                "a",
                "asc"
              ]
            ],
            "path": "collection"
          },
          "targetId": 4
        },
        "expectedSnapshotEvents": [
          {
            "added": [
              {
                "createTime": 0,
                "key": "collection/a",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "a": 1
                },
                "version": 1001
              }
            ],
            "errorCode": 0,
            "fromCache": true,
            "hasPendingWrites": false,
            "query": {
              "filters": [
              ],
              "orderBys": [
                [
                  "a",
                  "asc"
                ]
              ],
              "path": "collection"
            }
          }
        ],
        "expectedState": {
          "activeTargets": {
            "4": {
              "queries": [
                {
                  "filters": [
                  ],
                  "orderBys": [
                    [
                      "a",
                      "asc"
                    ]
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": ""
            }
          }
        }
      },
      {
        "watchAck": [
          4
        ]
      },
      {
        "watchEntity": {
          "docs": [
            {
              "createTime": 0,
              "key": "collection/a",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "a": 1
              },
              "version": 1001
            },
            {
              "createTime": 0,
              "key": "collection/b",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "a": 2
              },
              "version": 1000
            }
          ],
          "targets": [
            4
          ]
        }
      },
      {
        "watchCurrent": [
          [
            4
          ],
          "resume-token-1002"
        ]
      },
      {
        "watchSnapshot": {
          "targetIds": [
          ],
          "version": 1002
        },
        "expectedSnapshotEvents": [
          {
            "added": [
              {
                "createTime": 0,
                "key": "collection/b",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "a": 2
                },
                "version": 1000
              }
            ],
            "errorCode": 0,
            "fromCache": false,
            "hasPendingWrites": false,
            "query": {
              "filters": [
              ],
              "orderBys": [
                [
                  "a",
                  "asc"
                ]
              ],
              "path": "collection"
            }
          }
        ]
      },
      {
        "watchEntity": {
          "key": "collection/a",
          "removedTargets": [
            4
          ]
        }
      },
      {
        "watchSnapshot": {
          "targetIds": [
          ],
          "version": 1003
        },
        "expectedSnapshotEvents": [
          {
            "errorCode": 0,
            "fromCache": true,
            "hasPendingWrites": false,
            "query": {
              "filters": [
              ],
              "orderBys": [
                [
                  "a",
                  "asc"
                ]
              ],
              "path": "collection"
            }
          }
        ],
        "expectedState": {
          "activeLimboDocs": [
            "collection/a"
          ],
          "activeTargets": {
            "1": {
              "queries": [
                {
                  "filters": [
                  ],
                  "orderBys": [
                  ],
                  "path": "collection/a"
                }
              ],
              "resumeToken": "",
              "targetPurpose": "TargetPurposeLimboResolution"
            },
            "4": {
              "queries": [
                {
                  "filters": [
                  ],
                  "orderBys": [
                    [
                      "a",
                      "asc"
                    ]
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": ""
            }
          }
        }
      },
      {
        "userUnlisten": [
          4,
          {
            "filters": [
            ],
            "orderBys": [
              [
                "a",
                "asc"
              ]
            ],
            "path": "collection"
          }
        ],
        "expectedState": {
          "activeLimboDocs": [
          ],
          "activeTargets": {
          }
        }
      },
      {
        "watchRemove": {
          "targetIds": [
            4
          ]
        }
      },
      {
        "restart": true,
        "expectedState": {
          "activeLimboDocs": [
          ],
          "activeTargets": {
          },
          "enqueuedLimboDocs": [
          ]
        }
      },
      {
        "userListen": {
          "query": {
            "filters": [
            ],
            "limit": 1,
            "limitType": "LimitToFirst",
            "orderBys": [
              [
                "a",
                "asc"
              ]
            ],
            "path": "collection"
          },
          "targetId": 2
        },
        "expectedSnapshotEvents": [
          {
            "added": [
              {
                "createTime": 0,
                "key": "collection/a",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "a": 1
                },
                "version": 1001
              }
            ],
            "errorCode": 0,
            "fromCache": true,
            "hasPendingWrites": false,
            "query": {
              "filters": [
              ],
              "limit": 1,
              "limitType": "LimitToFirst",
              "orderBys": [
                [
                  "a",
                  "asc"
                ]
              ],
              "path": "collection"
            }
          }
        ],
        "expectedState": {
          "activeTargets": {
            "2": {
              "queries": [
                {
                  "filters": [
                  ],
                  "limit": 1,
                  "limitType": "LimitToFirst",
                  "orderBys": [
                    [
                      "a",
                      "asc"
                    ]
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": "resume-token-1001"
            }
          }
        }
      },
      {
        "watchAck": [
          2
        ]
      },
      {
        "watchEntity": {
          "docs": [
            {
              "createTime": 0,
              "key": "collection/b",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "a": 2
              },
              "version": 1000
            }
          ],
          "targets": [
            2
          ]
        }
      },
      {
        "watchFilter": {
          "keys": [
            "collection/b"
          ],
          "targetIds": [
            2
          ]
        }
      },
      {
        "watchCurrent": [
          [
            2
          ],
          "resume-token-1004"
        ]
      },
      {
        "watchSnapshot": {
          "targetIds": [
          ],
          "version": 1004
        },
        "expectedState": {
          "activeTargets": {
            "2": {
              "queries": [
                {
                  "filters": [
                  ],
                  "limit": 1,
                  "limitType": "LimitToFirst",
                  "orderBys": [
                    [
                      "a",
                      "asc"
                    ]
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": "",
              "targetPurpose": "TargetPurposeExistenceFilterMismatch"
            }
          }
        }
      },
      {
        "watchRemove": {
          "targetIds": [
            2
          ]
        }
      },
      {
        "watchAck": [
          2
        ]
      },
      {
        "watchEntity": {
          "docs": [
            {
              "createTime": 0,
              "key": "collection/b",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "a": 2
              },
              "version": 1000
            }
          ],
          "targets": [
            2
          ]
        }
      },
      {
        "watchCurrent": [
          [
            2
          ],
          "resume-token-1005"
        ]
      },
      {
        "watchSnapshot": {
          "targetIds": [
          ],
          "version": 1005
        },
        "expectedState": {
          "activeLimboDocs": [
            "collection/a"
          ],
          "activeTargets": {
            "1": {
              "queries": [
                {
                  "filters": [
                  ],
                  "orderBys": [
                  ],
                  "path": "collection/a"
                }
              ],
              "resumeToken": "",
              "targetPurpose": "TargetPurposeLimboResolution"
            },
            "2": {
              "queries": [
                {
                  "filters": [
                  ],
                  "limit": 1,
                  "limitType": "LimitToFirst",
                  "orderBys": [
                    [
                      "a",
                      "asc"
                    ]
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": "",
              "targetPurpose": "TargetPurposeExistenceFilterMismatch"
            }
          }
        }
      },
      {
        "watchAck": [
          1
        ]
      },
      {
        "watchCurrent": [
          [
            1
          ],
          "resume-token-1006"
        ]
      },
      {
        "watchSnapshot": {
          "targetIds": [
          ],
          "version": 1006
        },
        "expectedSnapshotEvents": [
          {
            "added": [
              {
                "createTime": 0,
                "key": "collection/b",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "a": 2
                },
                "version": 1000
              }
            ],
            "errorCode": 0,
            "fromCache": false,
            "hasPendingWrites": false,
            "query": {
              "filters": [
              ],
              "limit": 1,
              "limitType": "LimitToFirst",
              "orderBys": [
                [
                  "a",
                  "asc"
                ]
              ],
              "path": "collection"
            },
            "removed": [
              {
                "createTime": 0,
                "key": "collection/a",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "a": 1
                },
                "version": 1001
              }
            ]
          }
        ],
        "expectedState": {
          "activeLimboDocs": [
          ],
          "activeTargets": {
            "2": {
              "queries": [
                {
                  "filters": [
                  ],
                  "limit": 1,
                  "limitType": "LimitToFirst",
                  "orderBys": [
                    [
                      "a",
                      "asc"
                    ]
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": "",
              "targetPurpose": "TargetPurposeExistenceFilterMismatch"
            }
          }
        }
      }
    ]
  },
  "Resumed limit queries use updated documents ": {
    "describeName": "Limits:",
    "itName": "Resumed limit queries use updated documents ",
    "tags": [
    ],
    "config": {
      "numClients": 1,
      "useEagerGCForMemory": false
    },
    "steps": [
      {
        "userListen": {
          "query": {
            "filters": [
            ],
            "limit": 1,
            "limitType": "LimitToFirst",
            "orderBys": [
              [
                "a",
                "asc"
              ]
            ],
            "path": "collection"
          },
          "targetId": 2
        },
        "expectedState": {
          "activeTargets": {
            "2": {
              "queries": [
                {
                  "filters": [
                  ],
                  "limit": 1,
                  "limitType": "LimitToFirst",
                  "orderBys": [
                    [
                      "a",
                      "asc"
                    ]
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": ""
            }
          }
        }
      },
      {
        "watchAck": [
          2
        ]
      },
      {
        "watchEntity": {
          "docs": [
            {
              "createTime": 0,
              "key": "collection/a",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "a": 1
              },
              "version": 2001
            }
          ],
          "targets": [
            2
          ]
        }
      },
      {
        "watchCurrent": [
          [
            2
          ],
          "resume-token-2001"
        ]
      },
      {
        "watchSnapshot": {
          "targetIds": [
          ],
          "version": 2001
        },
        "expectedSnapshotEvents": [
          {
            "added": [
              {
                "createTime": 0,
                "key": "collection/a",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "a": 1
                },
                "version": 2001
              }
            ],
            "errorCode": 0,
            "fromCache": false,
            "hasPendingWrites": false,
            "query": {
              "filters": [
              ],
              "limit": 1,
              "limitType": "LimitToFirst",
              "orderBys": [
                [
                  "a",
                  "asc"
                ]
              ],
              "path": "collection"
            }
          }
        ]
      },
      {
        "userUnlisten": [
          2,
          {
            "filters": [
            ],
            "limit": 1,
            "limitType": "LimitToFirst",
            "orderBys": [
              [
                "a",
                "asc"
              ]
            ],
            "path": "collection"
          }
        ],
        "expectedState": {
          "activeTargets": {
          }
        }
      },
      {
        "watchRemove": {
          "targetIds": [
            2
          ]
        }
      },
      {
        "userListen": {
          "query": {
            "filters": [
            ],
            "orderBys": [
              [
                "a",
                "asc"
              ]
            ],
            "path": "collection"
          },
          "targetId": 4
        },
        "expectedSnapshotEvents": [
          {
            "added": [
              {
                "createTime": 0,
                "key": "collection/a",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "a": 1
                },
                "version": 2001
              }
            ],
            "errorCode": 0,
            "fromCache": true,
            "hasPendingWrites": false,
            "query": {
              "filters": [
              ],
              "orderBys": [
                [
                  "a",
                  "asc"
                ]
              ],
              "path": "collection"
            }
          }
        ],
        "expectedState": {
          "activeTargets": {
            "4": {
              "queries": [
                {
                  "filters": [
                  ],
                  "orderBys": [
                    [
                      "a",
                      "asc"
                    ]
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": ""
            }
          }
        }
      },
      {
        "watchAck": [
          4
        ]
      },
      {
        "watchEntity": {
          "docs": [
            {
              "createTime": 0,
              "key": "collection/a",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "a": 3
              },
              "version": 2003
            },
            {
              "createTime": 0,
              "key": "collection/c",
              "options": {
                "hasCommittedMutations": false,
                "hasLocalMutations": false
              },
              "value": {
                "a": 2
              },
              "version": 1000
            }
          ],
          "targets": [
            4
          ]
        }
      },
      {
        "watchCurrent": [
          [
            4
          ],
          "resume-token-2003"
        ]
      },
      {
        "watchSnapshot": {
          "targetIds": [
          ],
          "version": 2003
        },
        "expectedSnapshotEvents": [
          {
            "added": [
              {
                "createTime": 0,
                "key": "collection/c",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "a": 2
                },
                "version": 1000
              }
            ],
            "errorCode": 0,
            "fromCache": false,
            "hasPendingWrites": false,
            "modified": [
              {
                "createTime": 0,
                "key": "collection/a",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "a": 3
                },
                "version": 2003
              }
            ],
            "query": {
              "filters": [
              ],
              "orderBys": [
                [
                  "a",
                  "asc"
                ]
              ],
              "path": "collection"
            }
          }
        ]
      },
      {
        "userUnlisten": [
          4,
          {
            "filters": [
            ],
            "orderBys": [
              [
                "a",
                "asc"
              ]
            ],
            "path": "collection"
          }
        ],
        "expectedState": {
          "activeTargets": {
          }
        }
      },
      {
        "watchRemove": {
          "targetIds": [
            4
          ]
        }
      },
      {
        "userListen": {
          "query": {
            "filters": [
            ],
            "limit": 1,
            "limitType": "LimitToFirst",
            "orderBys": [
              [
                "a",
                "asc"
              ]
            ],
            "path": "collection"
          },
          "targetId": 2
        },
        "expectedSnapshotEvents": [
          {
            "added": [
              {
                "createTime": 0,
                "key": "collection/c",
                "options": {
                  "hasCommittedMutations": false,
                  "hasLocalMutations": false
                },
                "value": {
                  "a": 2
                },
                "version": 1000
              }
            ],
            "errorCode": 0,
            "fromCache": true,
            "hasPendingWrites": false,
            "query": {
              "filters": [
              ],
              "limit": 1,
              "limitType": "LimitToFirst",
              "orderBys": [
                [
                  "a",
                  "asc"
                ]
              ],
              "path": "collection"
            }
          }
        ],
        "expectedState": {
          "activeTargets": {
            "2": {
              "queries": [
                {
                  "filters": [
                  ],
                  "limit": 1,
                  "limitType": "LimitToFirst",
                  "orderBys": [
                    [
                      "a",
                      "asc"
                    ]
                  ],
                  "path": "collection"
                }
              ],
              "resumeToken": "resume-token-2001"
            }
          }
        }
      }
    ]
  }
}
