refactor: improve logging levels and environment configuration

- Fix logging levels: change verbose debugging from info to debug level
  - TestView: component mounting, boot-time config, URL flow testing
  - main.capacitor.ts: deeplink processing steps and router state
  - HomeView: API call details, component state updates, template rendering

- Remove redundant environment variable override in vite.config.common.mts
  - Environment loading via dotenv works correctly
  - Manual override was defensive programming but unnecessary
  - Simplifies configuration and reduces maintenance burden

- Add comprehensive Playwright timeout behavior documentation
  - README.md: detailed timeout types, failure behavior, debugging guide
  - TESTING.md: timeout failure troubleshooting and common scenarios
  - Clarifies that timeout failures indicate real issues, not flaky tests

- Fix TypeScript configuration for .mts imports
  - tsconfig.node.json: add allowImportingTsExtensions for Vite config files
  - Resolves import path linting errors for .mts extensions

All changes maintain existing functionality while improving code quality
and reducing log noise in production environments.
This commit is contained in:
Matthew Raymer
2025-09-05 04:02:53 +00:00
parent 10a1f435ed
commit b57be7670c
7 changed files with 131 additions and 20 deletions

View File

@@ -97,6 +97,69 @@ The test suite uses predefined test users, with User #0 having registration priv
More details available in TESTING.md
## Timeout Behavior
**Important**: Playwright tests will fail if any operation exceeds its specified timeout. This is intentional behavior to catch performance issues and ensure tests don't hang indefinitely.
### Timeout Types and Defaults
1. **Test Timeout**: 45 seconds (configured in `playwright.config-local.ts`)
- Maximum time for entire test to complete
- Test fails if exceeded
2. **Expect Timeout**: 5 seconds (Playwright default)
- Maximum time for assertions (`expect()`) to pass
- Test fails if assertion doesn't pass within timeout
3. **Action Timeout**: No default limit
- Maximum time for actions (`click()`, `fill()`, etc.)
- Can be set per action if needed
4. **Function Timeout**: Specified per `waitForFunction()` call
- Example: `{ timeout: 5000 }` = 5 seconds
- **Test will fail if function doesn't return true within timeout**
### Common Timeout Patterns in Tests
```typescript
// Wait for UI element to appear (5 second timeout)
await page.waitForFunction(() => {
const buttons = document.querySelectorAll('div[role="alert"] button');
return Array.from(buttons).some(button => button.textContent?.includes('No'));
}, { timeout: 5000 });
// If this times out, the test FAILS immediately
```
### Why Tests Fail on Timeout
- **Performance Issues**: Slow UI rendering or network requests
- **Application Bugs**: Missing elements or broken functionality
- **Test Environment Issues**: Server not responding or browser problems
- **Race Conditions**: Elements not ready when expected
### Timeout Configuration
To adjust timeouts for specific tests:
```typescript
test('slow test', async ({ page }) => {
test.setTimeout(120000); // 2 minutes for entire test
await expect(page.locator('button')).toBeVisible({ timeout: 15000 }); // 15 seconds for assertion
await page.click('button', { timeout: 10000 }); // 10 seconds for action
});
```
### Debugging Timeout Failures
1. **Check Test Logs**: Look for timeout error messages
2. **Run with Tracing**: `--trace on` to see detailed execution
3. **Run Headed**: `--headed` to watch test execution visually
4. **Check Server Logs**: Verify backend is responding
5. **Increase Timeout**: Temporarily increase timeout to see if it's a performance issue
## Troubleshooting
Common issues and solutions:
@@ -105,6 +168,7 @@ Common issues and solutions:
- Some tests may fail intermittently - try rerunning
- Check Endorser server logs for backend issues
- Verify test environment setup
- **Timeout failures indicate real performance or functionality issues**
2. **Mobile Testing**
- Ensure XCode/Android Studio is running
@@ -116,6 +180,12 @@ Common issues and solutions:
- Reset IndexedDB if needed
- Check service worker status
4. **Timeout Issues**
- Check if UI elements are loading slowly
- Verify server response times
- Consider if timeout values are appropriate for the operation
- Use `--headed` mode to visually debug timeout scenarios
For more detailed troubleshooting, see TESTING.md.
## Contributing

View File

@@ -85,13 +85,57 @@ mkdir -p profiles/dev2 && \
firefox --no-remote --profile $(realpath profiles/dev2) --devtools --new-window http://localhost:8080
```
## Timeout Behavior
**Critical Understanding**: Playwright tests will **fail immediately** if any timeout is exceeded. This is intentional behavior to catch performance issues and ensure tests don't hang indefinitely.
### Key Timeout Facts
- **Test Timeout**: 45 seconds (entire test must complete)
- **Expect Timeout**: 5 seconds (assertions must pass)
- **Function Timeout**: As specified (e.g., `{ timeout: 5000 }` = 5 seconds)
- **Action Timeout**: No default limit (can be set per action)
### What Happens on Timeout
```typescript
// This will FAIL the test if buttons don't appear within 5 seconds
await page.waitForFunction(() => {
const buttons = document.querySelectorAll('div[role="alert"] button');
return Array.from(buttons).some(button => button.textContent?.includes('No'));
}, { timeout: 5000 });
```
**If timeout exceeded**: Test fails immediately with `TimeoutError` - no recovery, no continuation.
### Debugging Timeout Failures
1. **Visual Debugging**: Run with `--headed` to watch test execution
2. **Tracing**: Use `--trace on` for detailed execution logs
3. **Server Check**: Verify Endorser server is responding quickly
4. **Performance**: Check if UI elements are loading slowly
5. **Timeout Adjustment**: Temporarily increase timeout to isolate performance vs functionality issues
### Common Timeout Scenarios
- **UI Elements Not Appearing**: Check if alerts/dialogs are rendering correctly
- **Network Delays**: Verify server response times
- **Race Conditions**: Elements not ready when expected
- **Browser Issues**: Slow rendering or JavaScript execution
## Troubleshooting
1. Identity Errors:
- "No keys for ID" errors may occur when current account was erased
- Account switching can cause issues with erased accounts
2. If you find yourself wanting to see the testing process try something like this:
2. **Timeout Failures**:
- **These are NOT flaky tests** - they indicate real performance or functionality issues
- Check server logs for slow responses
- Verify UI elements are rendering correctly
- Use `--headed` mode to visually debug the issue
3. If you find yourself wanting to see the testing process try something like this:
```
npx playwright test -c playwright.config-local.ts test-playwright/60-new-activity.spec.ts --grep "New offers for another user" --headed