Skip to content

Commit c2fd361

Browse files
authored
Merge pull request #265 from fingerprintjs/chore/smoke-tests-cleanup
INTER-2307: Low-hanging test coverage improvements (ecosystem care)
2 parents ec98ada + ea8842e commit c2fd361

6 files changed

Lines changed: 51 additions & 12 deletions

File tree

.changeset/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212
"access": "public",
1313
"baseBranch": "main",
1414
"updateInternalDependencies": "patch",
15-
"ignore": ["node-sdk-example", "node-sdk-smoke-tests"]
15+
"ignore": ["node-sdk-example", "node-sdk-functional-tests"]
1616
}

.github/workflows/functional_tests.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
artifactPath: ./dist
2020

2121
functional_tests:
22-
name: 'Smoke test on node ${{ matrix.node-version }}'
22+
name: 'Functional test on node ${{ matrix.node-version }}'
2323
needs: build
2424
runs-on: ubuntu-latest
2525

@@ -59,20 +59,19 @@ jobs:
5959
env:
6060
CI: true
6161

62-
- name: Install Dependencies for example
63-
run: pnpm install
64-
working-directory: ./example
65-
env:
66-
CI: true
62+
- name: Typecheck examples
63+
run: pnpm typecheck:examples
6764

68-
- name: 'Switch to target Node version for smoke test'
65+
- name: 'Switch to target Node version for functional test'
6966
uses: actions/setup-node@v6
7067
with:
7168
node-version: ${{ matrix.node-version }}
7269

7370
- name: Run test
7471
run: |
75-
node smokeTests.mjs
72+
node functionalTests.mjs
7673
working-directory: ./tests/functional-tests
7774
env:
7875
API_KEY: '${{ secrets.PRIVATE_KEY }}'
76+
BASE64_SEALED_RESULT: '${{ secrets.BASE64_SEALED_RESULT }}'
77+
BASE64_KEY: '${{ secrets.BASE64_KEY }}'

tests/functional-tests/.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@ API_KEY=<API_KEY>
22
# "eu" or "ap", "us" is the default
33
REGION=<REGION>
44
RULESET_ID=<RULESET_ID>
5+
# Optional: sealed-result validation is skipped unless both are set.
6+
BASE64_SEALED_RESULT=<BASE64_SEALED_RESULT>
7+
BASE64_KEY=<BASE64_KEY>

tests/functional-tests/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# node-sdk-smoke-tests
1+
# node-sdk-functional-tests
22

33
## 1.0.6
44

tests/functional-tests/smokeTests.mjs renamed to tests/functional-tests/functionalTests.mjs

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
import { FingerprintServerApiClient, Region, RequestError, TooManyRequestsError } from '@fingerprint/node-sdk'
1+
import {
2+
FingerprintServerApiClient,
3+
Region,
4+
RequestError,
5+
TooManyRequestsError,
6+
unsealEventsResponse,
7+
DecryptionAlgorithm,
8+
} from '@fingerprint/node-sdk'
29
import { config } from 'dotenv'
310
import assert from 'node:assert'
411
config()
@@ -128,6 +135,34 @@ async function validateOldestOrder(client, start, end) {
128135
}
129136
}
130137

138+
async function validateSealedResult() {
139+
const sealedData = process.env.BASE64_SEALED_RESULT
140+
const decryptionKey = process.env.BASE64_KEY
141+
142+
if (!sealedData || !decryptionKey) {
143+
// In CI the fixture must be present; locally we skip so contributors don't need it.
144+
if (process.env.CI) {
145+
throw new Error('BASE64_SEALED_RESULT and BASE64_KEY must be set in CI for sealed results validation')
146+
}
147+
console.log('BASE64_SEALED_RESULT or BASE64_KEY not set, skipping sealed results validation')
148+
return
149+
}
150+
151+
console.log('Validating sealed result...')
152+
const unsealed = await unsealEventsResponse(Buffer.from(sealedData, 'base64'), [
153+
{
154+
key: Buffer.from(decryptionKey, 'base64'),
155+
algorithm: DecryptionAlgorithm.Aes256Gcm,
156+
},
157+
])
158+
159+
if (!unsealed?.identification?.visitor_id) {
160+
throw new Error('Unsealed result missing identification.visitor_id')
161+
}
162+
163+
console.log('Sealed result validation works!')
164+
}
165+
131166
async function main() {
132167
try {
133168
const client = createClient()
@@ -141,6 +176,8 @@ async function main() {
141176

142177
await validateOldestOrder(client, start, end)
143178

179+
await validateSealedResult()
180+
144181
if (ruleset_id) {
145182
await validateRulesetEvaluationForBlock(client, start, end)
146183
await validateRulesetEvaluationForAllow(client, start, end)

tests/functional-tests/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "node-sdk-smoke-tests",
2+
"name": "node-sdk-functional-tests",
33
"version": "2.0.0",
44
"description": "",
55
"main": "index.mjs",

0 commit comments

Comments
 (0)