scc-universal 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (271) hide show
  1. package/.claude-plugin/plugin.json +44 -0
  2. package/.cursor/agents/deep-researcher.md +142 -0
  3. package/.cursor/agents/doc-updater.md +219 -0
  4. package/.cursor/agents/eval-runner.md +335 -0
  5. package/.cursor/agents/learning-engine.md +210 -0
  6. package/.cursor/agents/loop-operator.md +245 -0
  7. package/.cursor/agents/refactor-cleaner.md +119 -0
  8. package/.cursor/agents/sf-admin-agent.md +127 -0
  9. package/.cursor/agents/sf-agentforce-agent.md +126 -0
  10. package/.cursor/agents/sf-apex-agent.md +117 -0
  11. package/.cursor/agents/sf-architect.md +426 -0
  12. package/.cursor/agents/sf-aura-reviewer.md +369 -0
  13. package/.cursor/agents/sf-bugfix-agent.md +101 -0
  14. package/.cursor/agents/sf-flow-agent.md +155 -0
  15. package/.cursor/agents/sf-integration-agent.md +141 -0
  16. package/.cursor/agents/sf-lwc-agent.md +123 -0
  17. package/.cursor/agents/sf-review-agent.md +357 -0
  18. package/.cursor/agents/sf-visualforce-reviewer.md +465 -0
  19. package/.cursor/hooks/adapter.js +81 -0
  20. package/.cursor/hooks/after-file-edit.js +26 -0
  21. package/.cursor/hooks/after-mcp-execution.js +12 -0
  22. package/.cursor/hooks/after-shell-execution.js +30 -0
  23. package/.cursor/hooks/after-tab-file-edit.js +12 -0
  24. package/.cursor/hooks/before-mcp-execution.js +11 -0
  25. package/.cursor/hooks/before-read-file.js +13 -0
  26. package/.cursor/hooks/before-shell-execution.js +29 -0
  27. package/.cursor/hooks/before-submit-prompt.js +23 -0
  28. package/.cursor/hooks/pre-compact.js +7 -0
  29. package/.cursor/hooks/session-end.js +10 -0
  30. package/.cursor/hooks/session-start.js +10 -0
  31. package/.cursor/hooks/stop.js +18 -0
  32. package/.cursor/hooks/subagent-start.js +10 -0
  33. package/.cursor/hooks/subagent-stop.js +10 -0
  34. package/.cursor/hooks.json +107 -0
  35. package/.cursor/skills/aside/SKILL.md +115 -0
  36. package/.cursor/skills/checkpoint/SKILL.md +50 -0
  37. package/.cursor/skills/configure-scc/SKILL.md +160 -0
  38. package/.cursor/skills/continuous-agent-loop/SKILL.md +260 -0
  39. package/.cursor/skills/mcp-server-patterns/SKILL.md +142 -0
  40. package/.cursor/skills/model-route/SKILL.md +81 -0
  41. package/.cursor/skills/prompt-optimizer/SKILL.md +366 -0
  42. package/.cursor/skills/refactor-clean/SKILL.md +133 -0
  43. package/.cursor/skills/resume-session/SKILL.md +111 -0
  44. package/.cursor/skills/save-session/SKILL.md +183 -0
  45. package/.cursor/skills/search-first/SKILL.md +140 -0
  46. package/.cursor/skills/security-scan/SKILL.md +142 -0
  47. package/.cursor/skills/sessions/SKILL.md +124 -0
  48. package/.cursor/skills/sf-agentforce-development/SKILL.md +449 -0
  49. package/.cursor/skills/sf-apex-async-patterns/SKILL.md +324 -0
  50. package/.cursor/skills/sf-apex-best-practices/SKILL.md +421 -0
  51. package/.cursor/skills/sf-apex-constraints/SKILL.md +79 -0
  52. package/.cursor/skills/sf-apex-cursor/SKILL.md +336 -0
  53. package/.cursor/skills/sf-apex-enterprise-patterns/SKILL.md +344 -0
  54. package/.cursor/skills/sf-apex-testing/SKILL.md +407 -0
  55. package/.cursor/skills/sf-api-design/SKILL.md +237 -0
  56. package/.cursor/skills/sf-approval-processes/SKILL.md +312 -0
  57. package/.cursor/skills/sf-aura-development/SKILL.md +260 -0
  58. package/.cursor/skills/sf-build-fix/SKILL.md +120 -0
  59. package/.cursor/skills/sf-data-modeling/SKILL.md +274 -0
  60. package/.cursor/skills/sf-debugging/SKILL.md +362 -0
  61. package/.cursor/skills/sf-deployment/SKILL.md +291 -0
  62. package/.cursor/skills/sf-deployment-constraints/SKILL.md +153 -0
  63. package/.cursor/skills/sf-devops-ci-cd/SKILL.md +322 -0
  64. package/.cursor/skills/sf-docs-lookup/SKILL.md +100 -0
  65. package/.cursor/skills/sf-e2e-testing/SKILL.md +321 -0
  66. package/.cursor/skills/sf-experience-cloud/SKILL.md +248 -0
  67. package/.cursor/skills/sf-flow-development/SKILL.md +376 -0
  68. package/.cursor/skills/sf-governor-limits/SKILL.md +319 -0
  69. package/.cursor/skills/sf-harness-audit/SKILL.md +139 -0
  70. package/.cursor/skills/sf-help/SKILL.md +156 -0
  71. package/.cursor/skills/sf-integration/SKILL.md +479 -0
  72. package/.cursor/skills/sf-lwc-constraints/SKILL.md +128 -0
  73. package/.cursor/skills/sf-lwc-development/SKILL.md +302 -0
  74. package/.cursor/skills/sf-lwc-testing/SKILL.md +387 -0
  75. package/.cursor/skills/sf-metadata-management/SKILL.md +285 -0
  76. package/.cursor/skills/sf-platform-events-cdc/SKILL.md +372 -0
  77. package/.cursor/skills/sf-quickstart/SKILL.md +170 -0
  78. package/.cursor/skills/sf-security/SKILL.md +330 -0
  79. package/.cursor/skills/sf-security-constraints/SKILL.md +125 -0
  80. package/.cursor/skills/sf-soql-constraints/SKILL.md +129 -0
  81. package/.cursor/skills/sf-soql-optimization/SKILL.md +353 -0
  82. package/.cursor/skills/sf-tdd-workflow/SKILL.md +332 -0
  83. package/.cursor/skills/sf-testing-constraints/SKILL.md +198 -0
  84. package/.cursor/skills/sf-trigger-constraints/SKILL.md +88 -0
  85. package/.cursor/skills/sf-trigger-frameworks/SKILL.md +343 -0
  86. package/.cursor/skills/sf-visualforce-development/SKILL.md +259 -0
  87. package/.cursor/skills/strategic-compact/SKILL.md +205 -0
  88. package/.cursor/skills/update-docs/SKILL.md +162 -0
  89. package/.cursor/skills/update-platform-docs/SKILL.md +86 -0
  90. package/.cursor-plugin/plugin.json +26 -0
  91. package/LICENSE +21 -0
  92. package/README.md +522 -0
  93. package/agents/deep-researcher.md +145 -0
  94. package/agents/doc-updater.md +222 -0
  95. package/agents/eval-runner.md +340 -0
  96. package/agents/learning-engine.md +211 -0
  97. package/agents/loop-operator.md +247 -0
  98. package/agents/refactor-cleaner.md +122 -0
  99. package/agents/sf-admin-agent.md +131 -0
  100. package/agents/sf-agentforce-agent.md +132 -0
  101. package/agents/sf-apex-agent.md +124 -0
  102. package/agents/sf-architect.md +435 -0
  103. package/agents/sf-aura-reviewer.md +372 -0
  104. package/agents/sf-bugfix-agent.md +105 -0
  105. package/agents/sf-flow-agent.md +159 -0
  106. package/agents/sf-integration-agent.md +146 -0
  107. package/agents/sf-lwc-agent.md +127 -0
  108. package/agents/sf-review-agent.md +366 -0
  109. package/agents/sf-visualforce-reviewer.md +468 -0
  110. package/assets/logo.svg +18 -0
  111. package/docs/ARCHITECTURE.md +133 -0
  112. package/docs/authoring-guide.md +373 -0
  113. package/docs/hook-development.md +578 -0
  114. package/docs/token-optimization.md +139 -0
  115. package/docs/workflow-examples.md +645 -0
  116. package/examples/agentforce-action/README.md +227 -0
  117. package/examples/apex-trigger-handler/README.md +114 -0
  118. package/examples/devops-pipeline/README.md +325 -0
  119. package/examples/flow-automation/README.md +188 -0
  120. package/examples/integration-pattern/README.md +416 -0
  121. package/examples/lwc-component/README.md +180 -0
  122. package/examples/platform-events/README.md +492 -0
  123. package/examples/scratch-org-setup/README.md +138 -0
  124. package/examples/security-audit/README.md +244 -0
  125. package/examples/visualforce-migration/README.md +314 -0
  126. package/hooks/hooks.json +338 -0
  127. package/hooks/memory-persistence/README.md +73 -0
  128. package/manifests/install-modules.json +217 -0
  129. package/manifests/install-profiles.json +17 -0
  130. package/mcp-configs/mcp-servers.json +19 -0
  131. package/package.json +89 -0
  132. package/schemas/hooks.schema.json +123 -0
  133. package/schemas/install-modules.schema.json +76 -0
  134. package/schemas/install-profiles.schema.json +28 -0
  135. package/schemas/install-state.schema.json +73 -0
  136. package/schemas/package-manager.schema.json +18 -0
  137. package/schemas/plugin.schema.json +112 -0
  138. package/schemas/scc-install-config.schema.json +29 -0
  139. package/schemas/state-store.schema.json +111 -0
  140. package/scripts/cli/install-apply.js +170 -0
  141. package/scripts/cli/uninstall.js +193 -0
  142. package/scripts/hooks/check-console-log.js +101 -0
  143. package/scripts/hooks/check-hook-enabled.js +17 -0
  144. package/scripts/hooks/check-platform-docs-age.js +48 -0
  145. package/scripts/hooks/cost-tracker.js +78 -0
  146. package/scripts/hooks/doc-file-warning.js +63 -0
  147. package/scripts/hooks/evaluate-session.js +98 -0
  148. package/scripts/hooks/governor-check.js +220 -0
  149. package/scripts/hooks/learning-observe.sh +206 -0
  150. package/scripts/hooks/mcp-health-check.js +588 -0
  151. package/scripts/hooks/post-bash-build-complete.js +34 -0
  152. package/scripts/hooks/post-bash-pr-created.js +43 -0
  153. package/scripts/hooks/post-edit-console-warn.js +61 -0
  154. package/scripts/hooks/post-edit-format.js +79 -0
  155. package/scripts/hooks/post-edit-typecheck.js +98 -0
  156. package/scripts/hooks/post-write.js +168 -0
  157. package/scripts/hooks/pre-bash-git-push-reminder.js +35 -0
  158. package/scripts/hooks/pre-bash-tmux-reminder.js +47 -0
  159. package/scripts/hooks/pre-compact.js +51 -0
  160. package/scripts/hooks/pre-tool-use.js +163 -0
  161. package/scripts/hooks/pre-write-doc-warn.js +9 -0
  162. package/scripts/hooks/quality-gate.js +251 -0
  163. package/scripts/hooks/run-with-flags-shell.sh +32 -0
  164. package/scripts/hooks/run-with-flags.js +135 -0
  165. package/scripts/hooks/session-end-marker.js +29 -0
  166. package/scripts/hooks/session-end.js +311 -0
  167. package/scripts/hooks/session-start.js +202 -0
  168. package/scripts/hooks/sfdx-scanner-check.js +142 -0
  169. package/scripts/hooks/sfdx-validate.js +119 -0
  170. package/scripts/hooks/stop-hook.js +170 -0
  171. package/scripts/hooks/suggest-compact.js +67 -0
  172. package/scripts/lib/agent-adapter.js +82 -0
  173. package/scripts/lib/apex-analysis.js +194 -0
  174. package/scripts/lib/hook-flags.js +74 -0
  175. package/scripts/lib/install-config.js +73 -0
  176. package/scripts/lib/install-executor.js +363 -0
  177. package/scripts/lib/install-state.js +121 -0
  178. package/scripts/lib/orchestration-session.js +299 -0
  179. package/scripts/lib/package-manager.js +124 -0
  180. package/scripts/lib/project-detect.js +228 -0
  181. package/scripts/lib/schema-validator.js +190 -0
  182. package/scripts/lib/skill-adapter.js +100 -0
  183. package/scripts/lib/state-store.js +376 -0
  184. package/scripts/lib/tmux-worktree-orchestrator.js +598 -0
  185. package/scripts/lib/utils.js +313 -0
  186. package/scripts/scc.js +164 -0
  187. package/skills/_reference/AGENTFORCE_PATTERNS.md +112 -0
  188. package/skills/_reference/APEX_CURSOR.md +159 -0
  189. package/skills/_reference/API_VERSIONS.md +78 -0
  190. package/skills/_reference/APPROVAL_PROCESSES.md +105 -0
  191. package/skills/_reference/ASYNC_PATTERNS.md +163 -0
  192. package/skills/_reference/AURA_COMPONENTS.md +146 -0
  193. package/skills/_reference/DATA_MIGRATION_PATTERNS.md +151 -0
  194. package/skills/_reference/DATA_MODELING.md +124 -0
  195. package/skills/_reference/DEBUGGING_TOOLS.md +140 -0
  196. package/skills/_reference/DEPLOYMENT_CHECKLIST.md +87 -0
  197. package/skills/_reference/DEPRECATIONS.md +79 -0
  198. package/skills/_reference/DOCKER_CI_PATTERNS.md +138 -0
  199. package/skills/_reference/ENTERPRISE_PATTERNS.md +122 -0
  200. package/skills/_reference/EXPERIENCE_CLOUD.md +143 -0
  201. package/skills/_reference/FLOW_PATTERNS.md +113 -0
  202. package/skills/_reference/GOVERNOR_LIMITS.md +77 -0
  203. package/skills/_reference/INTEGRATION_PATTERNS.md +105 -0
  204. package/skills/_reference/LWC_PATTERNS.md +79 -0
  205. package/skills/_reference/METADATA_TYPES.md +115 -0
  206. package/skills/_reference/NAMING_CONVENTIONS.md +84 -0
  207. package/skills/_reference/PACKAGE_DEVELOPMENT.md +150 -0
  208. package/skills/_reference/PLATFORM_EVENTS.md +121 -0
  209. package/skills/_reference/REPORTING_API.md +143 -0
  210. package/skills/_reference/SCRATCH_ORG_PATTERNS.md +126 -0
  211. package/skills/_reference/SECURITY_PATTERNS.md +127 -0
  212. package/skills/_reference/SHARING_MODEL.md +120 -0
  213. package/skills/_reference/SOQL_PATTERNS.md +119 -0
  214. package/skills/_reference/TESTING_STANDARDS.md +96 -0
  215. package/skills/_reference/TRIGGER_PATTERNS.md +114 -0
  216. package/skills/_reference/VISUALFORCE_PATTERNS.md +121 -0
  217. package/skills/aside/SKILL.md +118 -0
  218. package/skills/checkpoint/SKILL.md +53 -0
  219. package/skills/configure-scc/SKILL.md +163 -0
  220. package/skills/continuous-agent-loop/SKILL.md +264 -0
  221. package/skills/mcp-server-patterns/SKILL.md +146 -0
  222. package/skills/model-route/SKILL.md +84 -0
  223. package/skills/prompt-optimizer/SKILL.md +369 -0
  224. package/skills/refactor-clean/SKILL.md +136 -0
  225. package/skills/resume-session/SKILL.md +114 -0
  226. package/skills/save-session/SKILL.md +186 -0
  227. package/skills/search-first/SKILL.md +144 -0
  228. package/skills/security-scan/SKILL.md +146 -0
  229. package/skills/sessions/SKILL.md +127 -0
  230. package/skills/sf-agentforce-development/SKILL.md +450 -0
  231. package/skills/sf-apex-async-patterns/SKILL.md +326 -0
  232. package/skills/sf-apex-best-practices/SKILL.md +425 -0
  233. package/skills/sf-apex-constraints/SKILL.md +81 -0
  234. package/skills/sf-apex-cursor/SKILL.md +338 -0
  235. package/skills/sf-apex-enterprise-patterns/SKILL.md +348 -0
  236. package/skills/sf-apex-testing/SKILL.md +409 -0
  237. package/skills/sf-api-design/SKILL.md +238 -0
  238. package/skills/sf-approval-processes/SKILL.md +315 -0
  239. package/skills/sf-aura-development/SKILL.md +263 -0
  240. package/skills/sf-build-fix/SKILL.md +121 -0
  241. package/skills/sf-data-modeling/SKILL.md +278 -0
  242. package/skills/sf-debugging/SKILL.md +363 -0
  243. package/skills/sf-deployment/SKILL.md +295 -0
  244. package/skills/sf-deployment-constraints/SKILL.md +155 -0
  245. package/skills/sf-devops-ci-cd/SKILL.md +325 -0
  246. package/skills/sf-docs-lookup/SKILL.md +103 -0
  247. package/skills/sf-e2e-testing/SKILL.md +324 -0
  248. package/skills/sf-experience-cloud/SKILL.md +249 -0
  249. package/skills/sf-flow-development/SKILL.md +377 -0
  250. package/skills/sf-governor-limits/SKILL.md +323 -0
  251. package/skills/sf-harness-audit/SKILL.md +142 -0
  252. package/skills/sf-help/SKILL.md +159 -0
  253. package/skills/sf-integration/SKILL.md +483 -0
  254. package/skills/sf-lwc-constraints/SKILL.md +130 -0
  255. package/skills/sf-lwc-development/SKILL.md +303 -0
  256. package/skills/sf-lwc-testing/SKILL.md +388 -0
  257. package/skills/sf-metadata-management/SKILL.md +288 -0
  258. package/skills/sf-platform-events-cdc/SKILL.md +375 -0
  259. package/skills/sf-quickstart/SKILL.md +173 -0
  260. package/skills/sf-security/SKILL.md +334 -0
  261. package/skills/sf-security-constraints/SKILL.md +127 -0
  262. package/skills/sf-soql-constraints/SKILL.md +131 -0
  263. package/skills/sf-soql-optimization/SKILL.md +354 -0
  264. package/skills/sf-tdd-workflow/SKILL.md +336 -0
  265. package/skills/sf-testing-constraints/SKILL.md +200 -0
  266. package/skills/sf-trigger-constraints/SKILL.md +90 -0
  267. package/skills/sf-trigger-frameworks/SKILL.md +347 -0
  268. package/skills/sf-visualforce-development/SKILL.md +260 -0
  269. package/skills/strategic-compact/SKILL.md +208 -0
  270. package/skills/update-docs/SKILL.md +165 -0
  271. package/skills/update-platform-docs/SKILL.md +90 -0
@@ -0,0 +1,321 @@
1
+ ---
2
+ name: sf-e2e-testing
3
+ description: >-
4
+ Use when writing Salesforce Apex end-to-end integration tests, deployment verification, or bulk scenario validation. Do NOT use for unit tests or TDD.
5
+ ---
6
+
7
+ # Salesforce E2E Testing
8
+
9
+ Comprehensive testing patterns for Salesforce applications including Apex integration tests, LWC component tests, and deployment verification.
10
+
11
+ Reference: @../_reference/TESTING_STANDARDS.md
12
+
13
+ ## When to Use
14
+
15
+ - When writing integration tests that exercise complete business workflows end-to-end
16
+ - When verifying full automation chains including triggers, flows, and queueable jobs
17
+ - When setting up pre-deployment verification test suites for a sandbox or production org
18
+ - When testing bulk scenarios with 200+ records across the full trigger and automation stack
19
+ - When building LWC integration tests with Jest that mock Apex wire adapters and calls
20
+
21
+ ## Apex Integration Tests
22
+
23
+ ```apex
24
+ @IsTest
25
+ private class OpportunityWorkflowTest {
26
+
27
+ @TestSetup
28
+ static void setup() {
29
+ Account acc = new Account(Name = 'E2E Test Account');
30
+ insert acc;
31
+
32
+ Opportunity opp = new Opportunity(
33
+ AccountId = acc.Id,
34
+ Name = 'E2E Test Opp',
35
+ StageName = 'Prospecting',
36
+ CloseDate = Date.today().addDays(30),
37
+ Amount = 50000
38
+ );
39
+ insert opp;
40
+ }
41
+
42
+ @IsTest
43
+ static void shouldProgressThroughFullSalesCycle() {
44
+ Opportunity opp = [SELECT Id, StageName FROM Opportunity LIMIT 1];
45
+
46
+ Test.startTest();
47
+
48
+ opp.StageName = 'Qualification';
49
+ update opp;
50
+
51
+ opp.StageName = 'Proposal/Price Quote';
52
+ update opp;
53
+
54
+ opp.StageName = 'Closed Won';
55
+ update opp;
56
+
57
+ Test.stopTest();
58
+
59
+ Opportunity result = [SELECT StageName, IsClosed, IsWon FROM Opportunity WHERE Id = :opp.Id];
60
+ Assert.areEqual('Closed Won', result.StageName);
61
+ Assert.isTrue(result.IsClosed, 'Should be closed');
62
+ Assert.isTrue(result.IsWon, 'Should be won');
63
+
64
+ // Verify downstream automation fired
65
+ List<Task> followUpTasks = [SELECT Id FROM Task WHERE WhatId = :opp.Id];
66
+ Assert.isTrue(!followUpTasks.isEmpty(), 'Should have created follow-up tasks');
67
+ }
68
+
69
+ @IsTest
70
+ static void shouldHandleBulkStageChanges() {
71
+ List<Opportunity> opps = new List<Opportunity>();
72
+ Account acc = [SELECT Id FROM Account LIMIT 1];
73
+ for (Integer i = 0; i < 200; i++) {
74
+ opps.add(new Opportunity(
75
+ AccountId = acc.Id,
76
+ Name = 'Bulk Opp ' + i,
77
+ StageName = 'Prospecting',
78
+ CloseDate = Date.today().addDays(30)
79
+ ));
80
+ }
81
+ insert opps;
82
+
83
+ Test.startTest();
84
+ for (Opportunity opp : opps) {
85
+ opp.StageName = 'Closed Won';
86
+ }
87
+ update opps;
88
+ Test.stopTest();
89
+
90
+ Integer closedCount = [SELECT COUNT() FROM Opportunity WHERE StageName = 'Closed Won'];
91
+ Assert.isTrue(closedCount >= 200, 'All opportunities should be closed');
92
+ }
93
+ }
94
+ ```
95
+
96
+ ## LWC Integration Tests
97
+
98
+ ```javascript
99
+ import { createElement } from 'lwc';
100
+ import OpportunityPipeline from 'c/opportunityPipeline';
101
+ import getOpportunities from '@salesforce/apex/OpportunityController.getOpportunities';
102
+
103
+ jest.mock('@salesforce/apex/OpportunityController.getOpportunities', () => ({
104
+ default: jest.fn()
105
+ }), { virtual: true });
106
+
107
+ const MOCK_OPPS = [
108
+ { Id: '006xx0001', Name: 'Opp 1', StageName: 'Prospecting', Amount: 10000 },
109
+ { Id: '006xx0002', Name: 'Opp 2', StageName: 'Closed Won', Amount: 50000 },
110
+ ];
111
+
112
+ describe('c-opportunity-pipeline (integration)', () => {
113
+ afterEach(() => { while (document.body.firstChild) document.body.removeChild(document.body.firstChild); });
114
+
115
+ it('renders pipeline with correct stage grouping', async () => {
116
+ getOpportunities.mockResolvedValue(MOCK_OPPS);
117
+ const element = createElement('c-opportunity-pipeline', { is: OpportunityPipeline });
118
+ document.body.appendChild(element);
119
+
120
+ await Promise.resolve();
121
+ await Promise.resolve();
122
+
123
+ const stages = element.shadowRoot.querySelectorAll('.stage-column');
124
+ expect(stages.length).toBeGreaterThan(0);
125
+ });
126
+ });
127
+ ```
128
+
129
+ ## Deployment Verification
130
+
131
+ ```bash
132
+ # Full E2E deployment verification
133
+ sf project deploy validate --test-level RunLocalTests --target-org staging
134
+ sf project deploy start --test-level RunLocalTests --target-org staging
135
+ sf apex run test --test-level RunLocalTests --result-format human --target-org staging
136
+ ```
137
+
138
+ ## Flow Integration Testing
139
+
140
+ ```apex
141
+ @IsTest
142
+ private class CaseEscalationFlowTest {
143
+
144
+ @IsTest
145
+ static void shouldEscalateHighPriorityCases() {
146
+ Account acc = new Account(Name = 'Flow E2E Account');
147
+ insert acc;
148
+
149
+ Case c = new Case(
150
+ AccountId = acc.Id,
151
+ Subject = 'Urgent Issue',
152
+ Priority = 'High',
153
+ Status = 'New'
154
+ );
155
+ insert c;
156
+
157
+ Test.startTest();
158
+ c.Status = 'Escalated';
159
+ update c;
160
+ Test.stopTest();
161
+
162
+ List<Task> tasks = [SELECT Subject, Priority FROM Task WHERE WhatId = :c.Id AND Subject LIKE '%Escalation%'];
163
+ Assert.isTrue(!tasks.isEmpty(), 'Flow should have created escalation task');
164
+ Assert.areEqual('High', tasks[0].Priority, 'Task priority should match case priority');
165
+ }
166
+ }
167
+ ```
168
+
169
+ ## Platform Event Testing
170
+
171
+ ```apex
172
+ @IsTest
173
+ private class OrderEventTest {
174
+
175
+ @IsTest
176
+ static void shouldPublishEventOnOrderCompletion() {
177
+ Order_Complete__e event = new Order_Complete__e(
178
+ Order_Id__c = 'ORD-001',
179
+ Total_Amount__c = 5000.00
180
+ );
181
+
182
+ Test.startTest();
183
+ Database.SaveResult sr = EventBus.publish(event);
184
+ Test.stopTest();
185
+
186
+ Assert.isTrue(sr.isSuccess(), 'Event should publish successfully');
187
+ }
188
+
189
+ @IsTest
190
+ static void shouldProcessEventInSubscriber() {
191
+ Order_Complete__e event = new Order_Complete__e(
192
+ Order_Id__c = 'ORD-002',
193
+ Total_Amount__c = 10000.00
194
+ );
195
+
196
+ Test.startTest();
197
+ EventBus.publish(event);
198
+ Test.getEventBus().deliver(); // Force trigger subscriber to execute
199
+ Test.stopTest();
200
+
201
+ List<Fulfillment__c> fulfillments = [
202
+ SELECT Order_Id__c FROM Fulfillment__c WHERE Order_Id__c = 'ORD-002'
203
+ ];
204
+ Assert.areEqual(1, fulfillments.size(), 'Subscriber should have created fulfillment');
205
+ }
206
+ }
207
+ ```
208
+
209
+ ## Async Job Verification
210
+
211
+ ```apex
212
+ @IsTest
213
+ private class AsyncWorkflowTest {
214
+
215
+ @IsTest
216
+ static void shouldProcessQueueableChain() {
217
+ Account acc = new Account(Name = 'Async E2E');
218
+ insert acc;
219
+
220
+ Test.startTest();
221
+ System.enqueueJob(new AccountEnrichmentJob(acc.Id));
222
+ Test.stopTest();
223
+
224
+ Account result = [SELECT Description, Industry FROM Account WHERE Id = :acc.Id];
225
+ Assert.isNotNull(result.Description, 'Enrichment job should populate description');
226
+ }
227
+ }
228
+ ```
229
+
230
+ ## Multi-User Testing
231
+
232
+ ```apex
233
+ @IsTest
234
+ private class PermissionE2ETest {
235
+
236
+ @IsTest
237
+ static void shouldRestrictAccessForStandardUser() {
238
+ // Note: Profile names are locale-dependent. For non-English orgs,
239
+ // query by Profile.UserType or use a custom permission set.
240
+ Profile stdProfile = [SELECT Id FROM Profile WHERE Name = 'Standard User'];
241
+ User testUser = new User(
242
+ Alias = 'stdu', Email = 'stduser@test.com',
243
+ EmailEncodingKey = 'UTF-8', LastName = 'StdUser',
244
+ LanguageLocaleKey = 'en_US', LocaleSidKey = 'en_US',
245
+ ProfileId = stdProfile.Id, TimeZoneSidKey = 'America/Los_Angeles',
246
+ UserName = 'stduser' + DateTime.now().getTime() + '@test.com'
247
+ );
248
+ insert testUser;
249
+
250
+ System.runAs(testUser) {
251
+ Test.startTest();
252
+ try {
253
+ ConfidentialRecord__c rec = new ConfidentialRecord__c(Name = 'Secret');
254
+ insert rec;
255
+ Assert.fail('Should have thrown insufficient access exception');
256
+ } catch (DmlException e) {
257
+ Assert.isTrue(e.getMessage().contains('INSUFFICIENT_ACCESS') ||
258
+ e.getMessage().contains('access'),
259
+ 'Should get access denied: ' + e.getMessage());
260
+ }
261
+ Test.stopTest();
262
+ }
263
+ }
264
+ }
265
+ ```
266
+
267
+ ## Performance Assertions
268
+
269
+ ```apex
270
+ @IsTest
271
+ private class PerformanceE2ETest {
272
+
273
+ @IsTest
274
+ static void shouldStayWithinGovernorLimits() {
275
+ List<Account> accounts = new List<Account>();
276
+ for (Integer i = 0; i < 200; i++) {
277
+ accounts.add(new Account(Name = 'Perf Test ' + i));
278
+ }
279
+ insert accounts;
280
+
281
+ Test.startTest();
282
+ Integer queriesBefore = Limits.getQueries();
283
+
284
+ AccountService.processAccounts(new Map<Id, Account>(accounts).keySet());
285
+
286
+ Integer queriesUsed = Limits.getQueries() - queriesBefore;
287
+ Test.stopTest();
288
+
289
+ Assert.isTrue(queriesUsed <= 5,
290
+ 'Should use <= 5 SOQL queries for 200 records, used: ' + queriesUsed);
291
+ }
292
+ }
293
+ ```
294
+
295
+ ## Anti-Patterns
296
+
297
+ | Anti-Pattern | Problem | Fix |
298
+ |-------------|---------|-----|
299
+ | Testing with 1 record only | Misses bulkification bugs | Test with 200+ records |
300
+ | No Test.startTest/stopTest | Governor limits from setup count against test | Wrap test logic in startTest/stopTest |
301
+ | Using SeeAllData=true | Tests depend on org data, fail unpredictably | Use @TestSetup with test-specific data |
302
+ | Hardcoded IDs | Break across orgs and sandboxes | Query for IDs or use TestDataFactory |
303
+ | No downstream verification | Trigger fires but automation not verified | Assert on records created by automation |
304
+ | Ignoring async results | Queueable/Batch results not checked | Test.stopTest forces execution, then assert |
305
+
306
+ ## Best Practices
307
+
308
+ - Use @TestSetup for shared test data across methods
309
+ - Test complete workflows, not just individual methods
310
+ - Include bulk tests (200+ records) for all trigger-based automation
311
+ - Test both happy path and error scenarios
312
+ - Verify downstream automation by checking created records
313
+ - Use Test.startTest()/Test.stopTest() to isolate governor limit counting
314
+ - Use Test.getEventBus().deliver() to force Platform Event subscriber execution
315
+ - Use System.runAs() to test permission and sharing model enforcement
316
+ - Assert governor limit consumption for performance-sensitive code
317
+ - For HTTP callout tests, use `Test.setMock(HttpCalloutMock.class, mock)` -- see the sf-integration skill for mock patterns
318
+
319
+ ## Related
320
+
321
+ - **Constraints**: `sf-testing-constraints` -- test isolation rules, assertion requirements, coverage gates
@@ -0,0 +1,248 @@
1
+ ---
2
+ name: sf-experience-cloud
3
+ description: >-
4
+ Salesforce Experience Cloud — site setup, guest users, external sharing, LWC in communities, CMS, auth. Use when building portals or partner communities. Do NOT use for internal Lightning apps.
5
+ ---
6
+
7
+ # Salesforce Experience Cloud
8
+
9
+ ## When to Use
10
+
11
+ - When building customer self-service portals, partner communities, or public-facing sites
12
+ - When configuring guest user access and reviewing external user security
13
+ - When developing LWC components for Experience Cloud sites
14
+ - When managing Experience Cloud deployment (Network, ExperienceBundle metadata)
15
+ - When designing sharing models for community/external users
16
+
17
+ @../_reference/EXPERIENCE_CLOUD.md
18
+
19
+ ---
20
+
21
+ ## Site Setup Procedure
22
+
23
+ ### Step 1 — Choose Site Type
24
+
25
+ | Site Type | Use Case |
26
+ |-----------|----------|
27
+ | Customer Service | Self-service portal (Knowledge, Cases) |
28
+ | Partner Central | Channel partner management (Leads, Opps) |
29
+ | Build Your Own (LWR) | Custom branded site, full customization |
30
+ | Help Center | Public knowledge base, no login required |
31
+
32
+ For new sites, use LWR (Lightning Web Runtime) for better performance, SEO, and LWC-only components.
33
+
34
+ ### Step 2 — Configure User Licensing
35
+
36
+ | User Type | License | Access |
37
+ |-----------|---------|--------|
38
+ | Customer Community | Community | Read/create own records |
39
+ | Customer Community Plus | Community Plus | Read/create + sharing rules |
40
+ | Partner Community | Partner Community | Leads, Opps, deal registration |
41
+ | Guest User | None | Public read access only |
42
+
43
+ ### Step 3 — Set Up Sharing Model
44
+
45
+ External users see records based on their Account association:
46
+
47
+ ```
48
+ External User -> Contact -> Account -> Records shared with that Account
49
+ ```
50
+
51
+ Configure Sharing Sets in Setup for account-based access. Each community has automatic share groups: All Customer Portal Users, All Partner Users.
52
+
53
+ ---
54
+
55
+ ## Guest User Configuration
56
+
57
+ Guest users access your site without logging in. This is the highest-risk area for data exposure.
58
+
59
+ ### Profile Permissions
60
+
61
+ - Grant Read only on objects explicitly needed for public display
62
+ - Review: Setup > Digital Experiences > [Site] > Guest User Profile
63
+
64
+ ### Guest User Sharing Rules
65
+
66
+ Configure in Setup > Sharing Settings > Guest User Sharing Rules:
67
+
68
+ ```
69
+ Object: Knowledge__kav
70
+ Criteria: IsPublished__c = TRUE AND Channel__c includes 'Public'
71
+ Access: Read Only
72
+ Shared With: Guest User (site-specific)
73
+ ```
74
+
75
+ ### Securing Apex Controllers for Guest Access
76
+
77
+ ```apex
78
+ // Use "with sharing" to enforce sharing rules
79
+ // Use WITH USER_MODE for CRUD/FLS enforcement
80
+ public with sharing class PublicKnowledgeController {
81
+ @AuraEnabled(cacheable=true)
82
+ public static List<Knowledge__kav> getPublicArticles() {
83
+ return [
84
+ SELECT Title, Summary FROM Knowledge__kav
85
+ WHERE PublishStatus = 'Online' AND IsVisibleInPkb = true
86
+ WITH USER_MODE
87
+ ];
88
+ }
89
+ }
90
+ ```
91
+
92
+ `with sharing` is necessary but not sufficient for guest users. You must also configure Guest User Sharing Rules. Without them, the query returns zero results.
93
+
94
+ ---
95
+
96
+ ## LWC in Experience Cloud
97
+
98
+ ### Component Meta XML
99
+
100
+ ```xml
101
+ <LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
102
+ <apiVersion>66.0</apiVersion>
103
+ <isExposed>true</isExposed>
104
+ <targets>
105
+ <target>lightningCommunity__Page</target>
106
+ <target>lightningCommunity__Default</target>
107
+ </targets>
108
+ <targetConfigs>
109
+ <targetConfig targets="lightningCommunity__Default">
110
+ <property name="title" type="String" label="Card Title" default="Welcome"/>
111
+ </targetConfig>
112
+ </targetConfigs>
113
+ </LightningComponentBundle>
114
+ ```
115
+
116
+ ### Accessing Community Context
117
+
118
+ ```javascript
119
+ import communityId from '@salesforce/community/Id';
120
+ import communityBasePath from '@salesforce/community/basePath';
121
+ import isGuest from '@salesforce/user/isGuest';
122
+ ```
123
+
124
+ ### Light DOM for Theming
125
+
126
+ LWR sites support Light DOM, allowing site-level CSS to style component internals:
127
+
128
+ ```javascript
129
+ export default class ThemedComponent extends LightningElement {
130
+ static renderMode = 'light';
131
+ }
132
+ ```
133
+
134
+ ### Navigation
135
+
136
+ ```javascript
137
+ import { NavigationMixin } from 'lightning/navigation';
138
+
139
+ // Navigate to a community named page
140
+ this[NavigationMixin.Navigate]({
141
+ type: 'comm__namedPage',
142
+ attributes: { name: 'Home' }
143
+ });
144
+ ```
145
+
146
+ ---
147
+
148
+ ## CMS Content
149
+
150
+ Manage content via CMS Workspaces, publish to site channels.
151
+
152
+ ```javascript
153
+ import { getContent } from 'experience/cmsDeliveryApi';
154
+
155
+ @wire(getContent, { channelId: '$channelId', contentKeyOrId: '$contentId' })
156
+ content;
157
+
158
+ get title() { return this.content?.data?.title?.value; }
159
+ ```
160
+
161
+ ---
162
+
163
+ ## Custom Authentication
164
+
165
+ ### Self-Registration Handler
166
+
167
+ ```apex
168
+ global class CustomRegistrationHandler implements Auth.RegistrationHandler {
169
+ global User createUser(Id portalId, Auth.UserData data) {
170
+ Account portalAccount = [SELECT Id FROM Account WHERE Name = 'Community Users' LIMIT 1];
171
+ Contact c = new Contact(
172
+ AccountId = portalAccount.Id, FirstName = data.firstName,
173
+ LastName = data.lastName, Email = data.email
174
+ );
175
+ insert c;
176
+
177
+ Profile p = [SELECT Id FROM Profile WHERE Name = 'Customer Community User'];
178
+ return new User(
179
+ ContactId = c.Id, ProfileId = p.Id,
180
+ Username = data.email + '.community',
181
+ FirstName = data.firstName, LastName = data.lastName,
182
+ Email = data.email, Alias = data.firstName != null ? data.firstName.left(8) : 'guest',
183
+ EmailEncodingKey = 'UTF-8', LanguageLocaleKey = 'en_US',
184
+ LocaleSidKey = 'en_US', TimeZoneSidKey = 'America/Los_Angeles'
185
+ );
186
+ }
187
+
188
+ global void updateUser(Id userId, Id portalId, Auth.UserData data) {
189
+ update new User(Id = userId, FirstName = data.firstName,
190
+ LastName = data.lastName, Email = data.email);
191
+ }
192
+ }
193
+ ```
194
+
195
+ Social login: configure in Settings > Login & Registration > Social Sign-On (Google, Facebook, Apple, LinkedIn, or custom OAuth providers).
196
+
197
+ ---
198
+
199
+ ## Deployment Steps
200
+
201
+ ### Metadata Components
202
+
203
+ | Metadata Type | Directory |
204
+ |---------------|-----------|
205
+ | Network | `networks/` |
206
+ | ExperienceBundle | `experiences/` |
207
+ | CustomSite | `sites/` |
208
+ | NavigationMenu | `navigationMenus/` |
209
+
210
+ ### Deploy Procedure
211
+
212
+ ```bash
213
+ sf project deploy start --source-dir force-app/main/default/experiences
214
+ sf project deploy start --source-dir force-app/main/default/networks
215
+ ```
216
+
217
+ Publish via Experience Builder UI or Apex: `ConnectApi.Communities.publishCommunity(null, communityId);`
218
+
219
+ ### Deployment Checklist
220
+
221
+ 1. Deploy Network metadata (site configuration)
222
+ 2. Deploy ExperienceBundle (pages, themes, routes)
223
+ 3. Deploy NavigationMenu and dependent components (LWC, Apex, objects)
224
+ 4. Publish the site
225
+ 5. Verify guest user profile permissions
226
+ 6. Test with community user login
227
+
228
+ ---
229
+
230
+ ## SEO and Performance
231
+
232
+ - Configure sitemap in Settings > SEO (LWR sites only)
233
+ - Use semantic URLs (`/orders/12345` not `/s/detail/a01xx000003ABC`)
234
+ - Enable CDN caching for static assets (default for LWR)
235
+ - Use `@AuraEnabled(cacheable=true)` for read-only data
236
+ - Use Custom Labels for multi-language support
237
+
238
+ ---
239
+
240
+ ## Related
241
+
242
+ ### Guardrails
243
+
244
+ - **sf-security-constraints** — Enforced rules for guest user permissions, sharing, and CRUD/FLS
245
+
246
+ ### Agents
247
+
248
+ - **sf-lwc-agent** — For LWC components used in Experience Cloud sites