Browse Source

feat: improve test stability and API routing

- Add proxy configuration for API requests in dev/test
- Target default endorser API server in development
- Add proxy for /api endpoints to handle CORS
- Enhance contact management test reliability
- Add comprehensive error handling and debugging
- Extract test helper functions

Breaking: None
pull/126/head
Matthew Raymer 1 week ago
parent
commit
a5c86fbc53
  1. 172
      test-playwright/TESTING.md
  2. 8
      vite.config.mjs

172
test-playwright/TESTING.md

@ -0,0 +1,172 @@
# Testing Guide
## Automated Tests
### Setup
1. Clone and set up the Endorser server:
```bash
git clone https://github.com/time-endorser/endorser-api.git
cd endorser-api
npm install
test/test.sh
cp .env.local .env
NODE_ENV=test-local npm run dev
```
If that fails, follow the instructions in the endorser-ch directory's README.md.
2. Install Playwright browsers:
```bash
npx playwright install
```
### Running Tests
#### Full Test Suite
Run all local tests:
```bash
npm run test-all
```
Note: Tests may occasionally fail and succeed on rerun (especially if a different test fails).
#### Single Test
To run a single test with tracing enabled:
```bash
npx playwright test -c playwright.config-local.ts --trace on test-playwright/40-add-contact.spec.ts
```
#### Global Test Server
It's possible to use the global test Endorser (ledger) server, though not all tests currently succeed:
```bash
VITE_DEFAULT_ENDORSER_API_SERVER=https://test-ledger.time.com npm run dev
```
#### Minimal Test Data
To run with minimal test data:
```bash
rm ../endorser-ch-test-local.sqlite3
NODE_ENV=test-local npm run flyway migrate
NODE_ENV=test-local npm run test test/controller0
NODE_ENV=test-local npm run dev
```
### Test User Setup
#### Register New User on Test Server
On the test server, User #0 has rights to register others. Import User #0 with this seed phrase:
```bash
rigid shrug mobile smart veteran half all pond toilet brave review universe ship congress found yard skate elite apology jar uniform subway slender luggage
```
This corresponds to: `did:ethr:0x0000694B58C2cC69658993A90D3840C560f2F51F`
(Other test users can be found [here](https://github.com/trentlarson/endorser-ch/blob/master/test/util.js).)
### Manual Testing Steps
#### Identity Management
1. Create multiple identifiers:
- Go to "Your Identity" screen
- Click "Advanced"
- Click "Switch Identity / No Identity"
- Click "Add Another Identity..."
2. Create keys with alternate tools:
- See [openssl_signing_console.rst](openssl_signing_console.rst) for JWT creation with local keypairs
#### Web Push Testing
For web-push tests:
1. Change push server URL in Advanced settings on the account page
2. Install Time Safari & push server on the same domain
#### Manual Walk-through Test Checklist
1. Initial Setup
- Backup seed & data
- Get CSV dump from Endorser Mobile
- Check DB migration compatibility
- Verify version update
2. Environment Setup
- Clear browser data
- Add identity
- Import Time Safari contacts and CSV contacts
- Verify test API usage
3. Fresh Install Testing
- Clear browser data
- Check account page before home page
- Verify ID generation
- Test feed without names
- Verify contact URL copying
- Check messaging on all pages
- Verify project discovery
- Test contact addition without ID
4. PWA Installation
- Install PWA
- Test User 0 functions
- Verify image handling
- Test contact management
- Check feed display
- Verify name visibility
5. Feature Testing
- Test identifier switching
- Check registration limits
- Verify gift recording
- Test offer & delivery
- Check contact registration
- Test notifications
- Verify export/import
- Test location features
- Check third-user connections
- Test mobile image sharing
### Data Reset Instructions
To clear/reset data:
1. Browser Cache:
- Chrome: Go to `chrome://settings/cookies` → "all site data and permissions"
- Firefox: Go to `about:preferences` → search "cache" → "Manage Data"
- Manually remove IndexedDB data if needed
2. Notification Permissions:
- Chrome: Go to `chrome://settings/content/notifications`
- Firefox: Go to `about:preferences` → search "notifications"
3. Service Worker:
- Chrome: Go to `chrome://serviceworker-internals`
- Firefox: Go to `about:serviceworkers`
4. Cache Storage:
- Chrome: Dev tools → Application
- Firefox: Dev tools → Storage
(Additional reset steps may be documented in HelpNotificationsView.vue)
### Troubleshooting
1. Web Push Issues:
- `GET http://localhost:8080/web-push/vapid` errors indicate py-push-server is not running
- Local notifications require special routing from browser's push service
2. Identity Errors:
- "No keys for ID" errors may occur when current account was erased
- Account switching can cause issues with erased accounts
3. Encryption Issues:
- "DEXIE ENCRYPT ADDON: Could not decrypt message!" indicates wrong encryption key
- May occur after clearing storage
- Usually requires storage erasure and identifier reload

8
vite.config.mjs

@ -32,7 +32,13 @@ export default defineConfig(({ mode }) => {
port: process.env.VITE_PORT || 8080,
fs: {
strict: false
}
},
proxy: process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test' ? {
'/api': {
target: process.env.VITE_DEFAULT_ENDORSER_API_SERVER || 'http://localhost:3000',
changeOrigin: true,
},
} : undefined,
},
build: {
outDir: isElectron ? "dist-electron" : "dist",

Loading…
Cancel
Save