## Features Implemented ### 1. Event Rename Functionality - Add EventRenameDialog component with live slug preview - Create eventRenameService for safe event renaming - Add slug_redirects table for old URL redirects - Support optional email notification on rename - Fix date formatting in slug (YYYY-MM-DD format) ### 2. Optional Event Contact Fields - Add settings to make customer name/email/admin email optional - Create migration for field requirement settings - Update CreateEventPage forms to show "(optional)" labels - Fix boolean parsing in publicSettings.js ### 3. Photo Filtering & Export - Add PhotoFilterPanel with rating/likes/favorites/comments filters - Create PhotoExportMenu with ZIP/metadata/XMP export options - Add photoExportService with Lightroom XMP sidecar generation - Create photoFilterBuilder utility for query construction - Wire up photo selection to export button via onSelectionChange ### 4. Custom CSS Gallery Templates - Add CssTemplateEditor component with 3 template slots - Create cssSanitizer utility blocking XSS vectors - Add gallery CSS endpoint for template delivery - Integrate Custom CSS tab into Settings page - Include default "Elegant Dark" template ## Bug Fixes - Fix event rename date formatting (was showing full Date string) - Fix common.optional translation key missing in locales - Fix photo export button staying disabled when photos selected - Fix authService import missing in SettingsPage ## Documentation - Add comprehensive REFACTORING_PLAN.md for codebase improvement - Add test specification documents for all features - Add feature documentation for CSS templates ## Database Migrations - 049_add_slug_redirects.js - 050_add_optional_event_fields_settings.js - 051_add_photo_filter_indexes.js - 052_add_css_templates.js
8.0 KiB
Test Specification: Custom CSS Gallery Templates
This document specifies the test cases for the Custom CSS Gallery Templates feature, which allows administrators to create and manage up to 3 custom CSS templates for gallery styling.
Prerequisites
- Local Docker environment running (
docker-compose up) - Access to admin dashboard
- Backend migrations applied (052_add_css_templates.js)
Test Cases
1. Template Editor Access
TC-CCT-001: Access CSS Templates Tab
Steps:
- Navigate to Settings page
- Look for "Custom CSS Templates" or "Styling" section
Expected Result:
- CSS Templates editor is accessible
- Three template slots are visible as tabs
TC-CCT-002: Default Template Content
Steps:
- Navigate to CSS Templates editor
- Select Template 1 tab
Expected Result:
- Template 1 named "Elegant Dark"
- Contains pre-populated CSS content
- Is marked as enabled
- Is marked as default
2. Template Editing
TC-CCT-003: Edit Template Name
Steps:
- Select Template 2
- Change name from "Untitled" to "My Custom Theme"
- Save template
Expected Result:
- Name updates in tab
- Save confirmation shown
- Name persists after refresh
TC-CCT-004: Edit CSS Content
Steps:
- Select Template 2
- Add CSS:
.gallery-page { background: #ff0000; } - Save template
Expected Result:
- CSS saved successfully
- No sanitization warnings for valid CSS
- Character count updates
TC-CCT-005: Enable/Disable Template
Steps:
- Select Template 2
- Toggle "Enable this template" checkbox
- Save template
Expected Result:
- Template status changes
- Tab shows check mark when enabled
- Disabled templates not available in event form
3. CSS Sanitization
TC-CCT-006: Block JavaScript Expressions
Steps:
- Enter CSS with
expression(alert('xss')) - Save template
Expected Result:
- Pattern blocked (replaced with /* BLOCKED */)
- Sanitization warning shown
- Template saves with sanitized content
TC-CCT-007: Block @import Rules
Steps:
- Enter CSS with
@import url('http://evil.com/styles.css'); - Save template
Expected Result:
- @import blocked
- Warning shown
- External resource not loaded
TC-CCT-008: Block External URLs
Steps:
- Enter CSS with
background-image: url('http://external.com/image.jpg'); - Save template
Expected Result:
- External URL blocked
- Only data: URIs allowed for images
- Warning shown
TC-CCT-009: Allow Safe CSS Properties
Steps:
- Enter CSS with standard properties:
.gallery-page { background-color: #333; color: white; font-family: Arial, sans-serif; padding: 20px; } - Save template
Expected Result:
- All properties saved as-is
- No sanitization warnings
- CSS valid
4. Template Size Limits
TC-CCT-010: CSS Size Limit
Steps:
- Try to save CSS content > 100KB
- Attempt to save
Expected Result:
- Error message about size limit
- Template not saved
- User informed of 100KB limit
5. Reset to Default
TC-CCT-011: Reset Template 1
Steps:
- Modify Template 1 CSS
- Save changes
- Click "Reset to Default"
- Confirm action
Expected Result:
- Template reverts to default "Elegant Dark" content
- Name reset to "Elegant Dark"
- Enable status reset to true
TC-CCT-012: Reset Button Only on Template 1
Steps:
- Select Template 2
- Look for Reset button
Expected Result:
- Reset to Default button NOT shown for Template 2 or 3
- Only Template 1 has reset option
6. Event Integration
TC-CCT-013: Template Dropdown in Event Form
Steps:
- Enable at least one CSS template
- Navigate to Create Event page
- Look for CSS Template selector
Expected Result:
- Dropdown shows "None (Use default theme)" option
- Enabled templates appear in list
- Disabled templates NOT shown
TC-CCT-014: Assign Template to Event
Steps:
- Create new event
- Select an enabled CSS template
- Save event
Expected Result:
- Event created with template assigned
- Template ID stored in database
- Event edit shows selected template
TC-CCT-015: Update Event Template
Steps:
- Edit existing event
- Change CSS template selection
- Save event
Expected Result:
- Template updated successfully
- Gallery reflects new template
7. Gallery CSS Loading
TC-CCT-016: Gallery Loads Custom CSS
Steps:
- Assign template to an event
- View gallery as guest
- Inspect page source/styles
Expected Result:
- Custom CSS injected via
<style id="gallery-custom-css"> - Gallery styling matches template
- CSS scoped to .gallery-page
TC-CCT-017: Gallery Without Template
Steps:
- Create event without template (select "None")
- View gallery
Expected Result:
- No custom CSS loaded
- Default theme used
- No errors
TC-CCT-018: Disabled Template Not Applied
Steps:
- Assign template to event
- Disable the template in settings
- View gallery
Expected Result:
- Custom CSS NOT loaded
- Gallery uses default styling
- No errors
8. API Tests
TC-CCT-019: Get All Templates
Steps:
- Call API:
GET /api/admin/css-templates
Expected Result:
- Returns array of 3 templates
- Each has: id, slot_number, name, css_content, is_enabled, is_default, updated_at
TC-CCT-020: Get Enabled Templates
Steps:
- Call API:
GET /api/admin/css-templates/enabled
Expected Result:
- Returns only enabled templates
- Each has: id, name, slot_number
TC-CCT-021: Update Template
Steps:
- Call API:
PUT /api/admin/css-templates/2Body:{ "name": "Test", "css_content": "...", "is_enabled": true }
Expected Result:
- Returns 200 OK
- Template updated
- Sanitization warnings array included
TC-CCT-022: Gallery CSS Endpoint
Steps:
- Assign template to event with slug "test-gallery"
- Call API:
GET /api/gallery/test-gallery/css-template
Expected Result:
- Returns 200 OK with Content-Type: text/css
- Body contains sanitized CSS content
TC-CCT-023: Gallery CSS Not Found
Steps:
- Create event without template
- Call API:
GET /api/gallery/no-template-event/css-template
Expected Result:
- Returns 204 No Content
- No body
9. Edge Cases
TC-CCT-024: Empty CSS Content
Steps:
- Save template with empty CSS content
- Assign to event
- View gallery
Expected Result:
- Template saves successfully
- Gallery loads without custom CSS
- No errors
TC-CCT-025: Invalid CSS Syntax
Steps:
- Enter CSS with mismatched braces:
{ color: red; - Try to save
Expected Result:
- Validation error shown
- Template not saved
- Error message indicates syntax issue
10. Persistence Tests
TC-CCT-026: Template Persists After Restart
Steps:
- Create and save custom template
- Restart backend container
- Reload template editor
Expected Result:
- Template content preserved
- All settings intact
- No data loss
Files Created/Modified
Backend
/backend/migrations/core/052_add_css_templates.js/backend/src/utils/cssSanitizer.js/backend/src/routes/adminCssTemplates.js/backend/src/routes/gallery.js/backend/server.js
Frontend
/frontend/src/services/cssTemplates.service.ts/frontend/src/components/admin/CssTemplateEditor.tsx/frontend/src/components/admin/index.ts/frontend/src/hooks/useGalleryCustomCss.ts
Integration Notes
The following additional integrations are recommended:
- Add CssTemplateEditor to Settings page styling tab
- Add CSS template dropdown to CreateEventPageEnhanced.tsx
- Add CSS template dropdown to CreateEventPage.tsx
- Update event edit forms to show/edit template selection
- Update GalleryPage.tsx to use useGalleryCustomCss hook
- Add
.gallery-pageclass to gallery container components
Automated Testing Notes
For Playwright tests:
- Login to admin dashboard
- Navigate to CSS Templates editor
- Manipulate template tabs, inputs, and checkboxes
- Verify save operations via API calls
- Navigate to Create Event, verify template dropdown
- View gallery, verify custom CSS is applied