dawarich/e2e/README.md
Evgenii Burmakin b1393ee674
0.36.0 (#1952)
* Implement OmniAuth GitHub authentication

* Fix omniauth GitHub scope to include user email access

* Remove margin-bottom

* Implement Google OAuth2 authentication

* Implement OIDC authentication for Dawarich using omniauth_openid_connect gem.

* Add patreon account linking and patron checking service

* Update docker-compose.yml to use boolean values instead of strings

* Add support for KML files

* Add tests

* Update changelog

* Remove patreon OAuth integration

* Move omniauthable to a concern

* Update an icon in integrations

* Update changelog

* Update app version

* Fix family location sharing toggle

* Move family location sharing to its own controller

* Update changelog

* Implement basic tagging functionality for places, allowing users to categorize and label places with custom tags.

* Add places management API and tags feature

* Add some changes related to places management feature

* Fix some tests

* Fix sometests

* Add places layer

* Update places layer to use Leaflet.Control.Layers.Tree for hierarchical layer control

* Rework tag form

* Add hashtag

* Add privacy zones to tags

* Add notes to places and manage place tags

* Update changelog

* Update e2e tests

* Extract tag serializer to its own file

* Fix some tests

* Fix tags request specs

* Fix some tests

* Fix rest of the tests

* Revert some changes

* Add missing specs

* Revert changes in place export/import code

* Fix some specs

* Fix PlaceFinder to only consider global places when finding existing places

* Fix few more specs

* Fix visits creator spec

* Fix last tests

* Update place creating modal

* Add home location based on "Home" tagged place

* Save enabled tag layers

* Some fixes

* Fix bug where enabling place tag layers would trigger saving enabled layers, overwriting with incomplete data

* Update migration to use disable_ddl_transaction! and add up/down methods

* Fix tag layers restoration and filtering logic

* Update OIDC auto-registration and email/password registration settings

* Fix potential xss
2025-11-24 19:45:09 +01:00

4.3 KiB

E2E Tests

End-to-end tests for Dawarich using Playwright.

Running Tests

# Run all tests
npx playwright test

# Run specific test file
npx playwright test e2e/map/map-controls.spec.js

# Run tests in headed mode (watch browser)
npx playwright test --headed

# Run tests in debug mode
npx playwright test --debug

# Run tests sequentially (avoid parallel issues)
npx playwright test --workers=1

# Run only non-destructive tests (safe for production data)
npx playwright test --grep-invert @destructive

# Run only destructive tests (use with caution!)
npx playwright test --grep @destructive

Test Tags

Tests are tagged to enable selective execution:

  • @destructive (22 tests) - Tests that delete or modify data:
    • Bulk delete operations (12 tests)
    • Point deletion (1 test)
    • Visit modification/deletion (3 tests)
    • Suggested visit actions (3 tests)
    • Place creation (3 tests)

Usage:

# Safe for staging/production - run only non-destructive tests
npx playwright test --grep-invert @destructive

# Use with caution - run only destructive tests
npx playwright test --grep @destructive

# Run specific destructive test file
npx playwright test e2e/map/map-bulk-delete.spec.js

Structure

e2e/
├── setup/           # Test setup and authentication
├── helpers/         # Shared helper functions
├── map/             # Map-related tests (40 tests total)
└── temp/            # Playwright artifacts (screenshots, videos)

Test Files

Map Tests (81 tests)

  • map-controls.spec.js - Basic map controls, zoom, tile layers (5 tests)
  • map-layers.spec.js - Layer toggles: Routes, Heatmap, Fog, etc. (8 tests)
  • map-points.spec.js - Point interactions and deletion (4 tests, 1 destructive)
  • map-visits.spec.js - Confirmed visit interactions and management (5 tests, 3 destructive)
  • map-suggested-visits.spec.js - Suggested visit interactions (6 tests, 3 destructive)
  • map-add-visit.spec.js - Add visit control and form (8 tests)
  • map-selection-tool.spec.js - Selection tool functionality (4 tests)
  • map-calendar-panel.spec.js - Calendar panel navigation (9 tests)
  • map-side-panel.spec.js - Side panel (visits drawer) functionality (13 tests)*
  • map-bulk-delete.spec.js - Bulk point deletion (12 tests, all destructive)
  • map-places-creation.spec.js - Creating new places on map (9 tests, 2 destructive)
  • map-places-layers.spec.js - Places layer visibility and filtering (10 tests)

* Some side panel tests may be skipped if demo data doesn't contain visits

Helper Functions

Map Helpers (helpers/map.js)

  • waitForMap(page) - Wait for Leaflet map initialization
  • enableLayer(page, layerName) - Enable a map layer by name
  • clickConfirmedVisit(page) - Click first confirmed visit circle
  • clickSuggestedVisit(page) - Click first suggested visit circle
  • getMapZoom(page) - Get current map zoom level

Navigation Helpers (helpers/navigation.js)

  • closeOnboardingModal(page) - Close getting started modal
  • navigateToDate(page, startDate, endDate) - Navigate to specific date range
  • navigateToMap(page) - Navigate to map page with setup

Selection Helpers (helpers/selection.js)

  • drawSelectionRectangle(page, options) - Draw selection on map
  • enableSelectionMode(page) - Enable area selection tool

Common Patterns

Basic Test Template

import { test, expect } from '@playwright/test';
import { navigateToMap } from '../helpers/navigation.js';
import { waitForMap } from '../helpers/map.js';

test('my test', async ({ page }) => {
  await navigateToMap(page);
  await waitForMap(page);
  // Your test logic
});

Testing Map Layers

import { enableLayer } from '../helpers/map.js';

await enableLayer(page, 'Routes');
await enableLayer(page, 'Heatmap');

Debugging

View Test Artifacts

# Open HTML report
npx playwright show-report

# Screenshots and videos are in:
test-results/

Common Issues

  • Flaky tests: Run with --workers=1 to avoid parallel interference
  • Timeout errors: Increase timeout in test or use page.waitForTimeout()
  • Map not loading: Ensure waitForMap() is called after navigation

CI/CD

Tests run with:

  • 1 worker (sequential)
  • 2 retries on failure
  • Screenshots/videos on failure
  • JUnit XML reports

See playwright.config.js for full configuration.