mirror of
https://github.com/gethomepage/homepage.git
synced 2026-02-07 16:30:52 +08:00
Chore: homepage tests (#6278)
This commit is contained in:
@@ -201,3 +201,18 @@ export default async function customProxyHandler(req, res, map) {
|
||||
```
|
||||
|
||||
Proxy handlers are a complex topic and require a good understanding of JavaScript and the Homepage codebase. If you are new to Homepage, we recommend using the built-in proxy handlers.
|
||||
|
||||
## Testing proxy handlers
|
||||
|
||||
Proxy handlers are a common source of regressions because they deal with authentication, request formatting, and sometimes odd upstream API behavior.
|
||||
|
||||
When you add a new proxy handler or custom widget proxy, include tests that focus on behavior:
|
||||
|
||||
- **Request construction:** the correct URL/path, query params, headers, and auth (and that secrets are not accidentally logged).
|
||||
- **Response mapping:** the payload shape expected by the widget/component (including optional/missing fields).
|
||||
- **Error handling:** upstream non-200s, invalid JSON, timeouts, and unexpected payloads should produce a predictable result.
|
||||
|
||||
Test locations:
|
||||
|
||||
- Shared handlers live in `src/utils/proxy/handlers/*.js` with tests alongside them (for example `src/utils/proxy/handlers/generic.test.js`).
|
||||
- Widget-specific proxies live in `src/widgets/<widget>/proxy.js` with tests in `src/widgets/<widget>/proxy.test.js`.
|
||||
|
||||
Reference in New Issue
Block a user