Skip to content

Commit

Permalink
V1.2.31 - Beginnings of Rollup Logger framework, massive refactor (#129)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jamessimone authored Jun 29, 2021
1 parent e9aef85 commit 59ecc3d
Show file tree
Hide file tree
Showing 36 changed files with 2,412 additions and 1,108 deletions.
15 changes: 13 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ jobs:
- name: 'Run LWC Unit Tests'
run: npm run test:lwc

- name: 'Upload code coverage for LWC to Codecov.io'
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: LWC

- name: 'Delete LWC test files after codecov upload'
run: |
rm coverage/ -rf
# Install Salesforce CLI
- name: Install Salesforce CLI
run: |
Expand All @@ -74,11 +84,12 @@ jobs:
shell: pwsh
run: '. ./scripts/test.ps1'

# Upload code coverage data
- name: 'Upload code coverage for Apex to Codecov.io'
# Upload Apex code coverage data
- name: 'Upload Apex code coverage for Apex to Codecov.io'
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: Apex

# Only create new package versions if a PR is pointed to main or we are merging to main
- name: 'Package & Promote'
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ debug.log
DEVHUB_SFDX_URL.txt
PACKAGING_SFDX_URL.txt
tests/apex
main/default/
main/default/
coverage/
54 changes: 38 additions & 16 deletions README.md

Large diffs are not rendered by default.

55 changes: 55 additions & 0 deletions extra-tests/classes/InvocableDrivenTests.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
@isTest
private class InvocableDrivenTests {
// Driven by extra-tests/flows/Rollup_Integration_Multiple_Deferred_Case_Rollups.flow-meta.xml

@TestSetup
static void setup() {
upsert new RollupSettings__c(IsEnabled__c = true);
Account acc = new Account(Name = 'InvocableDrivenRollupTests');
insert acc;
}

@isTest
static void shouldRollupMultipleDMLStatementsWithinSingleTransaction() {
Account acc = [SELECT Id FROM Account];
Account reparentAccount = new Account(Name = 'Reparent');
insert reparentAccount;

Date today = System.today();

Case one = new Case(Amount__c = 1, AccountId = acc.Id, Description = 'distinct', Subject = 'One', DateField__c = today.addDays(-2));
Case two = new Case(Amount__c = 2, AccountId = acc.Id, Description = 'again', Subject = 'Two', DateField__c = today);
Case three = new Case(Amount__c = 0, AccountId = reparentAccount.Id, Description = 'something else', Subject = 'Three');
Case four = new Case(Amount__c = 0, AccountId = reparentAccount.Id, Description = one.Description, Subject = 'Four');

Test.startTest();
insert new List<Case>{ one, two, three, four };

one.Amount__c = 2;
one.AccountId = reparentAccount.Id;
update one;

// Trigger recursive update after reparenting
// this is important because it not only validates that the recursion
// detection is working properly, but also because it validates that the
// recursion detection is necessary to calculate the results properly!
one.Subject = 'Z';
update one;
Test.stopTest();

acc = [SELECT Id, Description, AnnualRevenue, Name, NumberOfEmployees, DateField__c FROM Account WHERE Id = :acc.Id];
reparentAccount = [SELECT Id, Description, AnnualRevenue, Name, NumberOfEmployees, DateField__c FROM Account WHERE Id = :reparentAccount.Id];

System.assertEquals(today, acc.DateField__c, 'LAST should have been updated to new last');
System.assertEquals(2, acc.AnnualRevenue, 'First account sum field should be decremented on reparent');
System.assertEquals(two.Description, acc.Description, 'CONCAT_DISTINCT should remove extra text on reparent');
System.assertEquals(1, acc.NumberOfEmployees);
System.assertEquals(two.Subject, acc.Name);

System.assertEquals(today.addDays(-2), reparentAccount.DateField__c);
System.assertEquals(3, reparentAccount.NumberOfEmployees, 'Second account should properly reflect reparented record for number of employees');
System.assertEquals(one.Description + ', ' + three.Description, reparentAccount.Description, 'Second account should have only reparented case description');
System.assertEquals(one.Subject, reparentAccount.Name, 'Second account name field should reflect last subject');
System.assertEquals(2, reparentAccount.AnnualRevenue, 'Second account sum field should include updated amount');
}
}
5 changes: 5 additions & 0 deletions extra-tests/classes/InvocableDrivenTests.cls-meta.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>52.0</apiVersion>
<status>Active</status>
</ApexClass>
7 changes: 2 additions & 5 deletions extra-tests/classes/RollupIntegrationTests.cls
Original file line number Diff line number Diff line change
Expand Up @@ -632,11 +632,7 @@ private class RollupIntegrationTests {
@isTest
static void shouldNotBlowUpForRecursiveCheckOnFormulaFields() {
String oppId = RollupTestUtils.createId(Opportunity.SObjectType);
Opportunity opp = new Opportunity(
Amount = 15,
AccountId = RollupTestUtils.createId(Account.SObjectType),
Id = oppId
);
Opportunity opp = new Opportunity(Amount = 15, AccountId = RollupTestUtils.createId(Account.SObjectType), Id = oppId);
List<Opportunity> opps = new List<Opportunity>{ opp };
Formula.recalculateFormulas(opps); // sets the AmountFormula__c field on the opp

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

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

RollupEvaluator.stubRequestId = 'somethingElse';
// re-initialize to trigger recursion detection
eval = RollupEvaluator.getEvaluator(
null,
Expand Down
Loading

0 comments on commit 59ecc3d

Please sign in to comment.