trigger:
  branches:
    include:
      - reportingTest

pool:
  vmImage: ubuntu-latest

variables:
  PLAYWRIGHT_DIR: Playwright
  PW_ALLURE_RESULTS: $(PLAYWRIGHT_DIR)/allure-results

steps:
  # 1. Checkout repo
  - checkout: self

  # 2. Install Node
  - task: NodeTool@0
    inputs:
      versionSpec: "20.x"
    displayName: "Install Node.js"

  # 3. Install dependencies + Playwright browsers
  - script: |
      npm ci
      npx playwright install --with-deps
    workingDirectory: $(PLAYWRIGHT_DIR)
    displayName: "Install dependencies and browsers"

  # 4. Run Playwright tests
  - script: npm run smoke
    workingDirectory: $(PLAYWRIGHT_DIR)
    displayName: "Run Playwright tests"

  # 5. Publish Allure 3 report to Azure DevOps tab
  - task: PublishAllureReport@2
    displayName: "Publish Allure Report"
    condition: succeededOrFailed()
    inputs:
      testResultsDir: "$(PW_ALLURE_RESULTS)"
