Repository navigation
Pull requests overview: designed for a new install, a medium org and a big one #549
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nambok
wants to merge
12
commits into
main
Choose a base branch
from
prs-overview-polish
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,950
−917
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
a804af5
Pull requests overview: designed for a new install, a medium org and …
nambok 4533e76
Merge main (the settings page) into the overview polish
nambok 75c0fa8
Dashboard design tokens: one type ramp, a 4px spacing scale, radii an…
nambok 582d20c
Tabs reach 44px on a phone, fields share one height, Settings uses th…
nambok 6e6c87e
Inline code and bold text stay on the ramp; For you is held to the to…
nambok a5ac034
Pull requests overview: the trends from history, quiet panels, a read…
nambok 2778f71
Merge the design tokens (#551) into the overview polish
nambok 2288c0f
Pull requests: on the design tokens
nambok 30dc7e0
Pull requests overview: zeros left out, one note on a new install, co…
nambok 761be5f
Merge main (the design tokens as merged in #551) into the overview po…
nambok 5c89951
Pull requests overview: the review's tests, live column balancing, a …
nambok 9f19467
Merge main into the overview design pass
nambok File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| import fs from "node:fs"; | ||
| import path from "node:path"; | ||
| import { expect, test, type Locator } from "@playwright/test"; | ||
| import { mockOverview } from "./prs-overview-mock"; | ||
| import { sized, type Size } from "./prs-overview-sizes"; | ||
|
|
||
| // The overview at three sizes of org (one repo with three open pull requests | ||
| // and no history; 14 repos and about 40 open; about 300 open) and four widths. | ||
| // Each is captured, and the layout rules hold at every one: no tooltip is | ||
| // visible until something is hovered or focused, the age chart is never | ||
| // taller than its marks need, and a handful of pull requests is a list, not | ||
| // an empty plot. | ||
|
|
||
| /** | ||
| * The legend items with no drawn mark of their kind: a mark counts only on | ||
| * a drawn dot or band (never the chart's own element). | ||
| */ | ||
| async function undrawnLegendItems(aging: Locator): Promise<string[]> { | ||
| const out: string[] = []; | ||
| const legend = aging.getByTestId("aging-legend"); | ||
| if ((await legend.count()) === 0) return out; | ||
| for (const item of await legend.locator("[data-mark]").all()) { | ||
| const mark = (await item.getAttribute("data-mark")) ?? ""; | ||
| const drawn = await aging.locator(`[data-testid="aging-dot"][data-marks~="${mark}"], [data-testid="aging-band"][data-marks~="${mark}"]`).count(); | ||
| if (drawn === 0) out.push(mark); | ||
| } | ||
| return out; | ||
| } | ||
|
|
||
| const SHOTS_DIR = process.env.E2E_SHOTS_DIR || path.join("test-results", "overview-sizes"); | ||
| const PREFIX = process.env.E2E_SHOTS_PREFIX || `org-polish-${process.env.E2E_SHOTS_TAG || "after"}`; | ||
| const WIDTHS = [1440, 1280, 1024, 375]; | ||
| const SIZES: Size[] = ["sparse", "medium", "big"]; | ||
|
|
||
| for (const size of SIZES) { | ||
| for (const width of WIDTHS) { | ||
| test(`overview, ${size} org at ${width}px: captured, nothing floating at rest, the chart sized to its marks`, async ({ page }) => { | ||
| await page.setViewportSize({ width, height: 900 }); | ||
| await mockOverview(page, () => sized(size)); | ||
| await page.goto("/prs/overview?org=acme"); | ||
| await expect(page.getByTestId("overview-summary")).toBeVisible(); | ||
| await page.mouse.move(0, 0); | ||
| fs.mkdirSync(SHOTS_DIR, { recursive: true }); | ||
| await page.screenshot({ path: path.join(SHOTS_DIR, `${PREFIX}-${size}-${width}.png`), fullPage: true }); | ||
| if (width >= 640) await page.getByTestId("overview-aging").screenshot({ path: path.join(SHOTS_DIR, `${PREFIX}-${size}-${width}-aging.png`) }); | ||
|
|
||
| // Nothing floats over the page until a mark is hovered or focused. | ||
| await expect(page.locator('[role="tooltip"]:visible')).toHaveCount(0); | ||
|
|
||
| if (width >= 640) { | ||
| const aging = page.getByTestId("overview-aging"); | ||
| await expect(aging).toBeVisible(); | ||
| const marks = sized(size).aging.dots.length; | ||
| if (marks < 10) { | ||
| // A few pull requests are a list with their ages, not a plot. | ||
| await expect(aging.getByTestId("aging-chart")).toHaveCount(0); | ||
| await expect(aging.getByTestId("aging-row")).toHaveCount(marks); | ||
| } else { | ||
| const chart = aging.getByTestId("aging-chart"); | ||
| const box = await chart.boundingBox(); | ||
| expect(box && box.height, "the chart is never taller than 320px").toBeLessThanOrEqual(320); | ||
| // Axis words are body size or smaller. | ||
| const sizes = await chart.locator("text").evaluateAll((els) => els.map((e) => parseFloat(getComputedStyle(e).fontSize) * (e.getBoundingClientRect().height / Math.max(1, (e as SVGTextElement).getBBox().height)))); | ||
| expect(Math.max(...sizes), "axis labels are at most 13px on screen").toBeLessThanOrEqual(13.5); | ||
| // A mark shows its tooltip on hover, and it goes away after. | ||
| await chart.getByTestId("aging-dot").first().hover(); | ||
| await expect(page.locator('[role="tooltip"]:visible')).toHaveCount(1); | ||
| await page.mouse.move(0, 0); | ||
| await expect(page.locator('[role="tooltip"]:visible')).toHaveCount(0); | ||
| } | ||
| // The legend names only what is drawn. | ||
| expect(await undrawnLegendItems(aging)).toEqual([]); | ||
| } | ||
|
|
||
| // A new install: panels with nothing to say are one quiet line, never rows of 0. | ||
| if (size === "sparse" && width >= 640) { | ||
| const stale = page.getByTestId("panel-stale"); | ||
| await expect(stale.getByTestId("panel-rest")).toContainText("Nothing idle"); | ||
| await expect(stale).not.toContainText("Not enough history yet"); | ||
| await expect(page.getByTestId("panel-security")).not.toContainText("Not enough history yet"); | ||
| await expect(page.getByTestId("overview-coderhelm")).not.toContainText("Not enough history yet"); | ||
| // Whose turn and the conditions leave out their zeros; the note is said once. | ||
| await expect(page.locator('[data-testid="turn-link"]:visible')).toHaveText(["people 2", "CoderHelm 1"]); | ||
| await expect(page.locator('[data-testid="conditions-none"]:visible')).toHaveText("nothing stale, abandoned or zombie"); | ||
| await expect(page.getByTestId("history-note")).toContainText("review health"); | ||
| await expect(page.getByText("Failures and review health")).toHaveCount(0); | ||
| } | ||
|
|
||
| // On a phone a new install lists its open PRs by age, and has no | ||
| // failures or review folds; on a desktop, no such panels either. | ||
| if (size === "sparse" && width < 640) { | ||
| const phoneAge = page.getByTestId("overview-aging-phone"); | ||
| await expect(phoneAge).toBeVisible(); | ||
| await expect(phoneAge.getByTestId("aging-row")).toHaveCount(3); | ||
| await expect(phoneAge.getByTestId("aging-row").first()).toContainText("2.1d"); | ||
| await expect(page.getByTestId("phone-failures")).toHaveCount(0); | ||
| await expect(page.getByTestId("phone-review")).toHaveCount(0); | ||
| } | ||
| if (width >= 1024) { | ||
| const panels = page.getByTestId("overview-panels"); | ||
| const merged = size !== "sparse"; | ||
| await expect(panels.getByTestId("panel-failures")).toHaveCount(merged ? 1 : 0); | ||
| await expect(panels.getByTestId("panel-review")).toHaveCount(merged ? 1 : 0); | ||
| await expect(panels.getByTestId("panel-stale")).toHaveCount(1); | ||
| await expect(panels.getByTestId("panel-security")).toHaveCount(1); | ||
| } | ||
|
|
||
| // No sideways scroll at any width. | ||
| const sideways = await page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth); | ||
| expect(sideways).toBeLessThanOrEqual(1); | ||
|
|
||
| }); | ||
| } | ||
| } | ||
|
|
||
| test("the legend check fails when a legend item has no drawn mark", async ({ page }) => { | ||
| await page.setViewportSize({ width: 1440, height: 900 }); | ||
| await mockOverview(page, () => sized("medium")); | ||
| await page.goto("/prs/overview?org=acme"); | ||
| const aging = page.getByTestId("overview-aging"); | ||
| await expect(aging.getByTestId("aging-dot").first()).toBeVisible(); | ||
| expect(await undrawnLegendItems(aging)).toEqual([]); | ||
| // Take every person's mark off the chart: the legend still names it, and | ||
| // the check says so. | ||
| await aging.evaluate((el) => el.querySelectorAll('[data-testid="aging-dot"][data-marks~="person"]').forEach((d) => d.remove())); | ||
| expect(await undrawnLegendItems(aging)).toEqual(["person"]); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| // The overview at three sizes of org, for the layout and screenshot checks: | ||
| // a new install with one repo, three open pull requests and no history; a | ||
| // medium org (14 repos, about 40 open); and a big one (14 repos, about 300 | ||
| // open, more than the chart shows). Invented data, from the bookstore. | ||
|
|
||
| import type { OverviewDot, PrStage, PrsOverview } from "../src/lib/api"; | ||
| import { overview } from "./prs-overview-data"; | ||
|
|
||
| export type Size = "sparse" | "medium" | "big"; | ||
|
|
||
| const H = 3600; | ||
| const D = 86_400; | ||
|
|
||
| /** One repo, three open pull requests, no history: the first day of an install. */ | ||
| function sparse(): PrsOverview { | ||
| const o = overview("empty"); | ||
| const repo = "acme/bookstore"; | ||
| const mk = (n: number, stage: PrStage, state: string, state_label: string, age: number, who: "person" | "coderhelm" | "bot", title: string): OverviewDot => ({ | ||
| key: `${repo}#${n}`, | ||
| repo, | ||
| number: n, | ||
| title, | ||
| stage, | ||
| state, | ||
| state_label, | ||
| age_secs: age, | ||
| coderhelm: who === "coderhelm", | ||
| author_type: who, | ||
| band: null, | ||
| idle: false, | ||
| main_blocked: false, | ||
| }); | ||
| const dots = [ | ||
| mk(12, "first_review", "needs_review", "Needs review", 40 * 60, "person", "Add the paperback filter to search"), | ||
| mk(11, "in_review", "changes_requested", "Changes requested", 5 * H, "coderhelm", "Round cart totals per currency"), | ||
| mk(9, "approved", "checks_running", "Checks running", 2 * D + 3 * H, "person", "Show stock per warehouse on the book page"), | ||
| ]; | ||
| const stages: Partial<Record<PrStage, number>> = { first_review: 1, in_review: 1, approved: 1 }; | ||
| o.scope = { ...o.scope, repos: 1, repos_read: 1 }; | ||
| o.open = 3; | ||
| o.drafts = 0; | ||
| o.aging = { ...o.aging, dots, shown: 3, total: 3 }; | ||
| o.strip = o.strip.map((c) => ({ ...c, count: stages[c.stage as PrStage] ?? 0, delta: null, spark: null, past_p85: 0 })); | ||
| o.turns = { person: 2, coderhelm: 1, machines: 0, nobody: 0 }; | ||
| o.thresholds = { ...o.thresholds, cycle: null, first_review: null, external: true }; | ||
| o.history = { ...o.history, days: 0, weeks: 0, young: true, merged_90d: 0 }; | ||
| o.summary = { | ||
| ...o.summary, | ||
| verdict: { ...o.summary.verdict, state: "quiet", word: "Quiet", parts: [{ t: "3 open pull requests in bookstore, none waiting longer than a couple of days." }] }, | ||
| attention: [], | ||
| quiet: { repos: 1, open: 3, parts: [{ t: "Nothing needs you: no pull request is idle or blocked." }] }, | ||
| coderhelm: { ...o.summary.coderhelm, parts: [{ t: "One pull request of its own in review; nothing merged yet." }] }, | ||
| }; | ||
| o.coderhelm = { | ||
| author: { ...o.coderhelm.author, opened: 1, merged: 0, closed_unmerged: 0, open: 1, merge_rate: null, p50_merge_secs: null, waiting_on_people: null }, | ||
| fixer: { fixed: 0, merged: 0, closed_unmerged: 0, open: 0 }, | ||
| reviewer: { reviewed: 2, findings: null, verified_rate: null, p50_first_look_secs: 4 * 60 }, | ||
| runs: null, | ||
| exceptions: { ...o.coderhelm.exceptions, needs_decision: 0, oldest_secs: null, reworked: null, merges: null, cost_per_merged: null }, | ||
| }; | ||
| o.security = { ...o.security, dependency: null }; | ||
| // Opened in the last two days, nothing merged: the trends have nothing to say yet. | ||
| const today = new Date(); | ||
| today.setUTCHours(0, 0, 0, 0); | ||
| o.trends = { | ||
| flow: Array.from({ length: 84 }, (_, i) => { | ||
| const back = 83 - i; | ||
| const total = back === 0 ? 3 : back <= 2 ? 1 : 0; | ||
| return { day: new Date(today.getTime() - back * D * 1000).toISOString().slice(0, 10), stages: back === 0 ? stages : back <= 2 ? { approved: 1 } : {}, total, unknown: 0 }; | ||
| }), | ||
| split_from: new Date(today.getTime() - 83 * D * 1000).toISOString().slice(0, 10), | ||
| merged: [], | ||
| cycle_days: 90, | ||
| flow_days: 84, | ||
| }; | ||
| o.stale = { ...o.stale, stale: 0, past_usual: 0, on_author: 0, on_reviewer: 0, abandoned: { count: 0, oldest_secs: null }, zombie: 0, drift: null, draft_p85_secs: null, archive_candidates: 0 }; | ||
| o.repos = [{ ...o.repos[0], repo, open: 3, stages, past_p85: 0, health: "healthy", why: "3 open, none past usual.", link: { overview: `repo=${repo}` } }]; | ||
| return o; | ||
| } | ||
|
|
||
| /** About 300 open across 14 repos: the chart shows the oldest it can. */ | ||
| function big(): PrsOverview { | ||
| const o = overview("bad"); | ||
| const base = o.aging.dots; | ||
| const dots: OverviewDot[] = []; | ||
| for (let k = 0; k < 5; k++) { | ||
| for (const d of base) { | ||
| const number = d.number + 1000 * (k + 1); | ||
| dots.push({ ...d, number, key: `${d.repo}#${number}`, age_secs: Math.round(d.age_secs * (0.6 + 0.2 * k)) }); | ||
| } | ||
| } | ||
| o.aging = { ...o.aging, dots: dots.slice(0, 200), shown: 200, total: dots.length }; | ||
| o.open = dots.length; | ||
| o.strip = o.strip.map((c) => ({ ...c, count: c.count * 5, past_p85: (c.past_p85 ?? 0) * 5 })); | ||
| o.repos = o.repos.map((r) => ({ ...r, open: r.open * 5, past_p85: r.past_p85 * 5 })); | ||
| return o; | ||
| } | ||
|
|
||
| export function sized(size: Size): PrsOverview { | ||
| if (size === "sparse") return sparse(); | ||
| if (size === "big") return big(); | ||
| return overview("normal"); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛑 Blocking (required: tests): Legend check can never fail (tests)
charts.tsx:318 puts
data-markson the chart's root svg, built from the samepresentset the legend uses.aging.locator('[data-marks~="mark"]')always matches that root element, so every legend item passes even when no mark of that kind is drawn. 'Every legend item is drawn' is not actually tested. Count only elements below the root, for exampleaging-dotandaging-band, or the dot elements at charts.tsx:401 and 482.This repository requires tests with behavior changes, so this blocks the merge until the test is in the PR.