This document explains how to run tests that verify URL parameters are correctly applied to the password generator.
We've implemented two main types of tests:
- Unit Tests - Testing the URL parameter parsing in isolation
- End-to-End Tests - Testing the complete flow including:
- URL parameter processing and application
- UI controls reflecting parameter values
- Generated passwords adhering to constraints
- Network monitoring functionality
Unit tests verify that the getParamsFromURL function correctly parses URL parameters and returns the expected settings object.
# Run unit tests
npm test
# Run unit tests in watch mode
npm run test:watchEnd-to-end tests use Playwright to verify the application's behavior from a user's perspective.
Before running E2E tests, you need to start the development server:
# Start the development server
npm run dev
# In a separate terminal, run E2E tests
npm run test:e2e
# Alternatively, run E2E tests with UI
npm run test:e2e:uiYou can manually test URL parameters by appending them to your localhost URL:
http://localhost:5173/?len=24
http://localhost:5173/?exLower&exNum
This excludes lowercase letters and numbers.
http://localhost:5173/?exc=abc123
This excludes the characters a, b, c, 1, 2, and 3.
http://localhost:5173/?len=32&exSym&exc=%40%23%24
This sets length to 32, excludes symbols, and specifically excludes @, #, and $ (URL encoded).
http://localhost:5173/?ruleNoLead&len=15
This applies the rule to disallow leading numbers/symbols and sets length to 15.
http://localhost:5173/?len=18&exUpper&exSym&ruleNoLead&exc=xyz789
This sets length to 18, excludes uppercase letters and symbols, disallows leading numbers/symbols, and excludes the characters x, y, z, 7, 8, and 9.
Our end-to-end tests also verify the network monitoring functionality:
- When a user clicks "Ping Google", the request should be logged in the network monitor
- The response should appear in the log with latency information
- A success message with latency should be displayed in the UI
When URL parameters are present:
- The application should read the parameters on initial load
- The UI controls should reflect the parameter values
- The generated password should adhere to the constraints specified by the parameters
Changes to options after initial load should NOT update the URL - this is intended behavior based on the current implementation.
When using the network monitoring panel:
- Clicking "Ping Google" should send a HEAD request
- The request should appear in the network log
- The response should appear in the network log with latency information
- A success message with latency should be displayed