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