Skip to content

Commit

Permalink
Improved Testability of Queries (#813)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jongpie authored Dec 29, 2024
1 parent b5ac18e commit daf14e9
Show file tree
Hide file tree
Showing 98 changed files with 11,314 additions and 7,238 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.github/
.husky/
.sf/
.sfdx/
.vscode/
temp/
Expand Down
12 changes: 11 additions & 1 deletion .github/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,19 @@ coverage:
status:
project:
default:
target: 90
target: 90%
threshold: 2%
if_ci_failed: success
Apex:
target: 90%
flags:
- Apex
# LWC code coverage needs to be improved overall,
# but for now, the threshold is lowered in Codecov.io
LWC:
target: 85%
flags:
- LWC
patch: off
ignore:
- 'config/experience-cloud/**/*'
Expand Down
206 changes: 144 additions & 62 deletions .github/workflows/build.yml

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run husky:pre-commit
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

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.

## Unlocked Package - v4.15.2
## Unlocked Package - v4.15.3

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

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

---

Expand Down
2 changes: 1 addition & 1 deletion config/linters/lint-staged.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports = {
'sfdx-project.json': () => {
return `npm run package:version:number:fix`;
},
'*.{apex,cls,cmp,component,css,html,js,json,md,page,trigger,xml,yaml,yml}': filenames => filenames.map(filename => `prettier --write '${filename}'`),
'*.{apex,cls,cmp,component,css,html,js,json,md,page,trigger,yaml,yml}': filenames => filenames.map(filename => `prettier --write '${filename}'`),
'**/lwc/**': filenames => {
return [`eslint --config ./config/linters/.eslintrc.json ${filenames.join(' ')} --fix`];
// FIXME this command should only run tests for the changed LWCs (instead of running tests for all LWCs)
Expand Down
2 changes: 1 addition & 1 deletion docs/apex/Configuration/LoggerCache.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ layout: default

## LoggerCache class

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

---

Expand Down
139 changes: 139 additions & 0 deletions docs/apex/Configuration/LoggerConfigurationSelector.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
---
layout: default
---

## LoggerConfigurationSelector class

Selector class used for all queries that are specific to the configuration layer.

---

### Methods

#### `getInstance()``LoggerConfigurationSelector`

The instance of `LoggerConfigurationSelector` used for any querying specific to the configuration layer

##### Return

**Type**

LoggerConfigurationSelector

**Description**

The singleton instance of `LoggerConfigurationSelector`

#### `getLogEntryDataMaskRules()``List<LogEntryDataMaskRule_t>`

Returns the `LogEntryDataMaskRule_t` records in the org.

##### Return

**Type**

List&lt;LogEntryDataMaskRule_t&gt;

**Description**

`List&lt;LogEntryDataMaskRule_t&gt;` containing records in the org

#### `getLogEntryTagRules()``List<LogEntryTagRule_t>`

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`

##### Return

**Type**

List&lt;LogEntryTagRule_t&gt;

**Description**

`List&lt;LogEntryTagRule_t&gt;` containing enabled records in the org

#### `getLogStatuses()``List<LogStatus_t>`

Returns the `LogStatus_t` records in the org.

##### Return

**Type**

List&lt;LogStatus_t&gt;

**Description**

`List&lt;LogStatus_t&gt;` containing records in the org

#### `getLoggerFieldMappings()``List<LoggerFieldMapping_t>`

Returns the enabled `LoggerFieldMapping_t` records in the org.

##### Return

**Type**

List&lt;LoggerFieldMapping_t&gt;

**Description**

`List&lt;LoggerFieldMapping_t&gt;` containing enabled records in the org

#### `getLoggerParameters()``Map<String, LoggerParameter_t>`

Returns the `LoggerParameter_t` records in the org.

##### Return

**Type**

Map&lt;String, LoggerParameter_t&gt;

**Description**

`List&lt;LoggerParameter_t&gt;` containing records in the org

#### `getLoggerPlugins()``List<LoggerPlugin_t>`

Returns the `LoggerPlugin_t` records in the org.

##### Return

**Type**

List&lt;LoggerPlugin_t&gt;

**Description**

`List&lt;LoggerPlugin_t&gt;` containing records in the org

#### `getLoggerSObjectHandlers()``List<LoggerSObjectHandler_t>`

Returns the `LoggerSObjectHandler_t` records in the org.

##### Return

**Type**

List&lt;LoggerSObjectHandler_t&gt;

**Description**

`List&lt;LoggerSObjectHandler_t&gt;` containing records in the org

#### `getLoggerScenarioRules()``List<LoggerScenarioRule_t>`

Returns the `LoggerScenarioRule_t` records in the org.

##### Return

**Type**

List&lt;LoggerScenarioRule_t&gt;

**Description**

`List&lt;LoggerScenarioRule_t&gt;` containing records in the org

---
4 changes: 2 additions & 2 deletions docs/apex/Logger-Engine/LogEntryEventBuilder.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ Sets the log entry event&apos;s database operation result fields
##### Parameters

| Param | Description |
|-------------------------|---------------------------------------------------------|
| ----------------------- | ------------------------------------------------------- |
| `emptyRecycleBinResult` | The instance of `Database.EmptyRecycleBinResult` to log |

##### Return
Expand Down Expand Up @@ -307,7 +307,7 @@ Sets the log entry event&apos;s database operation result fields
##### Parameters

| Param | Description |
|--------------------------|------------------------------------------------------|
| ------------------------ | ---------------------------------------------------- |
| `emptyRecycleBinResults` | The list of `Database.EmptyRecycleBinResult`s to log |

##### Return
Expand Down
Loading

0 comments on commit daf14e9

Please sign in to comment.