ee044d03e0
- Add /health endpoint with anonymous access for monitoring - Add FileUploadResult<T> model and PostMultipartForFileResultAsync for proper upload response handling - Add ApiResult.Success() factory method for interface types - Refactor Login.razor for cleaner code - Add comprehensive Playwright E2E test suite with fixtures and helpers
121 lines
3.3 KiB
Markdown
121 lines
3.3 KiB
Markdown
# JDE Scoping Tool - Playwright E2E Tests
|
|
|
|
End-to-end tests for the JDE Scoping Tool using Playwright.
|
|
|
|
## Prerequisites
|
|
|
|
- Node.js 18+
|
|
- The JDE Scoping Tool server running at `http://localhost:5294`
|
|
|
|
## Setup
|
|
|
|
```bash
|
|
# Install dependencies
|
|
npm install
|
|
|
|
# Install Playwright browsers
|
|
npx playwright install chromium
|
|
|
|
# Create test data files
|
|
npm run create-test-data
|
|
```
|
|
|
|
## Running Tests
|
|
|
|
```bash
|
|
# Start the server first (in another terminal)
|
|
cd ../../NEW
|
|
dotnet run --project src/JdeScoping.Host/JdeScoping.Host.csproj
|
|
|
|
# Run all tests
|
|
npm test
|
|
|
|
# Run tests with browser visible
|
|
npm run test:headed
|
|
|
|
# Run tests in debug mode
|
|
npm run test:debug
|
|
|
|
# Run tests with Playwright UI
|
|
npm run test:ui
|
|
```
|
|
|
|
## Test Structure
|
|
|
|
```
|
|
playwright/
|
|
├── package.json # Dependencies
|
|
├── playwright.config.ts # Playwright configuration
|
|
├── scripts/
|
|
│ └── create-test-excel.js # Script to generate test Excel files
|
|
├── test-data/ # Generated test Excel files
|
|
│ ├── single_workorder.xlsx
|
|
│ ├── multiple_workorders.xlsx
|
|
│ ├── single_lot.xlsx
|
|
│ └── ...
|
|
└── tests/
|
|
└── search-page.spec.ts # Search page tests
|
|
```
|
|
|
|
## Test Cases
|
|
|
|
### Work Order Search (TC-010)
|
|
- **TC-010-P01**: Upload single work order ✓
|
|
- **TC-010-P02**: Upload multiple work orders ✓
|
|
- **TC-010-P03**: Download template ✓
|
|
- **TC-010-P04**: Clear data ✓
|
|
|
|
### Component Lot Search (TC-020)
|
|
- **TC-020-P01**: Upload component lot file ✓
|
|
|
|
### Time Span + Profit Center + Item Number (TC-060)
|
|
- **TC-060-P01**: Upload item numbers file ✓
|
|
|
|
### Time Span + Profit Center + Item/Operation/MIS (TC-070)
|
|
- **TC-070-P01**: Upload part operations file ✓
|
|
|
|
## Environment Variables
|
|
|
|
- `BASE_URL`: Override the default URL (default: `http://localhost:5294`)
|
|
|
|
```bash
|
|
BASE_URL=http://localhost:5000 npm test
|
|
```
|
|
|
|
## Authentication
|
|
|
|
The tests automatically handle login using the FakeAuthService in development mode:
|
|
- Username: `testuser`
|
|
- Password: `testpass` (any password works with FakeAuthService)
|
|
|
|
## File Upload Mechanism
|
|
|
|
These tests use Playwright's native `setInputFiles()` method which:
|
|
1. Finds the hidden file input created by RadzenUpload
|
|
2. Sets the file directly on the input element
|
|
3. Triggers the component's change event properly
|
|
|
|
This bypasses the binary encoding issues that occur with JavaScript FormData uploads.
|
|
|
|
## Blazor WASM Considerations
|
|
|
|
Blazor WebAssembly applications require additional time to initialize. The tests include:
|
|
- Extended timeouts (up to 2 minutes for page load)
|
|
- Network idle waits for WASM file downloads
|
|
- Post-login navigation refresh to ensure proper state
|
|
|
|
## Troubleshooting
|
|
|
|
### Tests timeout waiting for page load
|
|
- Ensure the server is running and accessible
|
|
- Check that Blazor WASM files are being served (verify `/_framework/dotnet.*.js` returns 200)
|
|
- Try running in headed mode to see what's happening: `npm run test:headed`
|
|
|
|
### Authentication issues
|
|
- The app uses FakeAuthService in development mode which accepts any credentials
|
|
- If authentication fails, check the server logs for errors
|
|
|
|
### File upload fails
|
|
- Ensure test data files exist: `npm run create-test-data`
|
|
- Verify the file input is accessible (RadzenUpload creates a hidden input)
|