opsdash-app/opsdash/test/fixtures/README.md
Blade34242 162e03e5b2 Refactor opsdash presets, widgets registry, onboarding
- Move presets endpoints to PresetsController and add unit tests\n- Split widgets registry into per-widget modules and add render-context composable\n- Break OnboardingWizard into step components/state\n- Rebuild Vite assets and add smoke target
2025-12-14 10:55:21 +07:00

2.9 KiB

Test Fixtures

Store anonymised payloads from a real Nextcloud instance here so integration tests can replay realistic /overview responses without hitting the server.

Capture Checklist

  1. Start your local/staging Nextcloud with Opsdash enabled and seeded with representative calendars/targets.
  2. Grab request token from the web UI (or run within the NC container where OCS-APIREQUEST is sufficient).
  3. Load payloads
    curl -sS -u admin:admin \
      -H "OCS-APIREQUEST: true" \
      -H "requesttoken: <token>" \
      "http://localhost:8088/index.php/apps/opsdash/overview/load?range=week&offset=0" \
      > test/fixtures/load-week.json
    
    curl -sS -u admin:admin \
      -H "OCS-APIREQUEST: true" \
      -H "requesttoken: <token>" \
      "http://localhost:8088/index.php/apps/opsdash/overview/load?range=month&offset=0" \
      > test/fixtures/load-month.json
    
    Repeat with offset=-4..4 to cover navigation and forecast edge-cases.
  4. Persist response
    • In the UI, adjust selections/targets and capture the POST body (e.g. via DevTools) or manually craft one.
    • Send it to /overview/persist, saving the response:
      curl -sS -u admin:admin \
        -H "OCS-APIREQUEST: true" \
        -H "requesttoken: <token>" \
        -H "Content-Type: application/json" \
        -d @test/fixtures/persist-request.json \
        "http://localhost:8088/index.php/apps/opsdash/overview/persist" \
        > test/fixtures/persist-response.json
      
  5. Anonymise IDs/names if needed (cal-1, Focus Week, …) before committing.
  6. Ensure files stay small; trim arrays if the full payload is huge (keep the structure intact).

Integration suites can now import these fixtures directly, e.g.:

import loadWeek from '../fixtures/load-week.json'
  • Added offset fixtures (week/month) to cover previous/next periods.
  • load-week-offset-1.json (offset -1)
  • load-month-offset1.json (offset +1)
  • load-week-offset2.json (offset +2 with multiple calendars selected)
  • load-month-multiuser.json (month view with multiple calendars)
  • preset-export.json (Config & Setup export envelope)
  • onboarding-export.json (Config & Setup export including onboarding snapshot)
  • persist-response.json (sanitised /overview/persist response)
  • persist-reporting-deck.json (persist payload exercising reporting + Deck settings)
  • notes-week.json (GET /overview/notes sample; also used for /overview/persist minimal fixture)
  • load-month-qa.json (Month view payload seeded via QA user)
  • notes-month-qa.json (QA user month note payload captured after rerunning onboarding)
  • load-week-qa.json (QA user week payload with independent calendar selection)
  • notes-week-offset1.json (Previous week notes capture)
  • persist-week-offset1.json (Persist response for previous-week scenario)
  • notes-week-offset1.json (Previous week notes payload)
  • persist-week-offset1.json (Persist response fixture for previous-week scenario)