|
1 week ago | |
---|---|---|
.. | ||
.eslintrc.js | 1 year ago | |
00-noid-tests.spec.ts | 2 weeks ago | |
03-duplicate-import-test.spec.ts | 3 weeks ago | |
05-invite.spec.ts | 2 weeks ago | |
10-check-usage-limits.spec.ts | 2 months ago | |
20-create-project.spec.ts | 7 months ago | |
25-create-project-x10.spec.ts | 7 months ago | |
30-record-gift.spec.ts | 2 weeks ago | |
33-record-gift-x10.spec.ts | 4 weeks ago | |
35-record-gift-from-image-share.spec.ts | 2 months ago | |
37-record-gift-on-project.spec.ts | 10 months ago | |
40-add-contact.spec.ts | 2 months ago | |
50-record-offer.spec.ts | 2 weeks ago | |
60-new-activity.spec.ts | 1 week ago | |
LICENSE | 10 months ago | |
README.md | 2 weeks ago | |
TESTING.md | 2 weeks ago | |
exported-data.json | 1 year ago | |
testUtils.ts | 2 weeks ago |
README.md
Playwright Test Suite
This directory contains the automated end-to-end test suite for Time Safari using Playwright. The tests verify critical functionality across web and mobile platforms.
Test Structure
Tests are organized by feature area and numbered for execution order:
00-noid-tests.spec.ts
- Tests for unregistered users05-invite.spec.ts
- Contact invitation functionality10-check-usage-limits.spec.ts
- Usage limit verification20-create-project.spec.ts
- Project creation25-create-project-x10.spec.ts
- Bulk project creation30-record-gift.spec.ts
- Gift recording33-record-gift-x10.spec.ts
- Bulk gift recording35-record-gift-from-image-share.spec.ts
- Gift recording from shared images37-record-gift-on-project.spec.ts
- Project-specific gift recording40-add-contact.spec.ts
- Contact management50-record-offer.spec.ts
- Offer recording60-new-activity.spec.ts
- Activity feed updates
Key Files
testUtils.ts
- Shared test utilities and helper functionsTESTING.md
- Detailed testing guide and manual test proceduresplaywright.config-local.ts
- Playwright configuration for local testingexported-data.json
- Test data for import/export testing
Prerequisites
-
Endorser server running locally (see TESTING.md for setup)
git clone https://github.com/time-endorser/endorser-ch.git cd endorser-ch npm install test/test.sh cp .env.local .env NODE_ENV=test-local npm run dev
-
Playwright browsers installed:
npx playwright install
-
For mobile testing:
- XCode (for iOS)
- Android Studio or connected Android device
Running Tests
Full Test Suite
# Run all tests (web + mobile)
npm run test:all
# Run web-only tests
npm run test:web
Individual Tests
# Run a specific test with tracing
npx playwright test -c playwright.config-local.ts --trace on test-playwright/40-add-contact.spec.ts
Test Environment Options
-
Local Endorser Server (default):
NODE_ENV=test-local npm run dev
-
Global Test Server:
VITE_DEFAULT_ENDORSER_API_SERVER=https://test-ledger.time.com npm run dev
-
Minimal Test Data:
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 Data
The test suite uses predefined test users, with User #0 having registration privileges. To use it: Profile -> Advanced -> Switch Identifier -> Add Another Identity -> You Have A Seed -> Advanced -> Use mnemonic for Test User #0 -> Import
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
-
Test Timeout: 45 seconds (configured in
playwright.config-local.ts
)- Maximum time for entire test to complete
- Test fails if exceeded
-
Expect Timeout: 5 seconds (Playwright default)
- Maximum time for assertions (
expect()
) to pass - Test fails if assertion doesn't pass within timeout
- Maximum time for assertions (
-
Action Timeout: No default limit
- Maximum time for actions (
click()
,fill()
, etc.) - Can be set per action if needed
- Maximum time for actions (
-
Function Timeout: Specified per
waitForFunction()
call- Example:
{ timeout: 5000 }
= 5 seconds - Test will fail if function doesn't return true within timeout
- Example:
Common Timeout Patterns in Tests
// 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:
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
- Check Test Logs: Look for timeout error messages
- Run with Tracing:
--trace on
to see detailed execution - Run Headed:
--headed
to watch test execution visually - Check Server Logs: Verify backend is responding
- Increase Timeout: Temporarily increase timeout to see if it's a performance issue
Troubleshooting
Common issues and solutions:
-
Test Failures
- 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
-
Mobile Testing
- Ensure XCode/Android Studio is running
- Check device connectivity
- Verify browser installation
-
Data Issues
- Clear browser data if tests fail due to stale state
- Reset IndexedDB if needed
- Check service worker status
-
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
When adding new tests:
- Follow the existing naming convention
- Use testUtils.ts for common operations
- Add appropriate comments and documentation
- Update this README if adding new test categories
- Consider both web and mobile platforms
Related Documentation
- TESTING.md - Detailed testing guide
- Playwright Documentation
- Endorser server documentation for test setup