Skip to content

Commit ca43b2a

Browse files
feat: enhance testing setup and improve error handling in CardField
1 parent d3ac1e3 commit ca43b2a

File tree

10 files changed

+1341
-152
lines changed

10 files changed

+1341
-152
lines changed

.github/workflows/ci.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: "CI"
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
build:
7+
name: "Build and test"
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v4
12+
13+
- name: Cache node modules
14+
id: cache-nodemodules
15+
uses: actions/cache@v4
16+
with:
17+
path: |
18+
node_modules
19+
key: ${{ runner.os }}-build-cache-node-modules-${{ hashFiles('./yarn.lock') }}
20+
restore-keys: |
21+
${{ runner.os }}-build-cache-node-modules-
22+
23+
- name: Install dependencies
24+
if: steps.cache-nodemodules.outputs.cache-hit != 'true'
25+
run: yarn install --prefer-offline --frozen-lockfile
26+
27+
- name: Build
28+
run: yarn build
29+
30+
- name: Test
31+
run: yarn test:built

package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@
1818
"append-debug-mode": "node scripts/append-script-metadata.js --debug",
1919
"append-debug-host": "node scripts/append-script-metadata.js --debug-host",
2020
"append-version": "node scripts/append-script-metadata.js --version",
21-
"bump-version": "yarn version"
21+
"bump-version": "yarn version",
22+
"test": "yarn build && vitest run",
23+
"test:built": "vitest run",
24+
"test:watch": "vitest"
2225
},
2326
"devDependencies": {
2427
"@eslint/js": "^9.19.0",
@@ -28,14 +31,17 @@
2831
"eslint": "^9.19.0",
2932
"eslint-config-prettier": "^10.0.1",
3033
"globals": "^15.14.0",
34+
"happy-dom": "^20.4.0",
3135
"husky": "^9.1.7",
36+
"jsdom": "^28.0.0",
3237
"lint-staged": "^15.4.3",
3338
"prettier": "^3.4.2",
3439
"tsc-watch": "^6.2.1",
3540
"typescript": "^5.7.3",
3641
"typescript-eslint": "^8.23.0",
3742
"uglify-js": "3.8.0",
38-
"vite": "^6.1.0"
43+
"vite": "^6.1.0",
44+
"vitest": "^4.0.18"
3945
},
4046
"lint-staged": {
4147
"*.{ts,json}": "eslint --cache --fix --no-warn-ignored"

src/apm/StateManager.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ module ProcessOut {
3131
// Optional cleanup callback when component is removed
3232
onDestroy?: (id: string, state: any) => void;
3333
}
34+
35+
type ScheduleFunction = (callback: FrameRequestCallback) => number | ReturnType<typeof setTimeout>;
3436

3537
export class StateManager {
3638
private static instance: StateManager | null = null;
@@ -171,7 +173,7 @@ module ProcessOut {
171173
this.isBatchScheduled = true;
172174

173175
// Use requestAnimationFrame to batch updates, with fallback for IE 11
174-
let scheduleFunction = requestAnimationFrame;
176+
let scheduleFunction: ScheduleFunction = requestAnimationFrame;
175177

176178
if (!scheduleFunction) {
177179
scheduleFunction = function(callback: FrameRequestCallback) { return setTimeout(() => callback(performance.now()), 16); };
@@ -214,7 +216,7 @@ module ProcessOut {
214216
this.pendingCallbacks.length = 0;
215217

216218
if (callbacks.length > 0) {
217-
let scheduleFunction = requestAnimationFrame
219+
let scheduleFunction: ScheduleFunction = requestAnimationFrame
218220

219221
if (!scheduleFunction) {
220222
scheduleFunction = function(callback: FrameRequestCallback) { return setTimeout(() => callback(performance.now()), 16); };

src/processout/actionhandler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ module ProcessOut {
484484
return wrapper;
485485
}
486486

487-
protected listenEvents(newWindow: Window, timer: number,
487+
protected listenEvents(newWindow: Window, timer: ReturnType<typeof setTimeout>,
488488
refocus: () => void,
489489
success: (data: any) => void,
490490
error: (err: Exception) => void): void {

0 commit comments

Comments
 (0)