# Real-browser load test: drive headless Chrome over CDP and capture
# Navigation Timing + Web Vitals (FCP, LCP, DCL, load) for a page.
#
# Unlike the protocol-level `http` client, the `browser` protocol renders the
# page in a real Chrome tab — running JavaScript, fetching subresources, and
# firing the load/DOMContentLoaded events — so the timings reflect what a user
# actually experiences. Each VU keeps its own warm tab for the whole run.
#
# Requires headless Chrome/Chromium installed on the runner; it is launched
# lazily on the first browser request.
name: browser
description: Headless-Chrome page load capturing Web Vitals

# Browser navigations record into the generic `plugin_*` metric family.
# Declaring it makes the threshold below a known metric.
metrics:
  plugin_req_duration: { kind: trend, time: true }

scenarios:
  homepage:
    executor: constant-vus
    vus: 5
    duration: 1m
    flow:
      - request:
          name: load homepage
          protocol: browser
          url: https://example.com
          timeout: 30s
          checks:
            - { type: status, equals: 200 }
            - { type: body_contains, name: rendered, value: "</html>" }
      - think_time: { type: constant, duration: 2s }

thresholds:
  # Browser samples feed the generic `plugin_*` family (plus http_req_failed).
  plugin_req_duration: [ "p(95)<5000" ]
  http_req_failed: [ "rate<0.01" ]
