Skip to content

Commit daf14e9

Browse files
authored
Improved Testability of Queries (#813)
* Added a new class LoggerConfigurationSelector to centralize accessing & mocking custom metadata type records - now Nebula Logger will only use mock CMDT records within its own tests (existing behavior), and to load the org's actual CMDT records during customer tests (changed behavior) * Tweaked how records are queried & converted to the inner classes in LoggerSObjectProxy to provide more flexibility + better code coverage * Made additional improvements to the tests for LoggerEngineDataSelector and LogManagementDataSelector to improve testing + test coverage, even when some features are not available (e.g., Network/Experience Cloud, OmniProcess/OmniStudio, etc.) * Scope creep: added explicit access for the Visualforce page LogMassDelete to the 3 permission sets LoggerAdmin, LoggerLogViewer, and LoggerEndUser * Fixed some test failures in the async-failure & big-object plugins and extra-tests, caused by the changes to how CMDT records are now loaded in core during tests * Updated build.yml to use new --concise flag when validating the core metadata in scratch orgs * Changed build.yml to use the base scratch org for codecov.io integration, since this org will have the lowest code coverage of any of the scratch orgs * Updated package.json + build.yml to auto-generate a new core.package.xml manifest file for the core package's metadata, for teams that utilize manifest files in their deployment/devops processes * Added some sample CMDT records to extra-tests so that the pipeline can validate that the records are returned by the query selector classes * Upgraded several dev dependencies in package.json
1 parent b5ac18e commit daf14e9

File tree

98 files changed

+11314
-7238
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+11314
-7238
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.github/
22
.husky/
3+
.sf/
34
.sfdx/
45
.vscode/
56
temp/

.github/codecov.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,19 @@ coverage:
22
status:
33
project:
44
default:
5-
target: 90
5+
target: 90%
66
threshold: 2%
77
if_ci_failed: success
8+
Apex:
9+
target: 90%
10+
flags:
11+
- Apex
12+
# LWC code coverage needs to be improved overall,
13+
# but for now, the threshold is lowered in Codecov.io
14+
LWC:
15+
target: 85%
16+
flags:
17+
- LWC
818
patch: off
919
ignore:
1020
- 'config/experience-cloud/**/*'

.github/workflows/build.yml

Lines changed: 144 additions & 62 deletions
Large diffs are not rendered by default.

.husky/pre-commit

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
#!/bin/sh
2-
. "$(dirname "$0")/_/husky.sh"
3-
41
npm run husky:pre-commit

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55

66
The most robust observability solution for Salesforce experts. Built 100% natively on the platform, and designed to work seamlessly with Apex, Lightning Components, Flow, OmniStudio, and integrations.
77

8-
## Unlocked Package - v4.15.2
8+
## Unlocked Package - v4.15.3
99

10-
[![Install Unlocked Package in a Sandbox](./images/btn-install-unlocked-package-sandbox.png)](https://test.salesforce.com/packaging/installPackage.apexp?p0=04t5Y0000015oifQAA)
11-
[![Install Unlocked Package in Production](./images/btn-install-unlocked-package-production.png)](https://login.salesforce.com/packaging/installPackage.apexp?p0=04t5Y0000015oifQAA)
10+
[![Install Unlocked Package in a Sandbox](./images/btn-install-unlocked-package-sandbox.png)](https://test.salesforce.com/packaging/installPackage.apexp?p0=04t5Y0000015ok2QAA)
11+
[![Install Unlocked Package in Production](./images/btn-install-unlocked-package-production.png)](https://login.salesforce.com/packaging/installPackage.apexp?p0=04t5Y0000015ok2QAA)
1212
[![View Documentation](./images/btn-view-documentation.png)](https://github.com/jongpie/NebulaLogger/wiki)
1313

14-
`sf package install --wait 20 --security-type AdminsOnly --package 04t5Y0000015oifQAA`
14+
`sf package install --wait 20 --security-type AdminsOnly --package 04t5Y0000015ok2QAA`
1515

1616
---
1717

config/linters/lint-staged.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module.exports = {
22
'sfdx-project.json': () => {
33
return `npm run package:version:number:fix`;
44
},
5-
'*.{apex,cls,cmp,component,css,html,js,json,md,page,trigger,xml,yaml,yml}': filenames => filenames.map(filename => `prettier --write '${filename}'`),
5+
'*.{apex,cls,cmp,component,css,html,js,json,md,page,trigger,yaml,yml}': filenames => filenames.map(filename => `prettier --write '${filename}'`),
66
'**/lwc/**': filenames => {
77
return [`eslint --config ./config/linters/.eslintrc.json ${filenames.join(' ')} --fix`];
88
// FIXME this command should only run tests for the changed LWCs (instead of running tests for all LWCs)

docs/apex/Configuration/LoggerCache.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ layout: default
44

55
## LoggerCache class
66

7-
Class used to cache query results returned by the selector classes
7+
Class used to cache query results & data used in other parts of Nebula Logger
88

99
---
1010

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
---
2+
layout: default
3+
---
4+
5+
## LoggerConfigurationSelector class
6+
7+
Selector class used for all queries that are specific to the configuration layer.
8+
9+
---
10+
11+
### Methods
12+
13+
#### `getInstance()``LoggerConfigurationSelector`
14+
15+
The instance of `LoggerConfigurationSelector` used for any querying specific to the configuration layer
16+
17+
##### Return
18+
19+
**Type**
20+
21+
LoggerConfigurationSelector
22+
23+
**Description**
24+
25+
The singleton instance of `LoggerConfigurationSelector`
26+
27+
#### `getLogEntryDataMaskRules()``List<LogEntryDataMaskRule_t>`
28+
29+
Returns the `LogEntryDataMaskRule_t` records in the org.
30+
31+
##### Return
32+
33+
**Type**
34+
35+
List&lt;LogEntryDataMaskRule_t&gt;
36+
37+
**Description**
38+
39+
`List&lt;LogEntryDataMaskRule_t&gt;` containing records in the org
40+
41+
#### `getLogEntryTagRules()``List<LogEntryTagRule_t>`
42+
43+
Returns the enabled `LogEntryTagRule_t` records in the org, including the field `SObjectField__r.QualifiedApiName` that cannot be accessed via `LogEntryTagRule_t.getAll()`. The value of `SObjectField__c` is automatically set to the value of `SObjectField__r.QualifiedApiName`
44+
45+
##### Return
46+
47+
**Type**
48+
49+
List&lt;LogEntryTagRule_t&gt;
50+
51+
**Description**
52+
53+
`List&lt;LogEntryTagRule_t&gt;` containing enabled records in the org
54+
55+
#### `getLogStatuses()``List<LogStatus_t>`
56+
57+
Returns the `LogStatus_t` records in the org.
58+
59+
##### Return
60+
61+
**Type**
62+
63+
List&lt;LogStatus_t&gt;
64+
65+
**Description**
66+
67+
`List&lt;LogStatus_t&gt;` containing records in the org
68+
69+
#### `getLoggerFieldMappings()``List<LoggerFieldMapping_t>`
70+
71+
Returns the enabled `LoggerFieldMapping_t` records in the org.
72+
73+
##### Return
74+
75+
**Type**
76+
77+
List&lt;LoggerFieldMapping_t&gt;
78+
79+
**Description**
80+
81+
`List&lt;LoggerFieldMapping_t&gt;` containing enabled records in the org
82+
83+
#### `getLoggerParameters()``Map<String, LoggerParameter_t>`
84+
85+
Returns the `LoggerParameter_t` records in the org.
86+
87+
##### Return
88+
89+
**Type**
90+
91+
Map&lt;String, LoggerParameter_t&gt;
92+
93+
**Description**
94+
95+
`List&lt;LoggerParameter_t&gt;` containing records in the org
96+
97+
#### `getLoggerPlugins()``List<LoggerPlugin_t>`
98+
99+
Returns the `LoggerPlugin_t` records in the org.
100+
101+
##### Return
102+
103+
**Type**
104+
105+
List&lt;LoggerPlugin_t&gt;
106+
107+
**Description**
108+
109+
`List&lt;LoggerPlugin_t&gt;` containing records in the org
110+
111+
#### `getLoggerSObjectHandlers()``List<LoggerSObjectHandler_t>`
112+
113+
Returns the `LoggerSObjectHandler_t` records in the org.
114+
115+
##### Return
116+
117+
**Type**
118+
119+
List&lt;LoggerSObjectHandler_t&gt;
120+
121+
**Description**
122+
123+
`List&lt;LoggerSObjectHandler_t&gt;` containing records in the org
124+
125+
#### `getLoggerScenarioRules()``List<LoggerScenarioRule_t>`
126+
127+
Returns the `LoggerScenarioRule_t` records in the org.
128+
129+
##### Return
130+
131+
**Type**
132+
133+
List&lt;LoggerScenarioRule_t&gt;
134+
135+
**Description**
136+
137+
`List&lt;LoggerScenarioRule_t&gt;` containing records in the org
138+
139+
---

docs/apex/Logger-Engine/LogEntryEventBuilder.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ Sets the log entry event&apos;s database operation result fields
167167
##### Parameters
168168

169169
| Param | Description |
170-
|-------------------------|---------------------------------------------------------|
170+
| ----------------------- | ------------------------------------------------------- |
171171
| `emptyRecycleBinResult` | The instance of `Database.EmptyRecycleBinResult` to log |
172172

173173
##### Return
@@ -307,7 +307,7 @@ Sets the log entry event&apos;s database operation result fields
307307
##### Parameters
308308

309309
| Param | Description |
310-
|--------------------------|------------------------------------------------------|
310+
| ------------------------ | ---------------------------------------------------- |
311311
| `emptyRecycleBinResults` | The list of `Database.EmptyRecycleBinResult`s to log |
312312

313313
##### Return

0 commit comments

Comments
 (0)