persistence_spec_test.json 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870
  1. {
  2. "Local mutations are persisted and re-sent": {
  3. "describeName": "Persistence:",
  4. "itName": "Local mutations are persisted and re-sent",
  5. "tags": [
  6. "persistence"
  7. ],
  8. "config": {
  9. "useGarbageCollection": true
  10. },
  11. "steps": [
  12. {
  13. "userSet": [
  14. "collection/key1",
  15. {
  16. "foo": "bar"
  17. }
  18. ]
  19. },
  20. {
  21. "userSet": [
  22. "collection/key2",
  23. {
  24. "baz": "quu"
  25. }
  26. ]
  27. },
  28. {
  29. "restart": true,
  30. "stateExpect": {
  31. "activeTargets": {},
  32. "limboDocs": [],
  33. "numOutstandingWrites": 2
  34. }
  35. },
  36. {
  37. "writeAck": {
  38. "version": 1,
  39. "expectUserCallback": false
  40. }
  41. },
  42. {
  43. "writeAck": {
  44. "version": 2,
  45. "expectUserCallback": false
  46. },
  47. "stateExpect": {
  48. "numOutstandingWrites": 0
  49. }
  50. }
  51. ]
  52. },
  53. "Persisted local mutations are visible to listeners": {
  54. "describeName": "Persistence:",
  55. "itName": "Persisted local mutations are visible to listeners",
  56. "tags": [
  57. "persistence"
  58. ],
  59. "config": {
  60. "useGarbageCollection": true
  61. },
  62. "steps": [
  63. {
  64. "userSet": [
  65. "collection/key1",
  66. {
  67. "foo": "bar"
  68. }
  69. ]
  70. },
  71. {
  72. "userSet": [
  73. "collection/key2",
  74. {
  75. "baz": "quu"
  76. }
  77. ]
  78. },
  79. {
  80. "restart": true,
  81. "stateExpect": {
  82. "activeTargets": {},
  83. "limboDocs": []
  84. }
  85. },
  86. {
  87. "userListen": [
  88. 2,
  89. {
  90. "path": "collection",
  91. "filters": [],
  92. "orderBys": []
  93. }
  94. ],
  95. "stateExpect": {
  96. "activeTargets": {
  97. "2": {
  98. "query": {
  99. "path": "collection",
  100. "filters": [],
  101. "orderBys": []
  102. },
  103. "resumeToken": ""
  104. }
  105. }
  106. },
  107. "expect": [
  108. {
  109. "query": {
  110. "path": "collection",
  111. "filters": [],
  112. "orderBys": []
  113. },
  114. "added": [
  115. [
  116. "collection/key1",
  117. 0,
  118. {
  119. "foo": "bar"
  120. },
  121. "local"
  122. ],
  123. [
  124. "collection/key2",
  125. 0,
  126. {
  127. "baz": "quu"
  128. },
  129. "local"
  130. ]
  131. ],
  132. "errorCode": 0,
  133. "fromCache": true,
  134. "hasPendingWrites": true
  135. }
  136. ]
  137. }
  138. ]
  139. },
  140. "Remote documents are persisted": {
  141. "describeName": "Persistence:",
  142. "itName": "Remote documents are persisted",
  143. "tags": [
  144. "persistence"
  145. ],
  146. "config": {
  147. "useGarbageCollection": true
  148. },
  149. "steps": [
  150. {
  151. "userListen": [
  152. 2,
  153. {
  154. "path": "collection",
  155. "filters": [],
  156. "orderBys": []
  157. }
  158. ],
  159. "stateExpect": {
  160. "activeTargets": {
  161. "2": {
  162. "query": {
  163. "path": "collection",
  164. "filters": [],
  165. "orderBys": []
  166. },
  167. "resumeToken": ""
  168. }
  169. }
  170. }
  171. },
  172. {
  173. "watchAck": [
  174. 2
  175. ]
  176. },
  177. {
  178. "watchEntity": {
  179. "docs": [
  180. [
  181. "collection/key",
  182. 1000,
  183. {
  184. "foo": "bar"
  185. }
  186. ]
  187. ],
  188. "targets": [
  189. 2
  190. ]
  191. }
  192. },
  193. {
  194. "watchCurrent": [
  195. [
  196. 2
  197. ],
  198. "resume-token-1000"
  199. ]
  200. },
  201. {
  202. "watchSnapshot": {
  203. "version": 1000
  204. },
  205. "expect": [
  206. {
  207. "query": {
  208. "path": "collection",
  209. "filters": [],
  210. "orderBys": []
  211. },
  212. "added": [
  213. [
  214. "collection/key",
  215. 1000,
  216. {
  217. "foo": "bar"
  218. }
  219. ]
  220. ],
  221. "errorCode": 0,
  222. "fromCache": false,
  223. "hasPendingWrites": false
  224. }
  225. ]
  226. },
  227. {
  228. "restart": true,
  229. "stateExpect": {
  230. "activeTargets": {},
  231. "limboDocs": []
  232. }
  233. },
  234. {
  235. "userListen": [
  236. 2,
  237. {
  238. "path": "collection",
  239. "filters": [],
  240. "orderBys": []
  241. }
  242. ],
  243. "stateExpect": {
  244. "activeTargets": {
  245. "2": {
  246. "query": {
  247. "path": "collection",
  248. "filters": [],
  249. "orderBys": []
  250. },
  251. "resumeToken": "resume-token-1000"
  252. }
  253. }
  254. },
  255. "expect": [
  256. {
  257. "query": {
  258. "path": "collection",
  259. "filters": [],
  260. "orderBys": []
  261. },
  262. "added": [
  263. [
  264. "collection/key",
  265. 1000,
  266. {
  267. "foo": "bar"
  268. }
  269. ]
  270. ],
  271. "errorCode": 0,
  272. "fromCache": true,
  273. "hasPendingWrites": false
  274. }
  275. ]
  276. }
  277. ]
  278. },
  279. "Remote documents from watch are not GC'd": {
  280. "describeName": "Persistence:",
  281. "itName": "Remote documents from watch are not GC'd",
  282. "tags": [
  283. "persistence"
  284. ],
  285. "config": {
  286. "useGarbageCollection": false
  287. },
  288. "steps": [
  289. {
  290. "userListen": [
  291. 2,
  292. {
  293. "path": "collection",
  294. "filters": [],
  295. "orderBys": []
  296. }
  297. ],
  298. "stateExpect": {
  299. "activeTargets": {
  300. "2": {
  301. "query": {
  302. "path": "collection",
  303. "filters": [],
  304. "orderBys": []
  305. },
  306. "resumeToken": ""
  307. }
  308. }
  309. }
  310. },
  311. {
  312. "watchAck": [
  313. 2
  314. ]
  315. },
  316. {
  317. "watchEntity": {
  318. "docs": [
  319. [
  320. "collection/key",
  321. 1000,
  322. {
  323. "foo": "bar"
  324. }
  325. ]
  326. ],
  327. "targets": [
  328. 2
  329. ]
  330. }
  331. },
  332. {
  333. "watchCurrent": [
  334. [
  335. 2
  336. ],
  337. "resume-token-1000"
  338. ]
  339. },
  340. {
  341. "watchSnapshot": {
  342. "version": 1000
  343. },
  344. "expect": [
  345. {
  346. "query": {
  347. "path": "collection",
  348. "filters": [],
  349. "orderBys": []
  350. },
  351. "added": [
  352. [
  353. "collection/key",
  354. 1000,
  355. {
  356. "foo": "bar"
  357. }
  358. ]
  359. ],
  360. "errorCode": 0,
  361. "fromCache": false,
  362. "hasPendingWrites": false
  363. }
  364. ]
  365. },
  366. {
  367. "userUnlisten": [
  368. 2,
  369. {
  370. "path": "collection",
  371. "filters": [],
  372. "orderBys": []
  373. }
  374. ],
  375. "stateExpect": {
  376. "activeTargets": {}
  377. }
  378. },
  379. {
  380. "userListen": [
  381. 2,
  382. {
  383. "path": "collection",
  384. "filters": [],
  385. "orderBys": []
  386. }
  387. ],
  388. "stateExpect": {
  389. "activeTargets": {
  390. "2": {
  391. "query": {
  392. "path": "collection",
  393. "filters": [],
  394. "orderBys": []
  395. },
  396. "resumeToken": "resume-token-1000"
  397. }
  398. }
  399. },
  400. "expect": [
  401. {
  402. "query": {
  403. "path": "collection",
  404. "filters": [],
  405. "orderBys": []
  406. },
  407. "added": [
  408. [
  409. "collection/key",
  410. 1000,
  411. {
  412. "foo": "bar"
  413. }
  414. ]
  415. ],
  416. "errorCode": 0,
  417. "fromCache": true,
  418. "hasPendingWrites": false
  419. }
  420. ]
  421. }
  422. ]
  423. },
  424. "Remote documents from user sets are not GC'd": {
  425. "describeName": "Persistence:",
  426. "itName": "Remote documents from user sets are not GC'd",
  427. "tags": [
  428. "persistence"
  429. ],
  430. "config": {
  431. "useGarbageCollection": false
  432. },
  433. "steps": [
  434. {
  435. "userSet": [
  436. "collection/key",
  437. {
  438. "foo": "bar"
  439. }
  440. ]
  441. },
  442. {
  443. "writeAck": {
  444. "version": 1000,
  445. "expectUserCallback": true
  446. }
  447. },
  448. {
  449. "userListen": [
  450. 2,
  451. {
  452. "path": "collection",
  453. "filters": [],
  454. "orderBys": []
  455. }
  456. ],
  457. "stateExpect": {
  458. "activeTargets": {
  459. "2": {
  460. "query": {
  461. "path": "collection",
  462. "filters": [],
  463. "orderBys": []
  464. },
  465. "resumeToken": ""
  466. }
  467. }
  468. },
  469. "expect": [
  470. {
  471. "query": {
  472. "path": "collection",
  473. "filters": [],
  474. "orderBys": []
  475. },
  476. "added": [
  477. [
  478. "collection/key",
  479. 0,
  480. {
  481. "foo": "bar"
  482. }
  483. ]
  484. ],
  485. "errorCode": 0,
  486. "fromCache": true,
  487. "hasPendingWrites": false
  488. }
  489. ]
  490. }
  491. ]
  492. },
  493. "Mutation Queue is persisted across uid switches": {
  494. "describeName": "Persistence:",
  495. "itName": "Mutation Queue is persisted across uid switches",
  496. "tags": [
  497. "persistence"
  498. ],
  499. "config": {
  500. "useGarbageCollection": true
  501. },
  502. "steps": [
  503. {
  504. "userSet": [
  505. "users/anon",
  506. {
  507. "uid": "anon"
  508. }
  509. ]
  510. },
  511. {
  512. "changeUser": "user1",
  513. "stateExpect": {
  514. "numOutstandingWrites": 0
  515. }
  516. },
  517. {
  518. "userSet": [
  519. "users/user1",
  520. {
  521. "uid": "user1"
  522. }
  523. ]
  524. },
  525. {
  526. "userSet": [
  527. "users/user1",
  528. {
  529. "uid": "user1",
  530. "extra": true
  531. }
  532. ]
  533. },
  534. {
  535. "changeUser": null,
  536. "stateExpect": {
  537. "numOutstandingWrites": 1
  538. }
  539. },
  540. {
  541. "writeAck": {
  542. "version": 1000,
  543. "expectUserCallback": true
  544. }
  545. },
  546. {
  547. "changeUser": "user1",
  548. "stateExpect": {
  549. "numOutstandingWrites": 2
  550. }
  551. },
  552. {
  553. "writeAck": {
  554. "version": 2000,
  555. "expectUserCallback": true
  556. }
  557. },
  558. {
  559. "writeAck": {
  560. "version": 3000,
  561. "expectUserCallback": true
  562. }
  563. }
  564. ]
  565. },
  566. "Mutation Queue is persisted across uid switches (with restarts)": {
  567. "describeName": "Persistence:",
  568. "itName": "Mutation Queue is persisted across uid switches (with restarts)",
  569. "tags": [
  570. "persistence"
  571. ],
  572. "config": {
  573. "useGarbageCollection": true
  574. },
  575. "steps": [
  576. {
  577. "userSet": [
  578. "users/anon",
  579. {
  580. "uid": "anon"
  581. }
  582. ]
  583. },
  584. {
  585. "changeUser": "user1",
  586. "stateExpect": {
  587. "numOutstandingWrites": 0
  588. }
  589. },
  590. {
  591. "userSet": [
  592. "users/user1",
  593. {
  594. "uid": "user1"
  595. }
  596. ]
  597. },
  598. {
  599. "userSet": [
  600. "users/user1",
  601. {
  602. "uid": "user1",
  603. "extra": true
  604. }
  605. ]
  606. },
  607. {
  608. "changeUser": null
  609. },
  610. {
  611. "restart": true,
  612. "stateExpect": {
  613. "activeTargets": {},
  614. "limboDocs": [],
  615. "numOutstandingWrites": 1
  616. }
  617. },
  618. {
  619. "writeAck": {
  620. "version": 1000,
  621. "expectUserCallback": false
  622. }
  623. },
  624. {
  625. "changeUser": "user1"
  626. },
  627. {
  628. "restart": true,
  629. "stateExpect": {
  630. "activeTargets": {},
  631. "limboDocs": [],
  632. "numOutstandingWrites": 2
  633. }
  634. },
  635. {
  636. "writeAck": {
  637. "version": 2000,
  638. "expectUserCallback": false
  639. }
  640. },
  641. {
  642. "writeAck": {
  643. "version": 3000,
  644. "expectUserCallback": false
  645. }
  646. }
  647. ]
  648. },
  649. "Visible mutations reflect uid switches": {
  650. "describeName": "Persistence:",
  651. "itName": "Visible mutations reflect uid switches",
  652. "tags": [
  653. "persistence"
  654. ],
  655. "config": {
  656. "useGarbageCollection": true
  657. },
  658. "steps": [
  659. {
  660. "userListen": [
  661. 2,
  662. {
  663. "path": "users",
  664. "filters": [],
  665. "orderBys": []
  666. }
  667. ],
  668. "stateExpect": {
  669. "activeTargets": {
  670. "2": {
  671. "query": {
  672. "path": "users",
  673. "filters": [],
  674. "orderBys": []
  675. },
  676. "resumeToken": ""
  677. }
  678. }
  679. }
  680. },
  681. {
  682. "watchAck": [
  683. 2
  684. ]
  685. },
  686. {
  687. "watchEntity": {
  688. "docs": [
  689. [
  690. "users/existing",
  691. 0,
  692. {
  693. "uid": "existing"
  694. }
  695. ]
  696. ],
  697. "targets": [
  698. 2
  699. ]
  700. }
  701. },
  702. {
  703. "watchCurrent": [
  704. [
  705. 2
  706. ],
  707. "resume-token-500"
  708. ]
  709. },
  710. {
  711. "watchSnapshot": {
  712. "version": 500
  713. },
  714. "expect": [
  715. {
  716. "query": {
  717. "path": "users",
  718. "filters": [],
  719. "orderBys": []
  720. },
  721. "added": [
  722. [
  723. "users/existing",
  724. 0,
  725. {
  726. "uid": "existing"
  727. }
  728. ]
  729. ],
  730. "errorCode": 0,
  731. "fromCache": false,
  732. "hasPendingWrites": false
  733. }
  734. ]
  735. },
  736. {
  737. "userSet": [
  738. "users/anon",
  739. {
  740. "uid": "anon"
  741. }
  742. ],
  743. "expect": [
  744. {
  745. "query": {
  746. "path": "users",
  747. "filters": [],
  748. "orderBys": []
  749. },
  750. "added": [
  751. [
  752. "users/anon",
  753. 0,
  754. {
  755. "uid": "anon"
  756. },
  757. "local"
  758. ]
  759. ],
  760. "errorCode": 0,
  761. "fromCache": false,
  762. "hasPendingWrites": true
  763. }
  764. ]
  765. },
  766. {
  767. "changeUser": "user1",
  768. "stateExpect": {
  769. "activeTargets": {
  770. "2": {
  771. "query": {
  772. "path": "users",
  773. "filters": [],
  774. "orderBys": []
  775. },
  776. "resumeToken": "resume-token-500"
  777. }
  778. }
  779. },
  780. "expect": [
  781. {
  782. "query": {
  783. "path": "users",
  784. "filters": [],
  785. "orderBys": []
  786. },
  787. "removed": [
  788. [
  789. "users/anon",
  790. 0,
  791. {
  792. "uid": "anon"
  793. },
  794. "local"
  795. ]
  796. ],
  797. "errorCode": 0,
  798. "fromCache": false,
  799. "hasPendingWrites": false
  800. }
  801. ]
  802. },
  803. {
  804. "userSet": [
  805. "users/user1",
  806. {
  807. "uid": "user1"
  808. }
  809. ],
  810. "expect": [
  811. {
  812. "query": {
  813. "path": "users",
  814. "filters": [],
  815. "orderBys": []
  816. },
  817. "added": [
  818. [
  819. "users/user1",
  820. 0,
  821. {
  822. "uid": "user1"
  823. },
  824. "local"
  825. ]
  826. ],
  827. "errorCode": 0,
  828. "fromCache": false,
  829. "hasPendingWrites": true
  830. }
  831. ]
  832. },
  833. {
  834. "changeUser": null,
  835. "expect": [
  836. {
  837. "query": {
  838. "path": "users",
  839. "filters": [],
  840. "orderBys": []
  841. },
  842. "added": [
  843. [
  844. "users/anon",
  845. 0,
  846. {
  847. "uid": "anon"
  848. },
  849. "local"
  850. ]
  851. ],
  852. "removed": [
  853. [
  854. "users/user1",
  855. 0,
  856. {
  857. "uid": "user1"
  858. },
  859. "local"
  860. ]
  861. ],
  862. "errorCode": 0,
  863. "fromCache": false,
  864. "hasPendingWrites": true
  865. }
  866. ]
  867. }
  868. ]
  869. }
  870. }