Skip to content

Commit c5feb23

Browse files
ngreardSFtprouvot
andauthored
[feat] review and fix CI/CD tests automation (#1084)
## Describe your changes review and refactor all Inspector Reloaded tests to leverage Playwright ## Issue ticket number and link N/A ## Checklist before requesting a review - [x] I have read and understand the [Contributions section](https://github.com/tprouvot/Salesforce-Inspector-reloaded#contributions) - [ ] Target branch is releaseCandidate and not master - [x] I have performed a self-review of my code - [x] I ran the [unit tests](https://github.com/tprouvot/Salesforce-Inspector-reloaded#unit-tests) and my PR does not break any tests - [] I documented the changes I've made on the [CHANGES.md](https://github.com/tprouvot/Salesforce-Inspector-reloaded/blob/master/CHANGES.md) and followed actual conventions - [ ] I added a new section on [how-to.md](https://github.com/tprouvot/Salesforce-Inspector-reloaded/blob/master/docs/how-to.md) (optional) --------- Co-authored-by: Thomas Prouvot <prouvot.t@gmail.com>
1 parent 2f3267d commit c5feb23

45 files changed

Lines changed: 8300 additions & 3032 deletions

Some content is hidden

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

.github/workflows/e2e.yml

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
name: Playwright Tests
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
branches: [ releaseCandidate, beta, main ]
7+
push:
8+
branches: [ releaseCandidate, beta, main ]
9+
10+
jobs:
11+
# Fork PRs: run tests with mocks (no access to secrets)
12+
test-mocked:
13+
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == true
14+
timeout-minutes: 60
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v6
18+
19+
- name: Setup Node.js
20+
uses: actions/setup-node@v6
21+
with:
22+
node-version: '24'
23+
cache: 'npm'
24+
25+
- name: Restore node_modules cache
26+
id: cache-npm
27+
uses: actions/cache@v5
28+
with:
29+
path: ~/.npm
30+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
31+
restore-keys: |
32+
${{ runner.os }}-build-${{ env.cache-name }}-
33+
${{ runner.os }}-build-
34+
${{ runner.os }}-
35+
36+
- name: Install dependencies
37+
run: npm ci
38+
39+
- name: Install Playwright Browsers
40+
run: npx playwright install chromium
41+
42+
- name: Run Playwright tests (mocked)
43+
run: npm run test:e2e:mock
44+
45+
- uses: actions/upload-artifact@v4
46+
if: always()
47+
with:
48+
name: playwright-report-mocked
49+
path: playwright-report/
50+
retention-days: 30
51+
52+
# Repo PRs + manual dispatch + post-merge push: run tests against real org
53+
test-real-org:
54+
if: >-
55+
github.event_name == 'workflow_dispatch'
56+
|| github.event_name == 'push'
57+
|| (github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork != true)
58+
timeout-minutes: 60
59+
runs-on: ubuntu-latest
60+
steps:
61+
- uses: actions/checkout@v6
62+
63+
- name: Setup Node.js
64+
uses: actions/setup-node@v6
65+
with:
66+
node-version: '24'
67+
cache: 'npm'
68+
69+
- name: Restore node_modules cache
70+
id: cache-npm
71+
uses: actions/cache@v5
72+
with:
73+
path: ~/.npm
74+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
75+
restore-keys: |
76+
${{ runner.os }}-build-${{ env.cache-name }}-
77+
${{ runner.os }}-build-
78+
${{ runner.os }}-
79+
80+
- name: Setup Salesforce CLI and authenticate
81+
if: ${{ vars.SF_TEST_MOCKENABLED == 'false' }}
82+
env:
83+
SF_CLI_URL: ${{ vars.SF_CLI_URL }}
84+
SF_TEST_APIVERSION: ${{ vars.SF_TEST_APIVERSION }}
85+
SF_TEST_MOCKENABLED: ${{ vars.SF_TEST_MOCKENABLED }}
86+
SF_TEST_ACCOUNTID: ${{ vars.SF_TEST_ACCOUNTID }}
87+
SF_TEST_FLOWID: ${{ vars.SF_TEST_FLOWID }}
88+
SF_TEST_FLOWDEFID: ${{ vars.SF_TEST_FLOWDEFID }}
89+
SF_AUTH_URL: ${{ secrets.SF_AUTH_URL }}
90+
run: |
91+
# Install Salesforce CLI
92+
echo "Installing Salesforce CLI from $SF_CLI_URL"
93+
wget $SF_CLI_URL -O sf-cli.tar.xz
94+
mkdir -p sf-cli
95+
tar xJf sf-cli.tar.xz -C sf-cli --strip-components=1
96+
echo "$PWD/sf-cli/bin" >> $GITHUB_PATH
97+
export PATH="$PWD/sf-cli/bin:$PATH"
98+
sf --version
99+
100+
# Authenticate and get access token
101+
echo "Authenticating to Salesforce org using SF_AUTH_URL..."
102+
echo $SF_AUTH_URL > ./SFDX_AUTH_URL.txt
103+
sf org login sfdx-url -f ./SFDX_AUTH_URL.txt -a cicdorg -d
104+
105+
# Display the authenticated org and extract the access token and instance url
106+
echo "Extracting authentication information..."
107+
ORG_INFO=$(sf org display --json -o cicdorg 2>/dev/null)
108+
SF_EXIT_CODE=$?
109+
110+
if [ $SF_EXIT_CODE -ne 0 ]; then
111+
echo "Error: sf org display failed with exit code $SF_EXIT_CODE"
112+
exit 1
113+
fi
114+
115+
# Check if we got valid JSON
116+
if [ -z "$ORG_INFO" ]; then
117+
echo "Error: sf org display returned empty output"
118+
exit 1
119+
fi
120+
121+
ACCESS_TOKEN=$(echo "$ORG_INFO" | jq -r '.result.accessToken // empty' 2>/dev/null)
122+
INSTANCE_URL=$(echo "$ORG_INFO" | jq -r '.result.instanceUrl // empty' 2>/dev/null)
123+
124+
if [ -z "$ACCESS_TOKEN" ]; then
125+
echo "Error: Could not extract access_token from auth response"
126+
exit 1
127+
fi
128+
129+
# Mask the token so it never appears in logs
130+
echo "::add-mask::$ACCESS_TOKEN"
131+
132+
# Extract hostname from instance URL
133+
if [ -n "$INSTANCE_URL" ]; then
134+
SF_HOST=$(echo "$INSTANCE_URL" | sed 's|https\?://||' | sed 's|/.*||')
135+
else
136+
echo "Error: Could not determine Salesforce instance URL"
137+
exit 1
138+
fi
139+
140+
if [ -z "$SF_HOST" ]; then
141+
echo "Error: Could not determine Salesforce hostname"
142+
exit 1
143+
fi
144+
145+
# Generate test-constants.local.js with real credentials
146+
echo "Generating tests/e2e/test-constants.local.js..."
147+
printf '%s\n' \
148+
'export const TEST_CONSTANTS = {' \
149+
' mockHost: "'"$SF_HOST"'",' \
150+
' mockToken: "'"$ACCESS_TOKEN"'",' \
151+
' apiVersion: "'"$SF_TEST_APIVERSION"'",' \
152+
' accountRecordId: "'"$SF_TEST_ACCOUNTID"'",' \
153+
' accountRecordName: "Test Account 1",' \
154+
' testUserSearchTerm: "Integration User",' \
155+
' flowId: "'"$SF_TEST_FLOWID"'",' \
156+
' flowDefId: "'"$SF_TEST_FLOWDEFID"'",' \
157+
' mockEnabled: '"$SF_TEST_MOCKENABLED" \
158+
'};' > tests/e2e/test-constants.local.js
159+
160+
- name: Install dependencies
161+
run: npm ci
162+
163+
- name: Install Playwright Browsers
164+
run: npx playwright install chromium
165+
166+
- name: Run Playwright tests
167+
run: npm run test:e2e
168+
169+
- uses: actions/upload-artifact@v4
170+
if: always()
171+
with:
172+
name: playwright-report
173+
path: playwright-report/
174+
retention-days: 30

.gitignore

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,13 @@ venv/
1414
.sf/
1515
.vscode/
1616
.DS_Store
17-
.cursorrules
17+
.cursorrules
18+
19+
# Playwright
20+
playwright-report/
21+
test-results/
22+
blob-report/
23+
tests/coverage/
24+
25+
# Local test constants (contains org credentials)
26+
tests/e2e/test-constants.local.js

addon/csv-parse-test.js

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)