11 KiB
Sharing Rules — Test Cases
Structured test scenarios for create, edit, and delete operations. Each test case defines an input, the expected behavior, and the expected output.
Create Operations
TC-01: Create a criteria-based sharing rule
Input:
- Object:
Property__c - Rule type: criteria-based
- Share with: role
RegionalManager - Access level: Read
- Criteria:
Status__cequalsActive
Expected behavior:
- Discovers SFDX project path and checks for existing
Property__c.sharingRules-meta.xml - Presents confirmation summary to user and waits for approval
- After confirmation, writes the file
Expected output:
<?xml version="1.0" encoding="UTF-8"?>
<SharingRules xmlns="http://soap.sforce.com/2006/04/metadata">
<sharingCriteriaRules>
<fullName>ShareActivePropertiesWithRegionalManager</fullName>
<accessLevel>Read</accessLevel>
<includeRecordsOwnedByAll>true</includeRecordsOwnedByAll>
<label>Share Active Properties With Regional Manager</label>
<sharedTo>
<role>RegionalManager</role>
</sharedTo>
<criteriaItems>
<field>Status__c</field>
<operation>equals</operation>
<value>Active</value>
</criteriaItems>
</sharingCriteriaRules>
</SharingRules>
TC-02: Create a guest user sharing rule
Input:
- Object:
Listing__c - Rule type: guest
- Share with: guest user with CommunityNickname
PropertySiteGuest - Access level: Read
- Criteria:
Published__cequalstrue
Expected behavior:
- Discovers project path and checks for existing file
- Queries org for guest user nickname if not provided
- Presents confirmation summary and waits for approval
- After confirmation, writes file using
<guestUser>(not<role>or<group>)
Expected output:
<?xml version="1.0" encoding="UTF-8"?>
<SharingRules xmlns="http://soap.sforce.com/2006/04/metadata">
<sharingGuestRules>
<fullName>SharePublishedListingsWithSiteGuest</fullName>
<accessLevel>Read</accessLevel>
<includeHVUOwnedRecords>false</includeHVUOwnedRecords>
<label>Share Published Listings With Site Guest</label>
<sharedTo>
<guestUser>PropertySiteGuest</guestUser>
</sharedTo>
<criteriaItems>
<field>Published__c</field>
<operation>equals</operation>
<value>true</value>
</criteriaItems>
</sharingGuestRules>
</SharingRules>
TC-03: Create an Account owner-based sharing rule
Input:
- Object:
Account - Rule type: owner-based
- Share from: role
SalesDirector - Share to: role and subordinates
SalesTeam - Access level: Edit
Expected behavior:
- Discovers project path, checks for existing Account sharing rules
- Includes
<accountSettings>with all three sub-elements defaulted toNone - Presents confirmation summary and waits for approval
- After confirmation, writes the file
Expected output:
<?xml version="1.0" encoding="UTF-8"?>
<SharingRules xmlns="http://soap.sforce.com/2006/04/metadata">
<sharingOwnerRules>
<fullName>ShareDirectorAccountsWithSalesTeam</fullName>
<accessLevel>Edit</accessLevel>
<accountSettings>
<caseAccessLevel>None</caseAccessLevel>
<contactAccessLevel>None</contactAccessLevel>
<opportunityAccessLevel>None</opportunityAccessLevel>
</accountSettings>
<label>Share Director Accounts With Sales Team</label>
<sharedFrom>
<role>SalesDirector</role>
</sharedFrom>
<sharedTo>
<roleAndSubordinates>SalesTeam</roleAndSubordinates>
</sharedTo>
</sharingOwnerRules>
</SharingRules>
TC-04: Append a rule to an existing file
Input:
- Object:
Property__c(file already exists with TC-01's rule) - Rule type: criteria-based
- Share with: group
AllAgents - Access level: Edit
- Criteria:
Price__cgreaterThan1000000
Expected behavior:
- Reads existing file and finds TC-01's rule already present
- Does not duplicate existing rule
- Presents confirmation showing the new rule will be appended
- After confirmation, appends new rule inside existing
<SharingRules>root
Expected output: File contains both TC-01's rule AND the new rule within the same <SharingRules> element.
Edit Operations
TC-05: Edit access level of an existing rule
Input:
- Object:
Property__c - Target rule:
ShareActivePropertiesWithRegionalManager - Change: access level from
ReadtoEdit
Expected behavior:
- Locates the rule by
<fullName>in the existing file - Presents confirmation showing current vs. proposed change:
Operation: Edit Object:
Property__cRule:ShareActivePropertiesWithRegionalManager(Share Active Properties With Regional Manager) Changes: accessLevel: Read → EditProceed? (yes / no / edit)
- Waits for user confirmation
- After confirmation, modifies only
<accessLevel>— all other elements unchanged
Expected output (changed portion):
<accessLevel>Edit</accessLevel>
All other elements (fullName, label, sharedTo, criteriaItems, includeRecordsOwnedByAll) remain identical.
TC-06: Edit shared-to target of an existing rule
Input:
- Object:
Property__c - Target rule:
ShareActivePropertiesWithRegionalManager - Change: shared-to from role
RegionalManagerto groupPropertyViewers
Expected behavior:
- Locates the rule in the file
- Presents confirmation showing:
Changes: sharedTo: role
RegionalManager→ groupPropertyViewers - Waits for confirmation
- Replaces
<sharedTo>content only
Expected output (changed portion):
<sharedTo>
<group>PropertyViewers</group>
</sharedTo>
TC-07: Edit criteria of an existing rule
Input:
- Object:
Property__c - Target rule:
ShareActivePropertiesWithRegionalManager - Change: update criteria from
Status__c equals ActivetoStatus__c equals ActiveANDRegion__c equals West
Expected behavior:
- Locates the rule in the file
- Presents confirmation showing current criteria vs. proposed criteria
- Waits for confirmation
- Replaces
<criteriaItems>elements
Expected output (changed portion):
<criteriaItems>
<field>Status__c</field>
<operation>equals</operation>
<value>Active</value>
</criteriaItems>
<criteriaItems>
<field>Region__c</field>
<operation>equals</operation>
<value>West</value>
</criteriaItems>
TC-08: Edit attempt on non-existent rule
Input:
- Object:
Property__c - Target rule:
NonExistentRule - Change: access level to
Edit
Expected behavior:
- Searches for the rule by
<fullName>in the file - Rule not found — reports error to user
- Suggests listing available rules in the file and asks user to clarify
Expected output: No file changes. Error message listing available rule names in the file.
Delete Operations
TC-09: Delete a single rule (other rules remain)
Input:
- Object:
Property__c(file contains 2 rules) - Delete rule:
ShareActivePropertiesWithRegionalManager
Expected behavior:
- Locates the rule in the file
- Presents confirmation:
Operation: Delete Object:
Property__cRule:ShareActivePropertiesWithRegionalManager(Share Active Properties With Regional Manager) Changes: Remove this criteria-based sharing rule entirely. 1 other rule(s) will remain in the file.Proceed? (yes / no / edit)
- Waits for confirmation
- Removes the entire
<sharingCriteriaRules>block for that rule - Other rules in the file remain intact
Expected output: File retains <SharingRules> root and all other rules, with the deleted rule's block completely removed.
TC-10: Delete the last rule in a file
Input:
- Object:
Listing__c(file contains only 1 rule) - Delete rule:
SharePublishedListingsWithSiteGuest
Expected behavior:
- Locates the rule — confirms it is the only rule in the file
- Presents confirmation warning that the entire file will be removed:
Operation: Delete Object:
Listing__cRule:SharePublishedListingsWithSiteGuest(Share Published Listings With Site Guest) Changes: Remove this guest sharing rule. This is the last rule — the entire fileListing__c.sharingRules-meta.xmlwill be deleted.Proceed? (yes / no / edit)
- Waits for confirmation
- Deletes the entire file
Expected output: File Listing__c.sharingRules-meta.xml no longer exists.
TC-11: Delete with user declining confirmation
Input:
- Object:
Account - Delete rule:
ShareDirectorAccountsWithSalesTeam - User response to confirmation: "no"
Expected behavior:
- Locates the rule
- Presents confirmation
- User says "no"
- Aborts — no changes written
Expected output: No file changes. Acknowledgment that the operation was cancelled.
TC-12: Delete attempt on non-existent rule
Input:
- Object:
Property__c - Delete rule:
RuleThatDoesNotExist
Expected behavior:
- Searches for the rule by
<fullName>in the file - Rule not found — reports error
- Lists available rules and asks user to clarify
Expected output: No file changes. Error message listing available rule names.
Confirmation Flow Tests
TC-13: User confirms with "yes"
Input: Any create/edit/delete operation where user responds "yes" to confirmation.
Expected behavior: Changes are written to disk as presented in the summary.
TC-14: User responds with "edit" and provides feedback
Input:
- Create operation for a criteria rule
- User responds "edit" to confirmation with: "Change the access level to Edit instead of Read"
Expected behavior:
- Original summary presented
- User says "edit" with feedback
- Incorporates feedback (changes
accessLeveltoEdit) - Re-presents updated summary
- Waits for new confirmation before writing
TC-15: User declines with "no"
Input: Any create/edit/delete operation where user responds "no" to confirmation.
Expected behavior: No file changes. Operation aborted with acknowledgment.
Edge Cases
TC-16: Edit that would change rule type
Input:
- Object:
Property__c - Target rule:
ShareActivePropertiesWithRegionalManager(criteria rule) - Change: convert to owner-based rule
Expected behavior:
- Detects that the change would alter the rule type
- Informs user this is not supported as an edit
- Suggests: delete the existing rule and create a new one with the desired type
Expected output: No file changes. Guidance to user about delete + create workflow.
TC-17: Create rule with duplicate fullName
Input:
- Object:
Property__c(file already contains ruleShareActivePropertiesWithRegionalManager) - Create a new rule also named
ShareActivePropertiesWithRegionalManager
Expected behavior:
- Reads existing file, finds duplicate
<fullName> - Informs user of the conflict
- Suggests an alternative name or asks user to choose
Expected output: No file changes until conflict is resolved.