emberflow 1.3.76 → 1.3.77

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -34,6 +34,7 @@ const adminClient = __importStar(require("emberflow-admin-client/lib"));
34
34
  var Timestamp = firebase_admin_1.firestore.Timestamp;
35
35
  const index_utils_1 = require("../index-utils");
36
36
  const distribution = __importStar(require("../utils/distribution"));
37
+ var FieldValue = firebase_admin_1.firestore.FieldValue;
37
38
  const projectConfig = {
38
39
  projectId: "your-project-id",
39
40
  budgetAlertTopicName: "budget-alerts",
@@ -55,8 +56,9 @@ const getMock = {
55
56
  data: dataMock,
56
57
  };
57
58
  const updateMock = jest.fn();
59
+ const setMock = jest.fn();
58
60
  const docMock = {
59
- set: jest.fn(),
61
+ set: setMock,
60
62
  get: jest.fn().mockResolvedValue(getMock),
61
63
  update: updateMock,
62
64
  collection: jest.fn(() => collectionMock),
@@ -64,9 +66,13 @@ const docMock = {
64
66
  const collectionMock = {
65
67
  doc: jest.fn(() => docMock),
66
68
  };
69
+ const transactionGetMock = jest.fn();
70
+ const transactionSetMock = jest.fn();
71
+ const transactionUpdateMock = jest.fn();
67
72
  const transactionMock = {
68
- set: jest.fn(),
69
- update: jest.fn(),
73
+ get: transactionGetMock,
74
+ set: transactionSetMock,
75
+ update: transactionUpdateMock,
70
76
  delete: jest.fn(),
71
77
  };
72
78
  jest.spyOn(admin, "firestore")
@@ -85,8 +91,9 @@ jest.spyOn(admin, "database")
85
91
  });
86
92
  admin.initializeApp();
87
93
  (0, index_1.initializeEmberFlow)(projectConfig, admin, db_structure_1.dbStructure, db_structure_1.Entity, {}, {}, []);
94
+ const refUpdateMock = jest.fn();
88
95
  const refMock = {
89
- update: jest.fn(),
96
+ update: refUpdateMock,
90
97
  };
91
98
  function createDocumentSnapshot(form) {
92
99
  return {
@@ -128,6 +135,41 @@ describe("onFormSubmit", () => {
128
135
  nestedField2: "oldValue",
129
136
  },
130
137
  };
138
+ const equation = "totalTodos = notStartedCount + inProgressCount + toVerifyCount + requestChangesCount + doneCount";
139
+ const now = Timestamp.fromDate(new Date());
140
+ const journalEntry = {
141
+ date: now,
142
+ ledgerEntries: [
143
+ {
144
+ account: "totalTodos",
145
+ debit: 1,
146
+ credit: 0,
147
+ },
148
+ {
149
+ account: "notStartedCount",
150
+ debit: 0,
151
+ credit: 1,
152
+ },
153
+ ],
154
+ equation: equation,
155
+ };
156
+ const recordedJournalEntry = {
157
+ date: now,
158
+ ledgerEntries: [
159
+ {
160
+ account: "inProgressCount",
161
+ debit: 1,
162
+ credit: 0,
163
+ },
164
+ {
165
+ account: "doneCount",
166
+ debit: 0,
167
+ credit: 1,
168
+ },
169
+ ],
170
+ equation: equation,
171
+ recordEntry: true,
172
+ };
131
173
  beforeEach(() => {
132
174
  jest.spyOn(index_1._mockable, "createNowTimestamp").mockReturnValue(Timestamp.now());
133
175
  jest.spyOn(console, "log").mockImplementation();
@@ -138,6 +180,14 @@ describe("onFormSubmit", () => {
138
180
  });
139
181
  refMock.update.mockReset();
140
182
  updateMock.mockReset();
183
+ transactionGetMock.mockResolvedValue({
184
+ data: () => ({
185
+ totalTodos: 3,
186
+ notStartedCount: 1,
187
+ inProgressCount: 1,
188
+ doneCount: 1,
189
+ }),
190
+ });
141
191
  });
142
192
  afterEach(() => {
143
193
  jest.restoreAllMocks();
@@ -502,7 +552,326 @@ describe("onFormSubmit", () => {
502
552
  docMock.set.mockReset();
503
553
  docMock.update.mockReset();
504
554
  });
555
+ it("should write journal entries first", async () => {
556
+ const consoleErrorSpy = jest.spyOn(console, "error").mockImplementation();
557
+ const consoleInfoSpy = jest.spyOn(console, "info").mockImplementation();
558
+ jest.spyOn(indexutils, "runBusinessLogics").mockImplementation(async (actionRef, action, distributeFn) => {
559
+ await distributeFn(actionRef, logicResults, 0);
560
+ return "done";
561
+ });
562
+ let logicResults = [
563
+ {
564
+ name: "logic 1",
565
+ timeFinished: index_1._mockable.createNowTimestamp(),
566
+ status: "finished",
567
+ documents: [
568
+ { action: "merge", priority: "normal", dstPath: "path1/doc1" },
569
+ ],
570
+ },
571
+ ];
572
+ const docPath = "users/user-1";
573
+ const form = {
574
+ "formData": JSON.stringify({
575
+ "@actionType": "create",
576
+ "name": "test",
577
+ "@docPath": docPath,
578
+ }),
579
+ "@status": "submit",
580
+ };
581
+ const event = createEvent(form);
582
+ await (0, index_1.onFormSubmit)(event);
583
+ expect(consoleInfoSpy).toHaveBeenCalledWith("No journal entries to write");
584
+ expect(transactionUpdateMock).not.toHaveBeenCalled();
585
+ expect(transactionSetMock).not.toHaveBeenCalled();
586
+ expect(transactionGetMock).not.toHaveBeenCalled();
587
+ logicResults = [
588
+ {
589
+ name: "logic 1",
590
+ timeFinished: index_1._mockable.createNowTimestamp(),
591
+ status: "finished",
592
+ documents: [
593
+ { action: "merge", priority: "normal", dstPath: "", journalEntries: [journalEntry] },
594
+ ],
595
+ },
596
+ ];
597
+ await (0, index_1.onFormSubmit)(event);
598
+ expect(consoleErrorSpy).toHaveBeenCalledWith("Dst path has no docId");
599
+ expect(transactionUpdateMock).not.toHaveBeenCalled();
600
+ expect(transactionSetMock).not.toHaveBeenCalled();
601
+ expect(transactionGetMock).not.toHaveBeenCalled();
602
+ logicResults = [
603
+ {
604
+ name: "logic 1",
605
+ timeFinished: index_1._mockable.createNowTimestamp(),
606
+ status: "finished",
607
+ documents: [
608
+ { action: "merge", priority: "high", dstPath: "path1/doc5", doc: { totalTodos: 1 }, journalEntries: [journalEntry] },
609
+ ],
610
+ },
611
+ ];
612
+ await (0, index_1.onFormSubmit)(event);
613
+ expect(consoleErrorSpy).toHaveBeenCalledWith("Doc cannot have keys that are the same as account names");
614
+ expect(transactionUpdateMock).not.toHaveBeenCalled();
615
+ expect(transactionSetMock).not.toHaveBeenCalled();
616
+ expect(transactionGetMock).not.toHaveBeenCalled();
617
+ logicResults = [
618
+ {
619
+ name: "logic 1",
620
+ timeFinished: index_1._mockable.createNowTimestamp(),
621
+ status: "finished",
622
+ documents: [
623
+ { action: "merge", priority: "high", dstPath: "path1/doc5", instructions: { totalTodos: "+1" }, journalEntries: [journalEntry] },
624
+ ],
625
+ },
626
+ ];
627
+ await (0, index_1.onFormSubmit)(event);
628
+ expect(consoleErrorSpy).toHaveBeenCalledWith("Instructions cannot have keys that are the same as account names");
629
+ expect(transactionUpdateMock).not.toHaveBeenCalled();
630
+ expect(transactionSetMock).not.toHaveBeenCalled();
631
+ expect(transactionGetMock).not.toHaveBeenCalled();
632
+ const unbalancedJournalEntry = {
633
+ date: index_1._mockable.createNowTimestamp(),
634
+ ledgerEntries: [
635
+ {
636
+ account: "totalTodos",
637
+ debit: 1,
638
+ credit: 0,
639
+ },
640
+ {
641
+ account: "notStartedCount",
642
+ debit: 0,
643
+ credit: 1,
644
+ },
645
+ {
646
+ account: "inProgressCount",
647
+ debit: 0,
648
+ credit: 1,
649
+ },
650
+ ],
651
+ equation: equation,
652
+ };
653
+ logicResults = [
654
+ {
655
+ name: "logic 1",
656
+ timeFinished: index_1._mockable.createNowTimestamp(),
657
+ status: "finished",
658
+ documents: [
659
+ { action: "merge", priority: "high", dstPath: "path1/doc5", journalEntries: [unbalancedJournalEntry] },
660
+ ],
661
+ },
662
+ ];
663
+ await (0, index_1.onFormSubmit)(event);
664
+ expect(consoleErrorSpy).toHaveBeenCalledWith("Debit and credit should be equal");
665
+ expect(transactionUpdateMock).not.toHaveBeenCalled();
666
+ expect(transactionSetMock).not.toHaveBeenCalled();
667
+ expect(transactionGetMock).not.toHaveBeenCalled();
668
+ transactionGetMock.mockRestore();
669
+ transactionSetMock.mockRestore();
670
+ transactionUpdateMock.mockRestore();
671
+ transactionGetMock.mockResolvedValueOnce({
672
+ data: () => undefined,
673
+ });
674
+ const docRef = index_1.db.doc("path1/doc1");
675
+ logicResults = [
676
+ {
677
+ name: "logic 1",
678
+ timeFinished: index_1._mockable.createNowTimestamp(),
679
+ status: "finished",
680
+ documents: [
681
+ { action: "merge", priority: "normal", dstPath: "path1/doc1", doc: { field: "value" }, journalEntries: [journalEntry] },
682
+ ],
683
+ },
684
+ ];
685
+ await (0, index_1.onFormSubmit)(event);
686
+ expect(transactionGetMock).toHaveBeenCalledTimes(1);
687
+ expect(transactionGetMock).toHaveBeenCalledWith(docRef);
688
+ expect(transactionSetMock).toHaveBeenCalledTimes(1);
689
+ expect(transactionSetMock).toHaveBeenCalledWith(docRef, { "field": "value", "@forDeletionLater": true });
690
+ expect(transactionUpdateMock).toHaveBeenCalledTimes(2);
691
+ expect(transactionUpdateMock).toHaveBeenNthCalledWith(1, docRef, {
692
+ "totalTodos": 1,
693
+ "@forDeletionLater": FieldValue.delete(),
694
+ });
695
+ expect(transactionUpdateMock).toHaveBeenNthCalledWith(2, docRef, {
696
+ "notStartedCount": 1,
697
+ "@forDeletionLater": FieldValue.delete(),
698
+ });
699
+ transactionGetMock.mockRestore();
700
+ transactionSetMock.mockRestore();
701
+ transactionUpdateMock.mockRestore();
702
+ transactionGetMock.mockResolvedValueOnce({
703
+ data: () => ({
704
+ "totalTodos": 1,
705
+ "notStartedCount": 1,
706
+ }),
707
+ });
708
+ logicResults = [
709
+ {
710
+ name: "logic 1",
711
+ timeFinished: index_1._mockable.createNowTimestamp(),
712
+ status: "finished",
713
+ documents: [
714
+ { action: "merge", priority: "normal", dstPath: "path1/doc1", doc: { field: "value" }, journalEntries: [journalEntry] },
715
+ ],
716
+ },
717
+ ];
718
+ await (0, index_1.onFormSubmit)(event);
719
+ expect(transactionGetMock).toHaveBeenCalledTimes(1);
720
+ expect(transactionGetMock).toHaveBeenCalledWith(docRef);
721
+ expect(transactionSetMock).not.toHaveBeenCalled();
722
+ expect(transactionUpdateMock).toHaveBeenCalledTimes(3);
723
+ expect(transactionUpdateMock).toHaveBeenNthCalledWith(1, docRef, { "field": "value", "@forDeletionLater": true });
724
+ expect(transactionUpdateMock).toHaveBeenNthCalledWith(2, docRef, {
725
+ "totalTodos": 2,
726
+ "@forDeletionLater": FieldValue.delete(),
727
+ });
728
+ expect(transactionUpdateMock).toHaveBeenNthCalledWith(3, docRef, {
729
+ "notStartedCount": 2,
730
+ "@forDeletionLater": FieldValue.delete(),
731
+ });
732
+ transactionGetMock.mockRestore();
733
+ transactionSetMock.mockRestore();
734
+ transactionUpdateMock.mockRestore();
735
+ transactionGetMock.mockResolvedValueOnce({
736
+ data: () => ({
737
+ "totalTodos": 2,
738
+ "notStartedCount": 0,
739
+ "inProgressCount": 2,
740
+ }),
741
+ });
742
+ const zeroJournalEntry = {
743
+ date: index_1._mockable.createNowTimestamp(),
744
+ ledgerEntries: [
745
+ {
746
+ account: "notStartedCount",
747
+ debit: 1,
748
+ credit: 1,
749
+ },
750
+ {
751
+ account: "inProgressCount",
752
+ debit: 1,
753
+ credit: 1,
754
+ },
755
+ ],
756
+ equation: equation,
757
+ };
758
+ logicResults = [
759
+ {
760
+ name: "logic 1",
761
+ timeFinished: index_1._mockable.createNowTimestamp(),
762
+ status: "finished",
763
+ documents: [
764
+ { action: "merge", priority: "normal", dstPath: "path1/doc1", journalEntries: [zeroJournalEntry] },
765
+ ],
766
+ },
767
+ ];
768
+ await (0, index_1.onFormSubmit)(event);
769
+ expect(transactionGetMock).toHaveBeenCalledTimes(1);
770
+ expect(transactionGetMock).toHaveBeenCalledWith(docRef);
771
+ expect(transactionSetMock).not.toHaveBeenCalled();
772
+ expect(transactionUpdateMock).toHaveBeenCalledTimes(3);
773
+ expect(transactionUpdateMock).toHaveBeenNthCalledWith(1, docRef, { "@forDeletionLater": true });
774
+ expect(transactionUpdateMock).toHaveBeenNthCalledWith(2, docRef, { "@forDeletionLater": FieldValue.delete() });
775
+ expect(transactionUpdateMock).toHaveBeenNthCalledWith(3, docRef, { "@forDeletionLater": FieldValue.delete() });
776
+ const errorMock = jest.spyOn(global, "Error")
777
+ .mockImplementation();
778
+ transactionGetMock.mockRestore();
779
+ transactionSetMock.mockRestore();
780
+ transactionUpdateMock.mockRestore();
781
+ transactionGetMock.mockResolvedValueOnce({
782
+ data: () => ({
783
+ "totalTodos": 2,
784
+ "notStartedCount": 0,
785
+ "inProgressCount": 2,
786
+ }),
787
+ });
788
+ const changeStatusJournalEntry = {
789
+ date: index_1._mockable.createNowTimestamp(),
790
+ ledgerEntries: [
791
+ {
792
+ account: "notStartedCount",
793
+ debit: 1,
794
+ credit: 0,
795
+ },
796
+ {
797
+ account: "inProgressCount",
798
+ debit: 0,
799
+ credit: 1,
800
+ },
801
+ ],
802
+ equation: equation,
803
+ };
804
+ logicResults = [
805
+ {
806
+ name: "logic 1",
807
+ timeFinished: index_1._mockable.createNowTimestamp(),
808
+ status: "finished",
809
+ documents: [
810
+ { action: "merge", priority: "normal", dstPath: "path1/doc1", journalEntries: [changeStatusJournalEntry] },
811
+ ],
812
+ },
813
+ ];
814
+ await (0, index_1.onFormSubmit)(event);
815
+ expect(transactionGetMock).toHaveBeenCalledTimes(1);
816
+ expect(transactionGetMock).toHaveBeenCalledWith(docRef);
817
+ expect(transactionSetMock).not.toHaveBeenCalled();
818
+ expect(transactionUpdateMock).toHaveBeenCalledTimes(1);
819
+ expect(transactionUpdateMock).toHaveBeenCalledWith(docRef, { "@forDeletionLater": true });
820
+ expect(errorMock).toHaveBeenCalledTimes(1);
821
+ expect(errorMock).toHaveBeenCalledWith("Account value cannot be negative");
822
+ transactionGetMock.mockRestore();
823
+ transactionSetMock.mockRestore();
824
+ transactionUpdateMock.mockRestore();
825
+ transactionGetMock.mockResolvedValueOnce({
826
+ data: () => ({
827
+ "totalTodos": 2,
828
+ "notStartedCount": 1,
829
+ "inProgressCount": 1,
830
+ "doneCount": 0,
831
+ }),
832
+ });
833
+ logicResults = [
834
+ {
835
+ name: "logic 1",
836
+ timeFinished: index_1._mockable.createNowTimestamp(),
837
+ status: "finished",
838
+ documents: [
839
+ { action: "merge", priority: "normal", dstPath: "path1/doc1", journalEntries: [recordedJournalEntry] },
840
+ ],
841
+ },
842
+ ];
843
+ await (0, index_1.onFormSubmit)(event);
844
+ expect(transactionGetMock).toHaveBeenCalledTimes(1);
845
+ expect(transactionGetMock).toHaveBeenCalledWith(docRef);
846
+ expect(transactionUpdateMock).toHaveBeenCalledTimes(3);
847
+ expect(transactionUpdateMock).toHaveBeenNthCalledWith(1, docRef, { "@forDeletionLater": true });
848
+ expect(transactionUpdateMock).toHaveBeenNthCalledWith(2, docRef, {
849
+ "inProgressCount": 0,
850
+ "@forDeletionLater": FieldValue.delete(),
851
+ });
852
+ expect(transactionUpdateMock).toHaveBeenNthCalledWith(3, docRef, {
853
+ "doneCount": 1,
854
+ "@forDeletionLater": FieldValue.delete(),
855
+ });
856
+ expect(transactionSetMock).toHaveBeenCalledTimes(2);
857
+ expect(transactionSetMock).toHaveBeenNthCalledWith(1, index_1.db.doc("path/doc1/@ledgers/doc100"), {
858
+ "journalEntryId": "doc10",
859
+ "account": "inProgressCount",
860
+ "debit": 1,
861
+ "credit": 0,
862
+ });
863
+ expect(transactionSetMock).toHaveBeenNthCalledWith(2, index_1.db.doc("path/doc1/@ledgers/doc101"), {
864
+ "journalEntryId": "doc10",
865
+ "account": "doneCount",
866
+ "debit": 0,
867
+ "credit": 1,
868
+ });
869
+ });
505
870
  it("should execute the sequence of operations correctly", async () => {
871
+ refUpdateMock.mockRestore();
872
+ setMock.mockRestore();
873
+ transactionSetMock.mockRestore();
874
+ transactionUpdateMock.mockRestore();
506
875
  jest.spyOn(indexutils, "validateForm").mockResolvedValue([false, {}]);
507
876
  jest.spyOn(indexutils, "getFormModifiedFields").mockReturnValue({ "field1": "value1", "field2": "value2" });
508
877
  jest.spyOn(indexutils, "getSecurityFn").mockReturnValue(() => Promise.resolve({ status: "allowed" }));
@@ -512,7 +881,7 @@ describe("onFormSubmit", () => {
512
881
  jest.spyOn(viewLogics, "queueRunViewLogics").mockResolvedValue();
513
882
  jest.spyOn(distribution, "convertInstructionsToDbValues").mockReturnValue({
514
883
  updateData: {
515
- transactions: admin.firestore.FieldValue.increment(-1),
884
+ transactions: FieldValue.increment(-1),
516
885
  },
517
886
  removeData: {},
518
887
  });
@@ -613,6 +982,37 @@ describe("onFormSubmit", () => {
613
982
  priority: "low",
614
983
  },
615
984
  ];
985
+ const recordedJournalEntry = {
986
+ date: index_1._mockable.createNowTimestamp(),
987
+ ledgerEntries: [
988
+ {
989
+ account: "inProgressCount",
990
+ debit: 1,
991
+ credit: 0,
992
+ },
993
+ {
994
+ account: "doneCount",
995
+ debit: 0,
996
+ credit: 1,
997
+ },
998
+ ],
999
+ equation: equation,
1000
+ recordEntry: true,
1001
+ };
1002
+ const journalDocs = [
1003
+ {
1004
+ action: "merge",
1005
+ priority: "normal",
1006
+ dstPath: "journal/doc1",
1007
+ journalEntries: [recordedJournalEntry, journalEntry],
1008
+ },
1009
+ {
1010
+ action: "merge",
1011
+ priority: "normal",
1012
+ dstPath: "journal/doc2",
1013
+ journalEntries: [journalEntry],
1014
+ },
1015
+ ];
616
1016
  const logicResults = [
617
1017
  {
618
1018
  name: "testLogic",
@@ -630,6 +1030,12 @@ describe("onFormSubmit", () => {
630
1030
  timeFinished: index_1._mockable.createNowTimestamp(),
631
1031
  documents: [...transactionalDocs],
632
1032
  transactional: true,
1033
+ }, {
1034
+ name: "journalLogic",
1035
+ status: "finished",
1036
+ timeFinished: index_1._mockable.createNowTimestamp(),
1037
+ documents: [...journalDocs],
1038
+ transactional: true,
633
1039
  },
634
1040
  ];
635
1041
  const runBusinessLogicsSpy = jest.spyOn(indexutils, "runBusinessLogics").mockImplementation(async (actionRef, action, distributeFn) => {
@@ -653,6 +1059,7 @@ describe("onFormSubmit", () => {
653
1059
  const lowPriorityDstPathLogicDocsMap = await (0, index_utils_1.expandConsolidateAndGroupByDstPath)(lowPriorityDocs);
654
1060
  const { docsByDocPath: lowPriorityDocsByDocPath, otherDocsByDocPath: lowPriorityOtherDocsByDocPath, } = (0, index_utils_1.groupDocsByTargetDocPath)(lowPriorityDstPathLogicDocsMap, docPath);
655
1061
  const transactionalDstPathLogicDocsMap = await (0, index_utils_1.expandConsolidateAndGroupByDstPath)(transactionalDocs);
1062
+ const journalDstPathLogicDocsMap = await (0, index_utils_1.expandConsolidateAndGroupByDstPath)(journalDocs);
656
1063
  const viewLogicResults = [{
657
1064
  name: "User ViewLogic",
658
1065
  status: "finished",
@@ -660,6 +1067,7 @@ describe("onFormSubmit", () => {
660
1067
  documents: logicResults.map((result) => result.documents).flat(),
661
1068
  }];
662
1069
  jest.spyOn(indexutils, "expandConsolidateAndGroupByDstPath")
1070
+ .mockResolvedValueOnce(journalDstPathLogicDocsMap)
663
1071
  .mockResolvedValueOnce(transactionalDstPathLogicDocsMap)
664
1072
  .mockResolvedValueOnce(highPriorityDstPathLogicDocsMap)
665
1073
  .mockResolvedValueOnce(normalPriorityDstPathLogicDocsMap)
@@ -683,29 +1091,32 @@ describe("onFormSubmit", () => {
683
1091
  await (0, index_1.onFormSubmit)(event);
684
1092
  // Test that the runBusinessLogics function was called with the correct parameters
685
1093
  expect(runBusinessLogicsSpy).toHaveBeenCalled();
686
- expect(docMock.set).toHaveBeenCalledTimes(15);
1094
+ expect(setMock).toHaveBeenCalledTimes(18);
687
1095
  expect(refMock.update).toHaveBeenCalledTimes(3);
688
1096
  expect(refMock.update).toHaveBeenNthCalledWith(1, { "@status": "processing" });
689
1097
  expect(refMock.update).toHaveBeenNthCalledWith(2, { "@status": "submitted" });
690
1098
  expect(refMock.update).toHaveBeenNthCalledWith(3, { "@status": "finished" });
691
1099
  // Test that the functions are called in the correct sequence
692
- expect(indexutils.expandConsolidateAndGroupByDstPath).toHaveBeenNthCalledWith(1, transactionalDocs);
693
- expect(transactionMock.set).toHaveBeenCalledTimes(1);
694
- expect(transactionMock.update).toHaveBeenCalledTimes(2);
1100
+ expect(indexutils.expandConsolidateAndGroupByDstPath).toHaveBeenNthCalledWith(1, journalDocs);
1101
+ console.debug("set", transactionSetMock.mock.calls);
1102
+ console.debug("update", transactionUpdateMock.mock.calls);
1103
+ expect(transactionMock.set).toHaveBeenCalledTimes(3);
1104
+ expect(transactionMock.update).toHaveBeenCalledTimes(11);
1105
+ expect(indexutils.expandConsolidateAndGroupByDstPath).toHaveBeenNthCalledWith(2, transactionalDocs);
695
1106
  expect(transactionMock.delete).toHaveBeenCalledTimes(1);
696
- expect(indexutils.expandConsolidateAndGroupByDstPath).toHaveBeenNthCalledWith(2, highPriorityDocs);
1107
+ expect(indexutils.expandConsolidateAndGroupByDstPath).toHaveBeenNthCalledWith(3, highPriorityDocs);
697
1108
  expect(indexutils.groupDocsByTargetDocPath).toHaveBeenNthCalledWith(1, highPriorityDstPathLogicDocsMap, docPath);
698
1109
  expect(indexutils.distribute).toHaveBeenNthCalledWith(1, highPriorityDocsByDocPath);
699
1110
  expect(indexutils.distribute).toHaveBeenNthCalledWith(2, highPriorityOtherDocsByDocPath);
700
- expect(indexutils.expandConsolidateAndGroupByDstPath).toHaveBeenNthCalledWith(3, [...normalPriorityDocs, ...additionalNormalPriorityDocs]);
1111
+ expect(indexutils.expandConsolidateAndGroupByDstPath).toHaveBeenNthCalledWith(4, [...normalPriorityDocs, ...additionalNormalPriorityDocs]);
701
1112
  expect(indexutils.groupDocsByTargetDocPath).toHaveBeenNthCalledWith(2, normalPriorityDstPathLogicDocsMap, docPath);
702
1113
  expect(indexutils.distribute).toHaveBeenNthCalledWith(3, normalPriorityDocsByDocPath);
703
1114
  expect(indexutils.distributeLater).toHaveBeenNthCalledWith(1, normalPriorityOtherDocsByDocPath);
704
- expect(indexutils.expandConsolidateAndGroupByDstPath).toHaveBeenNthCalledWith(4, lowPriorityDocs);
1115
+ expect(indexutils.expandConsolidateAndGroupByDstPath).toHaveBeenNthCalledWith(5, lowPriorityDocs);
705
1116
  expect(indexutils.groupDocsByTargetDocPath).toHaveBeenNthCalledWith(3, lowPriorityDstPathLogicDocsMap, docPath);
706
1117
  expect(indexutils.distributeLater).toHaveBeenNthCalledWith(2, lowPriorityDocsByDocPath);
707
1118
  expect(indexutils.distributeLater).toHaveBeenNthCalledWith(3, lowPriorityOtherDocsByDocPath);
708
- expect(indexutils.expandConsolidateAndGroupByDstPath).toHaveBeenCalledTimes(4);
1119
+ expect(indexutils.expandConsolidateAndGroupByDstPath).toHaveBeenCalledTimes(5);
709
1120
  expect(updateMock).toHaveBeenCalledTimes(1);
710
1121
  expect(updateMock.mock.calls[0][0]).toEqual({ status: "finished" });
711
1122
  });