controleonline/smoke-tests-playground

Symfony bundle for exposing browser smoke test indexes and artifacts as JSON APIs in ControleOnline projects.

Maintainers

Package info

github.com/ControleOnline/smoke-tests-playground

Type:symfony-bundle

pkg:composer/controleonline/smoke-tests-playground

Transparency log

Statistics

Installs: 272

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

dev-master 2026-07-17 02:39 UTC

This package is auto-updated.

Last update: 2026-07-20 18:59:53 UTC


README

Scrutinizer Code Quality

Smoke Tests Playground

Bundle Symfony para expor tests de varios tipos como API JSON.

composer require controleonline/smoke-tests-playground:dev-master

O pacote nao renderiza UI HTML. A leitura publica acontece por:

  • GET /tests
  • GET /tests/index.json como alias de compatibilidade
  • GET /tests/api

Os artifacts publicados pelos smoke tests ficam disponiveis por:

  • GET /tests/artifacts/{suiteId}/{arquivo}

O frontend separado em tests-frontend-tool consome essa API com X-API-KEY.

O que o Playwright publica

Cada tipo e suite continuam gravando em:

  • var/tests/<type>/<suite>/report.json
  • var/tests/<type>/<suite>/report.xml
  • var/tests/<type>/<suite>/*.png
  • var/tests/<type>/<suite>/*/*.png

O report.json ou report.xml fica por suite. O bundle varre todos os tipos e suites e monta um index.json agregado com:

  • status geral
  • progresso geral
  • resumo de suites e testes
  • resumo de tipos
  • lista de tipos
  • lista de suites
  • testes de cada suite
  • etapas de cada teste
  • prints com URLs autenticadas

Instalacao

  1. Instale o Node.js com nvm no servidor, se ainda nao existir:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
source ~/.bashrc
nvm install --lts
nvm use --lts
  1. No projeto consumidor, instale o Playwright e os browsers com o mesmo usuario que executa o app:
npm install -D @playwright/test
node node_modules/@playwright/test/cli.js install
  1. Instale o pacote com Composer.
  2. Registre o bundle em config/bundles.php:
ControleOnline\SmokeTestsPlayground\SmokeTestsPlaygroundBundle::class => ['all' => true],
  1. Rode o bootstrap do pacote:
php bin/console smoke-tests-playground:install

O instalador escreve:

  • .env com os defaults do smoke
  • config/routes/smoke_tests_playground.yaml
  • config/services/smoke_tests_playground.yaml

Se a instalacao dos browsers falhar por permissao, o comando imprime instrucoes para executar como root.

Variaveis de ambiente

  • PLAYWRIGHT_BROWSERS_PATH="0" evita depender do cache global do usuario.
  • SMOKE_TESTS_PLAYGROUND_TESTS_PATH aponta para a raiz dos smoke tests, por padrao var/tests.
  • SMOKE_TESTS_PLAYGROUND_RUN_COMMAND define o comando do runner, por padrao:
node node_modules/@playwright/test/cli.js test --config=playwright.config.cjs tests/browser/*.spec.js
  • SMOKE_TESTS_PLAYGROUND_RUN_WORKDIR define o diretorio de execucao.
  • SMOKE_TESTS_PLAYGROUND_RUN_TIMEOUT define o timeout em segundos.

Rotas

  • GET /tests retorna o indice agregado canĂ´nico
  • GET /tests/index.json retorna o mesmo JSON para compatibilidade
  • GET /tests/api retorna o mesmo JSON para compatibilidade
  • GET /tests/artifacts/{suiteId}/{arquivo} entrega os artifacts publicados
  • POST /tests/run continua disponivel para disparar o runner do backend

Contrato do indice

O indice publico tem a estrutura geral:

{
  "generatedAt": "2026-07-06T18:51:19.924Z",
  "status": "failed",
  "progress": 50,
  "message": "1 suite com falha em 2 publicadas.",
  "lastRunAt": "2026-07-06T18:51:19.924Z",
  "summary": {
    "types": {
      "total": 2,
      "passed": 1,
      "failed": 1
    },
    "suites": {
      "total": 2,
      "passed": 1,
      "failed": 1
    },
    "tests": {
      "total": 2,
      "passed": 1,
      "failed": 1
    }
  },
  "types": [],
  "suites": []
}

Cada tipo publica:

  • type
  • displayName
  • status
  • progress
  • message
  • summary
  • suites[]

Cada suite publica:

  • type
  • typeDisplayName
  • suite
  • suitePath
  • suiteId
  • displayName
  • generatedAt
  • updatedAt
  • status
  • summary
  • tests[]
  • links.report

Cada screenshot publica:

  • label
  • name
  • url
  • mimeType
  • kind
  • available

Frontend separado

O projeto tests-frontend-tool consome a API via .env:

API_ENTRYPOINT=https://staging.frethical.com
HTACCESS_USER=<user>
HTACCESS_PASSWORD=<password>

Ele nao executa smoke tests. Ele so le index.json, mostra suites/tests/etapas e faz preview dos artifacts.

Conferencia manual

Exemplo de leitura do indice:

curl -H "Accept: application/json" \
  -H "X-API-KEY: <api-key>" \
  "https://<your-host>/tests/index.json"

Exemplo de artifact:

curl -H "X-API-KEY: <api-key>" \
  "https://<your-host>/tests/artifacts/<suiteId>/01-login-screen.png" \
  --output login-screen.png

Testes

O pacote tem testes para:

  • indice vazio
  • multiplas suites
  • JSON invalido
  • resposta de run
  • entrega de artifacts