@fdm-monster/client-next 2.2.2 → 2.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/.yarn/install-state.gz +0 -0
  2. package/README.md +19 -0
  3. package/RELEASE_NOTES.MD +21 -0
  4. package/dist/assets/index-CvbkNANW.js +105 -0
  5. package/dist/assets/index-CvbkNANW.js.map +1 -0
  6. package/dist/assets/index-DfA7W6iO.css +1 -0
  7. package/dist/index.html +3 -3
  8. package/package.json +21 -2
  9. package/screenshots/COVERAGE.md +383 -0
  10. package/screenshots/README.md +431 -0
  11. package/screenshots/fixtures/api-mock.ts +699 -0
  12. package/screenshots/fixtures/data/auth.fixtures.ts +79 -0
  13. package/screenshots/fixtures/data/cameras.fixtures.ts +48 -0
  14. package/screenshots/fixtures/data/files.fixtures.ts +56 -0
  15. package/screenshots/fixtures/data/floors.fixtures.ts +39 -0
  16. package/screenshots/fixtures/data/jobs.fixtures.ts +172 -0
  17. package/screenshots/fixtures/data/printers.fixtures.ts +132 -0
  18. package/screenshots/fixtures/data/settings.fixtures.ts +62 -0
  19. package/screenshots/fixtures/socketio-mock.ts +76 -0
  20. package/screenshots/fixtures/test-fixtures.ts +112 -0
  21. package/screenshots/helpers/dialog.helper.ts +196 -0
  22. package/screenshots/helpers/form.helper.ts +207 -0
  23. package/screenshots/helpers/navigation.helper.ts +191 -0
  24. package/screenshots/playwright.screenshots.config.ts +70 -0
  25. package/screenshots/suites/00-example.screenshots.spec.ts +29 -0
  26. package/screenshots/suites/01-auth.screenshots.spec.ts +130 -0
  27. package/screenshots/suites/02-dashboard.screenshots.spec.ts +106 -0
  28. package/screenshots/suites/03-printer-grid.screenshots.spec.ts +160 -0
  29. package/screenshots/suites/04-printer-list.screenshots.spec.ts +184 -0
  30. package/screenshots/suites/05-camera-grid.screenshots.spec.ts +127 -0
  31. package/screenshots/suites/06-print-jobs.screenshots.spec.ts +139 -0
  32. package/screenshots/suites/07-queue.screenshots.spec.ts +86 -0
  33. package/screenshots/suites/08-files.screenshots.spec.ts +142 -0
  34. package/screenshots/suites/09-settings.screenshots.spec.ts +130 -0
  35. package/screenshots/suites/10-panels-dialogs.screenshots.spec.ts +245 -0
  36. package/screenshots/utils.ts +216 -0
  37. package/vitest.config.ts +8 -0
  38. package/dist/assets/index-BlOaSQti.js +0 -105
  39. package/dist/assets/index-BlOaSQti.js.map +0 -1
  40. package/dist/assets/index-TeWdSn_6.css +0 -1
@@ -0,0 +1,431 @@
1
+ # FDM Monster Screenshot Automation
2
+
3
+ Automated screenshot generation for FDM Monster documentation using Playwright.
4
+
5
+ ## Overview
6
+
7
+ This directory contains a focused e2e screenshot automation system for generating documentation screenshots. The system:
8
+
9
+ - **Chrome-only**: Focuses on desktop Chrome (1920x1080) for consistency
10
+ - **API Mocking**: All backend API calls are mocked using Playwright route interception
11
+ - **No Backend Required**: Screenshots can be generated without running the FDM Monster backend
12
+ - **Headed Mode Support**: Run tests with visible browser for debugging
13
+ - **Organized Suites**: Tests organized by feature area for easy maintenance
14
+
15
+ ## Quick Start
16
+
17
+ ### 1. Install Chromium
18
+
19
+ ```bash
20
+ yarn playwright:install-chromium
21
+ ```
22
+
23
+ ### 2. Run Screenshot Tests
24
+
25
+ ```bash
26
+ # Run single example test (recommended for first try)
27
+ yarn screenshots:example
28
+
29
+ # Run with visible browser to see it in action
30
+ yarn screenshots:example --headed
31
+
32
+ # Run all screenshot tests (headless)
33
+ yarn screenshots
34
+
35
+ # Run with Playwright UI (interactive mode)
36
+ yarn screenshots:ui
37
+ ```
38
+
39
+ ### 3. View Screenshots
40
+
41
+ Screenshots are saved to `screenshots/output/` organized by feature:
42
+ - `auth/` - Login, registration, first-time setup
43
+ - `dashboard/` - Dashboard views
44
+ - `printer-grid/` - Printer grid screenshots
45
+ - etc.
46
+
47
+ ## Directory Structure
48
+
49
+ ```
50
+ screenshots/
51
+ ├── playwright.screenshots.config.ts # Chrome-only configuration
52
+ ├── fixtures/ # API mocking layer
53
+ │ ├── api-mock.ts # Route interception class
54
+ │ ├── test-fixtures.ts # Custom Playwright fixtures
55
+ │ └── data/ # Mock response data
56
+ │ ├── auth.fixtures.ts
57
+ │ ├── printers.fixtures.ts
58
+ │ ├── floors.fixtures.ts
59
+ │ ├── cameras.fixtures.ts
60
+ │ ├── files.fixtures.ts
61
+ │ ├── jobs.fixtures.ts
62
+ │ └── settings.fixtures.ts
63
+ ├── helpers/ # UI interaction helpers
64
+ │ ├── dialog.helper.ts # Dialog/modal interactions
65
+ │ ├── form.helper.ts # Form filling utilities
66
+ │ └── navigation.helper.ts # Navigation helpers
67
+ ├── suites/ # Test suites by feature
68
+ │ ├── 00-example.screenshots.spec.ts # Simple example to get started
69
+ │ ├── 01-auth.screenshots.spec.ts
70
+ │ ├── 02-dashboard.screenshots.spec.ts
71
+ │ └── ... (more suites to be added)
72
+ ├── utils.ts # Screenshot utilities
73
+ ├── output/ # Generated screenshots (gitignored)
74
+ └── README.md # This file
75
+ ```
76
+
77
+ ## Available Scripts
78
+
79
+ | Script | Description |
80
+ |--------|-------------|
81
+ | `yarn screenshots` | Run all screenshot tests (headless) |
82
+ | `yarn screenshots:headed` | Run with visible browser window |
83
+ | `yarn screenshots:debug` | Run in debug mode with Playwright Inspector |
84
+ | `yarn screenshots:ui` | Open Playwright UI for interactive testing |
85
+ | `yarn screenshots:chrome` | Explicitly run Chrome project only |
86
+ | `yarn screenshots:example` | Run single example test (great for testing setup) |
87
+ | `yarn screenshots:auth` | Run authentication suite (login, register, first-time setup) |
88
+ | `yarn screenshots:dashboard` | Run dashboard suite |
89
+ | `yarn screenshots:printer-grid` | Run printer grid suite (grid views, creating floor/printer, drag operations) |
90
+ | `yarn screenshots:printer-list` | Run printer list suite (list view, attaching floor/camera/tag) |
91
+ | `yarn screenshots:cameras` | Run camera grid suite |
92
+ | `yarn screenshots:jobs` | Run print jobs suite (jobs list, job details dialog) |
93
+ | `yarn screenshots:queue` | Run queue suite |
94
+ | `yarn screenshots:files` | Run files suite (file browser, upload, operations) |
95
+ | `yarn screenshots:settings` | Run settings suite (all settings pages) |
96
+ | `yarn screenshots:dialogs` | Run panels and dialogs suite (YAML import/export, menus, dialogs) |
97
+ | `yarn screenshots:ci` | Run in CI mode (expects dev server running separately) |
98
+
99
+ ## Writing Screenshot Tests
100
+
101
+ ### Basic Test Structure
102
+
103
+ See `suites/00-example.screenshots.spec.ts` for a complete working example. Here's the pattern:
104
+
105
+ ```typescript
106
+ import { test, expect } from '../fixtures/test-fixtures';
107
+ import { captureFullPage } from '../utils';
108
+ import { createNavigationHelper } from '../helpers/navigation.helper';
109
+
110
+ test('example-dashboard-screenshot', async ({ authenticatedPage, apiMock }) => {
111
+ // 1. Mock all API endpoints with default data
112
+ await apiMock.mockAllEndpoints({ loginRequired: false });
113
+
114
+ // 2. Navigate to the page you want to capture
115
+ const nav = createNavigationHelper(authenticatedPage);
116
+ await nav.goToDashboard();
117
+
118
+ // 3. Wait for content to load
119
+ await authenticatedPage.waitForSelector('main, [data-testid="dashboard"]', {
120
+ timeout: 5000,
121
+ }).catch(() => {});
122
+
123
+ // 4. Optional: wait a bit more for animations/dynamic content
124
+ await authenticatedPage.waitForTimeout(1000);
125
+
126
+ // 5. Capture the screenshot
127
+ await captureFullPage(authenticatedPage, 'example-dashboard.png', 'examples');
128
+ });
129
+ ```
130
+
131
+ **Run this example:**
132
+ ```bash
133
+ yarn screenshots:example --headed
134
+ ```
135
+
136
+ ### Using Fixtures
137
+
138
+ The test suite provides custom fixtures:
139
+
140
+ - **`apiMock`** - API mocking instance for route interception
141
+ - **`authenticatedPage`** - Pre-authenticated page with mocked auth tokens
142
+ - **`mockPrinters`**, **`mockFloors`**, etc. - Access to mock data
143
+
144
+ Example:
145
+
146
+ ```typescript
147
+ test('example-test', async ({ authenticatedPage, apiMock, mockPrinters }) => {
148
+ // Mock printer endpoints with custom data
149
+ await apiMock.mockPrinterEndpoints();
150
+
151
+ // mockPrinters contains the default mock printer data
152
+ console.log(`Testing with ${mockPrinters.length} printers`);
153
+
154
+ // authenticatedPage is already authenticated
155
+ await authenticatedPage.goto('/printers');
156
+ });
157
+ ```
158
+
159
+ ### Using Helpers
160
+
161
+ #### Navigation Helper
162
+
163
+ ```typescript
164
+ import { createNavigationHelper } from '../helpers/navigation.helper';
165
+
166
+ const nav = createNavigationHelper(page);
167
+ await nav.goToDashboard();
168
+ await nav.goToPrinterGrid();
169
+ await nav.goToSettings('server');
170
+ ```
171
+
172
+ #### Dialog Helper
173
+
174
+ ```typescript
175
+ import { createDialogHelper } from '../helpers/dialog.helper';
176
+
177
+ const dialog = createDialogHelper(page);
178
+ await dialog.waitForDialog();
179
+ await dialog.submitDialog();
180
+ await dialog.closeDialog();
181
+ ```
182
+
183
+ #### Form Helper
184
+
185
+ ```typescript
186
+ import { createFormHelper } from '../helpers/form.helper';
187
+
188
+ const form = createFormHelper(page);
189
+ await form.fillPrinterForm({
190
+ name: 'Test Printer',
191
+ printerURL: 'http://192.168.1.100',
192
+ apiKey: 'test-key'
193
+ });
194
+ await form.fillLoginForm('username', 'password');
195
+ ```
196
+
197
+ ## API & WebSocket Mocking
198
+
199
+ ### Automatic SocketIO Mocking
200
+
201
+ **All tests automatically disable Socket.IO connections** to prevent "server disconnected" messages. This is handled transparently by the test fixtures - no additional setup needed!
202
+
203
+ The approach:
204
+ - Sets `window.__DISABLE_SOCKETIO__` and `window.__SCREENSHOT_MODE__` flags before page loads
205
+ - App code checks these flags and skips Socket.IO setup entirely (see `src/shared/socketio.service.ts`)
206
+ - Blocks Socket.IO polling endpoints at network level as fallback
207
+ - Hides any "Server Disconnected" UI messages that might appear
208
+ - Prevents connection errors and retry loops completely
209
+
210
+ ### Mock All API Endpoints
211
+
212
+ ```typescript
213
+ test('example', async ({ page, apiMock }) => {
214
+ // Mock all endpoints with default data
215
+ await apiMock.mockAllEndpoints();
216
+
217
+ // Or with options
218
+ await apiMock.mockAllEndpoints({
219
+ loginRequired: true,
220
+ emptyData: true,
221
+ });
222
+ });
223
+ ```
224
+
225
+ ### Mock Specific Endpoints
226
+
227
+ ```typescript
228
+ test('example', async ({ page, apiMock }) => {
229
+ // Mock only auth endpoints
230
+ await apiMock.mockAuthEndpoints({ loginRequired: true });
231
+
232
+ // Mock only printer endpoints
233
+ await apiMock.mockPrinterEndpoints({ empty: false });
234
+
235
+ // Mock floor endpoints
236
+ await apiMock.mockFloorEndpoints();
237
+ });
238
+ ```
239
+
240
+ ### Customize Mock Data
241
+
242
+ Edit fixture files in `fixtures/data/` to customize mock responses:
243
+
244
+ - `auth.fixtures.ts` - Authentication responses
245
+ - `printers.fixtures.ts` - Printer data and states
246
+ - `floors.fixtures.ts` - Floor layouts
247
+ - `cameras.fixtures.ts` - Camera streams
248
+ - `files.fixtures.ts` - File listings
249
+ - `jobs.fixtures.ts` - Print jobs and queue
250
+ - `settings.fixtures.ts` - Server and user settings
251
+
252
+ ## Screenshot Utilities
253
+
254
+ Located in `utils.ts`:
255
+
256
+ ```typescript
257
+ // Full page screenshot
258
+ await captureFullPage(page, 'filename.png', 'subdirectory');
259
+
260
+ // Viewport screenshot (above the fold)
261
+ await captureViewport(page, 'filename.png', 'subdirectory');
262
+
263
+ // Element screenshot
264
+ await captureElement(page, '[data-testid="element"]', 'filename.png', 'subdirectory');
265
+
266
+ // Wait for page to be ready (network idle + animations)
267
+ await waitForPageReady(page, 1000);
268
+ ```
269
+
270
+ ## Debugging
271
+
272
+ ### Run in Headed Mode
273
+
274
+ See the browser in action:
275
+
276
+ ```bash
277
+ yarn screenshots:headed
278
+ ```
279
+
280
+ ### Use Playwright UI
281
+
282
+ Interactive mode with time-travel debugging:
283
+
284
+ ```bash
285
+ yarn screenshots:ui
286
+ ```
287
+
288
+ ### Debug Specific Test
289
+
290
+ Step through a specific test:
291
+
292
+ ```bash
293
+ yarn screenshots:debug suites/01-auth
294
+ ```
295
+
296
+ ### View Playwright Report
297
+
298
+ After a test run:
299
+
300
+ ```bash
301
+ npx playwright show-report screenshots/playwright-report
302
+ ```
303
+
304
+ ## CI/CD Integration
305
+
306
+ ### Run in CI
307
+
308
+ The `screenshots:ci` script expects the dev server to be running separately:
309
+
310
+ ```bash
311
+ # Terminal 1: Start dev server
312
+ yarn dev
313
+
314
+ # Terminal 2: Run screenshot tests
315
+ yarn screenshots:ci
316
+ ```
317
+
318
+ ### GitHub Actions Example
319
+
320
+ ```yaml
321
+ - name: Install dependencies
322
+ run: yarn install
323
+
324
+ - name: Install Chromium
325
+ run: npx playwright install --with-deps chromium
326
+
327
+ - name: Start dev server and run screenshots
328
+ run: |
329
+ yarn dev &
330
+ npx wait-on http://localhost:3000
331
+ yarn screenshots:ci
332
+
333
+ - name: Upload screenshots
334
+ uses: actions/upload-artifact@v4
335
+ with:
336
+ name: documentation-screenshots
337
+ path: screenshots/output/
338
+ ```
339
+
340
+ ## Best Practices
341
+
342
+ 1. **Naming Convention**: Use descriptive filenames like `printer-grid-with-printers.png`
343
+ 2. **Organize by Feature**: Save screenshots to appropriate subdirectories
344
+ 3. **Wait for Content**: Always wait for content to load before capturing
345
+ 4. **Mock Consistently**: Use the same mock data across related tests
346
+ 5. **Test Independence**: Each test should be self-contained and not depend on others
347
+ 6. **Numbered Tests**: Prefix test names with numbers for execution order clarity
348
+
349
+ ## Troubleshooting
350
+
351
+ ### "Server disconnected" messages appear
352
+
353
+ This should be automatically handled by SocketIO mocking in the test fixtures. If you still see these messages:
354
+
355
+ 1. Verify you're using the custom `test` from `../fixtures/test-fixtures`
356
+ 2. Check browser console for: `[Mock] Socket.IO disabled via test flags`
357
+ 3. Ensure the page fixture is being used (it applies SocketIO mocking automatically)
358
+ 4. Verify the app code has the test flag checks in `src/shared/socketio.service.ts`
359
+
360
+ ### Screenshots are blank or show loading spinners
361
+
362
+ Ensure you're waiting for content to load:
363
+
364
+ ```typescript
365
+ await page.waitForSelector('[data-testid="content"]');
366
+ await waitForPageReady(page);
367
+ ```
368
+
369
+ ### API calls are not being mocked
370
+
371
+ Verify mocking is set up before navigation:
372
+
373
+ ```typescript
374
+ // Mock BEFORE navigating
375
+ await apiMock.mockAllEndpoints();
376
+ await page.goto('/path');
377
+ ```
378
+
379
+ ### Dialog not found
380
+
381
+ Dialogs may use different selectors. Check the helper or use a custom selector:
382
+
383
+ ```typescript
384
+ await dialog.waitForDialog('.custom-dialog-class');
385
+ ```
386
+
387
+ ### Tests fail on CI but pass locally
388
+
389
+ Check that:
390
+ - Dev server is running in CI
391
+ - Network timeout settings are appropriate
392
+ - Mock data is consistent
393
+
394
+ ## Future Enhancements
395
+
396
+ - Responsive testing (mobile/tablet viewports)
397
+ - Visual regression testing (screenshot comparison)
398
+ - Real backend integration (optional Docker support)
399
+ - Mock printer containers (OctoPrint simulators)
400
+ - WebSocket mocking for real-time updates
401
+ - Light/dark theme variations
402
+
403
+ ## Coverage Summary
404
+
405
+ All test suites have been implemented covering all pages and features from `screenshots.md`:
406
+
407
+ ### Completed Suites
408
+
409
+ - ✅ **00-example** - Simple working example for testing setup
410
+ - ✅ **01-auth** - Login, registration, first-time setup wizard (5 tests)
411
+ - ✅ **02-dashboard** - Dashboard views with stats (4 tests)
412
+ - ✅ **03-printer-grid** - Grid views, creating floor/printer, drag operations, batch bar, context menus (7 tests)
413
+ - ✅ **04-printer-list** - List view, creating printer, attaching floor/camera/tag (8 tests)
414
+ - ✅ **05-camera-grid** - Camera grid, creating camera, fullscreen view (6 tests)
415
+ - ✅ **06-print-jobs** - Jobs list, job details dialog, filtering by status (7 tests)
416
+ - ✅ **07-queue** - Queue view, reordering, context menus (5 tests)
417
+ - ✅ **08-files** - File browser, upload, grid/list views, file operations (8 tests)
418
+ - ✅ **09-settings** - All settings pages: overview, floors, printer, emergency commands, server protection, user management, account, software upgrade, diagnostics, experimental, slicer, debug socket, about (13 tests)
419
+ - ✅ **10-panels-dialogs** - YAML import/export, OctoFarm import, menus, printer dialogs (create, update, duplicate, test connection, type dropdown, force save), edit floor, delete confirmation (13 tests)
420
+
421
+ **Total: 76 screenshot tests covering all pages and dialogs**
422
+
423
+ ## Resources
424
+
425
+ - [Playwright Documentation](https://playwright.dev/)
426
+ - [Playwright Screenshots Guide](https://playwright.dev/docs/screenshots)
427
+ - [Playwright Best Practices](https://playwright.dev/docs/best-practices)
428
+
429
+ ## License
430
+
431
+ AGPL-3.0-or-later