Skip to content

Commit 59ecc3d

Browse files
authored
V1.2.31 - Beginnings of Rollup Logger framework, massive refactor (#129)
* Start of work on #68 - begin to flesh out Rollup Logger plugin, with beginning options for Nebula Logger and simple logging framework * Fixes #125 by making the date/time/datetime comparisons as safe as possible * Fix CONCAT issue reported by Katherine West * Fixing RollupLogger instance lazy loading * Start of work to reproduce issues with multiple DML statements in the same transaction on objects with deferred Rollup actions called from Flow * Adding LWC coverage to deployment pipeline * Aligning flow engine, DLRS migration script, and LWC for Rollup Recalc App to use the same field labels/positions * Fix two straggler issues from invocable refactor - ensure grouped invocable rollups don't add the same item twice, and ensure count-based rollups properly set the recalculated value prior to returning it * Fixing issue with map key for CACHED_ROLLUPS + invocables. Bumped beta package version and beta links * Rollup class minimization (#128) * break apart mono-Rollup class * Last (?) of improvements to recursion detection after adding recursive updates to Flow integration test in extra-tests/InvocableDrivenTests.cls. Because of the way that flow alternately boxcars/queues up different updates, it's doubly important here to make sure that the records are passing through in the right order to properly trigger detection on events like reparenting AND prevent recursive updates from running unless there's been a definitive change to the calc item/rollup operation in question * Properly calculate parent items with more than 2000 child records in RollupFullBatchRecalculator * Pinned to specific LWC jest version to avoid API version issue with VS Code test runner, added test coverage for LWC and added missing RollupLogger coverage * Bumping package version from Github Action
1 parent e9aef85 commit 59ecc3d

36 files changed

+2412
-1108
lines changed

.github/workflows/deploy.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,16 @@ jobs:
5252
- name: 'Run LWC Unit Tests'
5353
run: npm run test:lwc
5454

55+
- name: 'Upload code coverage for LWC to Codecov.io'
56+
uses: codecov/codecov-action@v1
57+
with:
58+
token: ${{ secrets.CODECOV_TOKEN }}
59+
flags: LWC
60+
61+
- name: 'Delete LWC test files after codecov upload'
62+
run: |
63+
rm coverage/ -rf
64+
5565
# Install Salesforce CLI
5666
- name: Install Salesforce CLI
5767
run: |
@@ -74,11 +84,12 @@ jobs:
7484
shell: pwsh
7585
run: '. ./scripts/test.ps1'
7686

77-
# Upload code coverage data
78-
- name: 'Upload code coverage for Apex to Codecov.io'
87+
# Upload Apex code coverage data
88+
- name: 'Upload Apex code coverage for Apex to Codecov.io'
7989
uses: codecov/codecov-action@v1
8090
with:
8191
token: ${{ secrets.CODECOV_TOKEN }}
92+
flags: Apex
8293

8394
# Only create new package versions if a PR is pointed to main or we are merging to main
8495
- name: 'Package & Promote'

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ debug.log
88
DEVHUB_SFDX_URL.txt
99
PACKAGING_SFDX_URL.txt
1010
tests/apex
11-
main/default/
11+
main/default/
12+
coverage/

README.md

Lines changed: 38 additions & 16 deletions
Large diffs are not rendered by default.
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
@isTest
2+
private class InvocableDrivenTests {
3+
// Driven by extra-tests/flows/Rollup_Integration_Multiple_Deferred_Case_Rollups.flow-meta.xml
4+
5+
@TestSetup
6+
static void setup() {
7+
upsert new RollupSettings__c(IsEnabled__c = true);
8+
Account acc = new Account(Name = 'InvocableDrivenRollupTests');
9+
insert acc;
10+
}
11+
12+
@isTest
13+
static void shouldRollupMultipleDMLStatementsWithinSingleTransaction() {
14+
Account acc = [SELECT Id FROM Account];
15+
Account reparentAccount = new Account(Name = 'Reparent');
16+
insert reparentAccount;
17+
18+
Date today = System.today();
19+
20+
Case one = new Case(Amount__c = 1, AccountId = acc.Id, Description = 'distinct', Subject = 'One', DateField__c = today.addDays(-2));
21+
Case two = new Case(Amount__c = 2, AccountId = acc.Id, Description = 'again', Subject = 'Two', DateField__c = today);
22+
Case three = new Case(Amount__c = 0, AccountId = reparentAccount.Id, Description = 'something else', Subject = 'Three');
23+
Case four = new Case(Amount__c = 0, AccountId = reparentAccount.Id, Description = one.Description, Subject = 'Four');
24+
25+
Test.startTest();
26+
insert new List<Case>{ one, two, three, four };
27+
28+
one.Amount__c = 2;
29+
one.AccountId = reparentAccount.Id;
30+
update one;
31+
32+
// Trigger recursive update after reparenting
33+
// this is important because it not only validates that the recursion
34+
// detection is working properly, but also because it validates that the
35+
// recursion detection is necessary to calculate the results properly!
36+
one.Subject = 'Z';
37+
update one;
38+
Test.stopTest();
39+
40+
acc = [SELECT Id, Description, AnnualRevenue, Name, NumberOfEmployees, DateField__c FROM Account WHERE Id = :acc.Id];
41+
reparentAccount = [SELECT Id, Description, AnnualRevenue, Name, NumberOfEmployees, DateField__c FROM Account WHERE Id = :reparentAccount.Id];
42+
43+
System.assertEquals(today, acc.DateField__c, 'LAST should have been updated to new last');
44+
System.assertEquals(2, acc.AnnualRevenue, 'First account sum field should be decremented on reparent');
45+
System.assertEquals(two.Description, acc.Description, 'CONCAT_DISTINCT should remove extra text on reparent');
46+
System.assertEquals(1, acc.NumberOfEmployees);
47+
System.assertEquals(two.Subject, acc.Name);
48+
49+
System.assertEquals(today.addDays(-2), reparentAccount.DateField__c);
50+
System.assertEquals(3, reparentAccount.NumberOfEmployees, 'Second account should properly reflect reparented record for number of employees');
51+
System.assertEquals(one.Description + ', ' + three.Description, reparentAccount.Description, 'Second account should have only reparented case description');
52+
System.assertEquals(one.Subject, reparentAccount.Name, 'Second account name field should reflect last subject');
53+
System.assertEquals(2, reparentAccount.AnnualRevenue, 'Second account sum field should include updated amount');
54+
}
55+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
3+
<apiVersion>52.0</apiVersion>
4+
<status>Active</status>
5+
</ApexClass>

extra-tests/classes/RollupIntegrationTests.cls

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -632,11 +632,7 @@ private class RollupIntegrationTests {
632632
@isTest
633633
static void shouldNotBlowUpForRecursiveCheckOnFormulaFields() {
634634
String oppId = RollupTestUtils.createId(Opportunity.SObjectType);
635-
Opportunity opp = new Opportunity(
636-
Amount = 15,
637-
AccountId = RollupTestUtils.createId(Account.SObjectType),
638-
Id = oppId
639-
);
635+
Opportunity opp = new Opportunity(Amount = 15, AccountId = RollupTestUtils.createId(Account.SObjectType), Id = oppId);
640636
List<Opportunity> opps = new List<Opportunity>{ opp };
641637
Formula.recalculateFormulas(opps); // sets the AmountFormula__c field on the opp
642638

@@ -653,6 +649,7 @@ private class RollupIntegrationTests {
653649

654650
System.assertEquals(true, eval.matches(opp), 'Should match when not recursive');
655651

652+
RollupEvaluator.stubRequestId = 'somethingElse';
656653
// re-initialize to trigger recursion detection
657654
eval = RollupEvaluator.getEvaluator(
658655
null,

0 commit comments

Comments
 (0)