-
Notifications
You must be signed in to change notification settings - Fork 190
✅ Add Salesforce E2E tests #4761
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
BeltranBulbarellaDD
merged 64 commits into
main
from
beltran.bulbarella/salesforce/add-e2e-test-setup
Jul 3, 2026
Merged
Changes from 63 commits
Commits
Show all changes
64 commits
Select commit
Hold shift + click to select a range
5dadb50
Add new Browser-rum-salesforce package
BeltranBulbarellaDD 8c6cd15
Add support for Salesforce LWS
BeltranBulbarellaDD 48f1282
Address comments from review
BeltranBulbarellaDD 0fe7170
Address comments from Codex
BeltranBulbarellaDD ecbb855
Add unit tests
BeltranBulbarellaDD d9b95ba
Address location change observable comments
BeltranBulbarellaDD a55b33f
Make window optional in globalObject
BeltranBulbarellaDD 3355032
Fix format and codex reviews
BeltranBulbarellaDD aa6f784
Fix linter
BeltranBulbarellaDD b260896
Initialize sf-lwc-app test app with eslint and prettier ignored
BeltranBulbarellaDD a742145
Add minimal LWC app for testing (Navigation, views, actions, resource…
BeltranBulbarellaDD 14362c2
Merge branch 'main' into salesforce/add-e2e-tests_2
BeltranBulbarellaDD dfab355
fix: build, woke, home url in console output
BeltranBulbarellaDD 93e8012
fix: rename sample json api url
BeltranBulbarellaDD 158954d
format changes
BeltranBulbarellaDD b5b5beb
feat: build and deploy hashed bundles for salesforce
BeltranBulbarellaDD 0424266
Add data test ids to salesforce app
BeltranBulbarellaDD bd55010
Add sf session helper
BeltranBulbarellaDD be88c73
Use playwright's route to intercept the requests
BeltranBulbarellaDD 625e764
format and linter
BeltranBulbarellaDD 1e47d83
Format SF html files. Add data-testid
BeltranBulbarellaDD e71a4dc
remove allowed tracing urls
BeltranBulbarellaDD 203d830
Integrate withSalesforceApp and build into e2e tests
BeltranBulbarellaDD 426f1c8
Print log when missing Salesforce credentials
BeltranBulbarellaDD 7d00c84
use client credentials for Salesforce E2E tests
BeltranBulbarellaDD 955154a
Use getSecretKey helper function for SF
BeltranBulbarellaDD 2f36b8a
Rewrite structure
BeltranBulbarellaDD dd7c95f
Cleanup unused code and files
BeltranBulbarellaDD d32e6bf
Merge branch 'main' into salesforce/add-e2e-tests_2
BeltranBulbarellaDD 9565382
Remove unused code
BeltranBulbarellaDD a5f06b4
Use query params for Datadog RUM config
BeltranBulbarellaDD 7c535a0
Clean up Datadog RUM URL parameters, don't initialize RUM if not conf…
BeltranBulbarellaDD 33581fd
chore: remove accidental rum-events-format gitlink
BeltranBulbarellaDD 0560c00
Address codex comments
BeltranBulbarellaDD b37c157
Merge branch 'salesforce/add-e2e-tests_2' into beltran.bulbarella/sal…
BeltranBulbarellaDD 3c6e244
Use CLI to authenticate and deploy Salesforce app
BeltranBulbarellaDD 9c0f601
Use runSf
BeltranBulbarellaDD 1f8d086
writeFileSync the bundle to the stable static resource
BeltranBulbarellaDD 28889ce
Merge branch 'main' into beltran.bulbarella/salesforce/add-e2e-test-s…
BeltranBulbarellaDD bdf0ca2
Load local bundle into Salesforce static resource
BeltranBulbarellaDD 2a4d1de
Address codex review
BeltranBulbarellaDD 3e7e6a1
Extend withSalesforceApp
BeltranBulbarellaDD 2e89087
Address codex reviews
BeltranBulbarellaDD bb0cc94
Use test RUM proxy config
BeltranBulbarellaDD 0bbc090
Add comments, remove before send, add ignore error log
BeltranBulbarellaDD 40131ed
Simply script, init
BeltranBulbarellaDD a98c30a
Simply error messagw
BeltranBulbarellaDD dc6cf91
Address codex, drop fallback from getSalesforceConfig()
BeltranBulbarellaDD 8d16cc6
Simplify scripts and test setup
BeltranBulbarellaDD 6fb1287
fix head error
BeltranBulbarellaDD 85c69bc
Separate authentication from test setup
BeltranBulbarellaDD f3942ac
Skip test on non-chromium browsers
BeltranBulbarellaDD 2e3b0e9
Improve README for Salesforce app
BeltranBulbarellaDD bbd5237
skip test on non-chromium browsers
BeltranBulbarellaDD de90e80
Address codex review
BeltranBulbarellaDD 6e02888
Check credentials before building Salesforce URL
BeltranBulbarellaDD 051276e
Authenticate on every deploy, use sf CLI JSON output
BeltranBulbarellaDD 2a53ea0
Authenticate on every salesforce script call
BeltranBulbarellaDD 96c2e6e
Simplify Salesforce app RUM configuration
BeltranBulbarellaDD c602507
Simplify config, address comments
BeltranBulbarellaDD 693e87d
Add more tests, simplify test app config
BeltranBulbarellaDD 2d97301
Add default init configuration to SF test app.
BeltranBulbarellaDD 5e23daa
Address comments
BeltranBulbarellaDD 9dc1458
Fix deploy script to use --env-file-if-exists=.env
BeltranBulbarellaDD File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,9 @@ | ||
| # BROWSERSTACK CREDENTIALS | ||
| BS_USERNAME=xxx | ||
| BS_ACCESS_KEY=xxx | ||
|
|
||
| # Salesforce credentials | ||
| SF_LWC_CLIENT_ID=xxx | ||
| SF_LWC_USERNAME=xxx | ||
| SF_LWC_INSTANCE_URL=xxx | ||
| SF_LWC_JWT_PRIVATE_KEY_B64=xxx |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| import { chmodSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs' | ||
| import { dirname, resolve } from 'node:path' | ||
| import { fileURLToPath } from 'node:url' | ||
| import { tmpdir } from 'node:os' | ||
| import { parseArgs } from 'node:util' | ||
|
|
||
| import { printLog, runMain } from './lib/executionUtils.ts' | ||
| import { getSfLwcClientId, getSfLwcInstanceUrl, getSfLwcJwtPrivateKey, getSfLwcUsername } from './lib/secrets.ts' | ||
| import { command } from './lib/command.ts' | ||
|
|
||
| const repositoryRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..') | ||
| const salesforceAppDir = resolve(repositoryRoot, 'test/apps/sf-lwc-app') | ||
| const SALESFORCE_HOME_PATH = '/lightning/app/c__SF_LWC_App/page/home' | ||
| const TARGET_ORG = 'sf-lwc-ci' | ||
|
|
||
| runMain(() => { | ||
| const { values, positionals } = parseArgs({ | ||
| allowPositionals: true, | ||
| options: { | ||
| help: { | ||
| type: 'boolean', | ||
| short: 'h', | ||
| }, | ||
| }, | ||
| }) | ||
|
|
||
| if (values.help) { | ||
| showUsageAndExit() | ||
| } | ||
|
|
||
| if (positionals.length !== 1) { | ||
| throw new Error('Usage: node scripts/salesforce-lwc-app.ts <deploy-app|get-url>') | ||
| } | ||
|
|
||
| const commandName = positionals[0] | ||
|
|
||
| switch (commandName) { | ||
| // Deploy the app to the Salesforce org. To be done only when the app is updated. | ||
| case 'deploy-app': | ||
| deployApp() | ||
| break | ||
| // Get the authenticated URL of the app. | ||
| case 'get-url': | ||
| printSalesforceLwcUrl() | ||
| break | ||
| default: | ||
| throw new Error(`Unknown command "${commandName ?? ''}". Expected: deploy-app|get-url`) | ||
| } | ||
| }) | ||
|
|
||
| function showUsageAndExit() { | ||
| console.log('Usage: node scripts/salesforce-lwc-app.ts <deploy-app|get-url>') | ||
| process.exit(0) | ||
| } | ||
|
|
||
| function authenticate(targetOrg: string) { | ||
| // Temporary directory holding the JWT private key for the duration of authentication. | ||
| // Using a unique temp dir avoids collisions when multiple CI jobs run in parallel. | ||
| const keyDirectory = mkdtempSync(resolve(tmpdir(), 'sf-lwc-jwt-')) | ||
| const serverKeyPath = resolve(keyDirectory, 'server.key') | ||
|
|
||
| try { | ||
| writeFileSync(serverKeyPath, Buffer.from(getSfLwcJwtPrivateKey(), 'base64').toString('utf8'), { mode: 0o600 }) | ||
| // writeFileSync mode can be masked by the process umask; chmodSync guarantees owner-only access. | ||
| chmodSync(serverKeyPath, 0o600) | ||
|
|
||
| printLog(`Authenticating Salesforce CLI alias ${targetOrg}...`) | ||
| command`sf org login jwt --client-id ${getSfLwcClientId()} --jwt-key-file ${serverKeyPath} --username ${getSfLwcUsername()} --instance-url ${getSfLwcInstanceUrl()} --alias ${targetOrg}` | ||
| .withCurrentWorkingDirectory(salesforceAppDir) | ||
| .withLogs() | ||
| .run() | ||
| printLog(`Salesforce CLI authenticated as ${targetOrg}.`) | ||
| } finally { | ||
| rmSync(keyDirectory, { recursive: true, force: true }) | ||
| } | ||
| } | ||
|
|
||
| function deployApp() { | ||
| authenticate(TARGET_ORG) | ||
|
|
||
| printLog(`Deploying Salesforce LWC app to ${TARGET_ORG}...`) | ||
| command`sf project deploy start --target-org ${TARGET_ORG} --source-dir force-app --ignore-conflicts --concise` | ||
| .withCurrentWorkingDirectory(salesforceAppDir) | ||
| .withLogs() | ||
| .run() | ||
| printLog('Salesforce LWC app deployed.') | ||
| } | ||
|
|
||
| function printSalesforceLwcUrl(): void { | ||
| const path = new URL(SALESFORCE_HOME_PATH, 'https://salesforce.local') | ||
|
|
||
| authenticate(TARGET_ORG) | ||
|
|
||
| command`sf org open --target-org ${TARGET_ORG} --path ${path.pathname}${path.search} --url-only` | ||
| .withCurrentWorkingDirectory(salesforceAppDir) | ||
| .withLogs() | ||
| .run() | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| .sf | ||
| .sfdx | ||
| /force-app/main/default/staticresources/datadog_rum_slim.js | ||
| /force-app/main/default/staticresources/datadog_rum_slim.js |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,5 @@ | ||
| { | ||
| "name": "sf-lwc-app", | ||
| "private": true, | ||
| "description": "Salesforce Lightning app for browser-sdk Salesforce testing", | ||
| "scripts": { | ||
| "setup": "node scripts/setup.mjs" | ||
| } | ||
| "description": "Salesforce Lightning app for browser-sdk Salesforce testing" | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.