Files
2026-08-17 09:12:03 +02:00

5.0 KiB

Ordrestyring GraphQL API Test Suite

Dette projekt indeholder komplet test suite og dokumentation for Ordrestyring GraphQL API.

🎯 Hurtig Start

# Test en endpoint
bash examples/curl_cases.sh

# Se output
cat examples/output/curl_cases.sh.output.json

# Test med specifikt ID
bash examples/curl_case_by_id.sh 8806

📚 Dokumentation

Fil Beskrivelse
README_API.md Komplet API dokumentation med eksempler
TESTING_SUMMARY.md Test rapport og læringer
examples/endpoint_inventory.json Struktureret oversigt over alle endpoints
examples/rollback_plan.md Cleanup procedurer for write operations

📂 Projekt Struktur

apitest/
├── README_API.md                    # 📖 Hoved dokumentation
├── TESTING_SUMMARY.md               # 📊 Test rapport
├── INDEX.md                         # 📌 Dette dokument
├── apiendpoint                      # 🔗 Production endpoint URL
├── apikey                           # 🔑 API nøgle (hemmelig)
│
└── examples/                        # 💡 Eksempler og scripts
    ├── endpoint_inventory.json      # 📋 JSON oversigt (19 endpoints)
    ├── endpoint_inventory.csv       # 📊 CSV oversigt
    ├── rollback_plan.md             # 🧹 Cleanup procedurer
    ├── python_client.py             # 🐍 Python eksempel
    │
    ├── curl_*.sh                    # 🔧 18 test scripts
    │   ├── curl_cases.sh            # Liste cases
    │   ├── curl_case_by_id.sh       # Case detaljer
    │   ├── curl_offers.sh           # Liste tilbud
    │   ├── curl_offer_by_id.sh      # Tilbud detaljer
    │   ├── curl_customers.sh        # Liste kunder
    │   ├── curl_customer_by_id.sh   # Kunde detaljer
    │   ├── curl_products.sh         # Liste produkter
    │   ├── curl_users.sh            # Liste brugere
    │   ├── curl_departments.sh      # Liste afdelinger
    │   ├── curl_installations.sh    # Liste installationer
    │   ├── curl_services.sh         # Liste services
    │   ├── curl_todos.sh            # Liste todos
    │   ├── curl_events.sh           # Liste events
    │   ├── curl_sales_invoices.sh   # Salgsfakturaer
    │   ├── curl_creditor_invoices.sh # Kreditorfakturaer
    │   ├── curl_hours.sh            # Timer
    │   ├── curl_invoices.sh         # Fakturaer
    │   ├── curl_create_offer.sh     # Opret tilbud (write)
    │   └── curl_upload.sh           # Upload dokument (write)
    │
    └── output/                      # 💾 Gemte responses
        └── curl_*.sh.output.json    # 18 output filer

Test Status

  • Total endpoints: 19
  • Testede: 19 (100%)
  • Scripts: 18
  • Output filer: 18
  • Success rate: 100%

Læseadgang (17 endpoints)

cases, caseById, offers, offer, customers, customer, products, users, departments, installations, services, todos, events, salesInvoices, creditorInvoices, hours, invoices

Skriveadgang (2 endpoints - testet og ryddet op)

createOffer (ID 5841 → slettet)
uploadCaseDocument (ID 10923 → slettet)

🔧 Almindelige Opgaver

Teste et nyt endpoint

  1. Find endpoint navn via introspection:
API_KEY=$(cat apikey)
curl -X POST https://graphql.ordrestyring.dk/graphql \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  --data '{"query":"{ __type(name: \"Query\") { fields { name } } }"}'
  1. Find felter for en type:
curl -X POST https://graphql.ordrestyring.dk/graphql \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  --data '{"query":"{ __type(name: \"<TypeName>\") { fields { name } } }"}'
  1. Lav script baseret på eksisterende scripts i examples/

  2. Test og gem output:

bash examples/curl_<new_endpoint>.sh > examples/output/curl_<new_endpoint>.sh.output.json

Udvide dokumentationen

  1. Test endpoint og gem output
  2. Tilføj til endpoint_inventory.json
  3. Opdater README_API.md med eksempel
  4. Opdater TESTING_SUMMARY.md

🛡️ Sikkerhed & Best Practices

  • API nøgle: Aldrig commit apikey til git
  • Produktion: Vær ekstra forsigtig med write operations
  • Cleanup: Slet altid test-data efter write operations
  • Introspection: Brug altid introspection til at verificere felt-navne
  • Pagination: Brug reasonable limits (f.eks. 5-10) ved test

📞 Support

Ved spørgsmål eller problemer:

  • Se README_API.md for detaljeret dokumentation
  • Check TESTING_SUMMARY.md for læringer og common issues
  • Kontakt Julius fra Ordrestyring for API-relaterede spørgsmål

Sidst opdateret: 2025-10-23
Maintainer: API Test Suite
Version: 1.0