Files
tinker_tickets/tests/ui/markdown.ui.js
T
jaredandClaude Opus 5.5 f1decca31f
Lint / UI screenshots (before/after) (push) Skipped
Lint / JS (eslint) (push) Successful in 16s
Lint / PHP (phpcs PSR-12) (push) Successful in 30s
Lint / PHP requirements (version + extensions) (push) Successful in 50s
Lint / UI (playwright) (push) Successful in 3m29s
Lint / Deploy (push) Skipped
Lint / Notify on failure (push) Skipped
Security / PHP Security (semgrep) (push) Successful in 2m59s
Lint / JS (eslint) (pull_request) Successful in 16s
Lint / PHP (phpcs PSR-12) (pull_request) Successful in 33s
Lint / PHP requirements (version + extensions) (pull_request) Successful in 32s
Lint / UI (playwright) (pull_request) Successful in 2m23s
Lint / Deploy (pull_request) Skipped
Lint / Notify on failure (pull_request) Skipped
Security / PHP Security (semgrep) (pull_request) Successful in 1m32s
Lint / UI screenshots (before/after) (pull_request) Successful in 4m14s
Add Playwright UI tests and before/after screenshots to CI
New UI (playwright) job: PHP and MariaDB inside the Playwright image, a
seeded instance (tests/ui/stack.sh, synthetic data only) and 21 tests:
every main page loads with no page errors, console errors or failed
requests, description and comment markdown render safely (#114), and
pages fit a phone screen. Deploys now wait for it.

New UI screenshots (before/after) job: for PRs that change assets/ or
views/, runs the base branch and the PR side by side with the same data
and uploads one side-by-side PNG per page and view (dark, light, phone).
Modelled on Pulse's ui and ui-screenshots jobs.

Fixes found while building it:
- migrate.php split statements on semicolons inside -- comments, so 001
  and 003 failed on a fresh database.
- API endpoints applied rate limiting before loading config, so
  RATE_LIMIT_DEFAULT/RATE_LIMIT_API from .env and TRUSTED_PROXIES were
  ignored there: every user behind the proxy shared one per-IP bucket.
  The limiter now loads config itself; the per-IP limits are configurable
  (RATE_LIMIT_IP, RATE_LIMIT_IP_API) with unchanged defaults.
- The avatar error fallback was registered in the footer, after the
  header avatar, so a fast 404 left a broken image instead of initials.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 19:06:52 -05:00

57 lines
2.6 KiB
JavaScript

'use strict';
// Ticket descriptions and comments render as markdown (#114), safely.
const { test, expect } = require('./fixtures');
test('description markdown renders as formatted HTML', async ({ page }) => {
await page.goto('/ticket/100000001');
const view = page.locator('#ticketDescriptionView');
await expect(view.locator('h2', { hasText: 'Goal' })).toBeVisible();
await expect(view.locator('strong', { hasText: 'PBS datastore' })).toBeVisible();
await expect(view.locator('table tr')).toHaveCount(4);
await expect(view.locator('pre code')).toContainText('proxmox-backup-manager datastore create');
await expect(view.locator('a[href="https://wiki.example.invalid/backups"]')).toBeVisible();
await expect(view.locator('a[href$="/ticket/100000002"]')).toBeVisible();
await expect(view).not.toContainText('## Goal');
});
test('HTML and javascript: links in a description stay inert', async ({ page }) => {
await page.goto('/ticket/100000001');
const view = page.locator('#ticketDescriptionView');
await expect(view).toContainText("<script>window.__seedXss = 1</script>");
await expect(view.locator('script')).toHaveCount(0);
await expect(view.locator('a[href^="javascript:"]')).toHaveCount(0);
expect(await page.evaluate(() => window.__seedXss)).toBeUndefined();
});
test('underscores inside identifiers stay literal', async ({ page }) => {
await page.goto('/ticket/100000002');
const view = page.locator('#ticketDescriptionView');
await expect(view).toContainText('node_network_up is 0');
await expect(view.locator('em', { hasText: 'Opened automatically by Gandalf.' })).toBeVisible();
});
test('plain text keeps its paragraphs', async ({ page }) => {
await page.goto('/ticket/100000003');
const view = page.locator('#ticketDescriptionView');
await expect(view).toContainText('Tried a new roll, same result.');
await expect(view).toContainText('Not urgent, the spare printer works.');
});
test('edit mode shows the raw markdown source', async ({ page }) => {
await page.goto('/ticket/100000001');
await page.click('#editButton');
const textarea = page.locator('#ticketDescription');
await expect(textarea).toBeVisible();
await expect(textarea).toHaveValue(/^## Goal\n/);
});
test('markdown comments render', async ({ page }) => {
await page.goto('/ticket/100000001');
await page.click('#comments-tab-btn');
const comment = page.locator('.comment-text').first();
await expect(comment.locator('strong', { hasText: 'Next:' })).toBeVisible();
await expect(comment.locator('code', { hasText: 'snake_case_job' })).toBeVisible();
await expect(comment).toContainText('verify_jobs');
});