.PHONY: help review hydrate preset-skips test test-unit test-e2e fixture

help: ## Show targets
	@grep -E '^[a-zA-Z0-9_-]+:.*##' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*## "}; {printf "  \033[36m%-16s\033[0m %s\n", $$1, $$2}'

review: ## Start triage UI (http://127.0.0.1:8765)
	@chmod +x run.sh
	@./run.sh

hydrate: ## Download attachments from official Slack export URLs
	@chmod +x scripts/hydrate-export.sh
	@./scripts/hydrate-export.sh

preset-skips: ## Apply presets/levkin-skips.json channel skips to manifest.json
	@python3 scripts/preset-skips.py

cherry-pick: ## Reset picks and re-run scripts/auto-cherry-pick.py
	@python3 scripts/auto-cherry-pick.py

prepare-export: ## Build prepared-export/ from manifest.json
	@python3 scripts/prepare-export.py

fixture: ## Build tests/fixtures/mini-export from your Slack export
	@python3 scripts/build-test-fixture.py

test: test-unit test-e2e ## Run 100+ pytest + Playwright tests

test-unit: fixture ## Pytest (export, cherry-pick, API)
	@test -d .venv || python3 -m venv .venv
	@.venv/bin/pip install -q -r requirements-dev.txt
	@.venv/bin/python -m pytest tests/ -v --ignore=tests/e2e --cov --cov-report=term-missing:skip-covered

test-cov: test-unit ## Alias with coverage report

test-e2e: fixture ## Playwright UI tests
	@npm install --no-save 2>/dev/null || npm install
	@npx playwright install chromium
	@SLACK_IMPORT_PORT=18765 npm run test:e2e

test-e2e-headed: fixture ## Playwright with visible browser
	@npm install --no-save 2>/dev/null || npm install
	@npx playwright install chromium
	@SLACK_IMPORT_PORT=18765 npx playwright test --headed

test-e2e-ui: fixture ## Playwright interactive UI runner
	@npm install --no-save 2>/dev/null || npm install
	@npx playwright install chromium
	@SLACK_IMPORT_PORT=18765 npx playwright test --ui
