Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions packages/website/src/lib/home-map-layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ export function formatPickerCoordinate(value: number): string {
return Number(fixed) === 0 ? (0).toFixed(6) : fixed;
}

// ---- The map's view: what part of the drawing the stage shows -------------
// A stage as wide as the drawing (200 by 88 map units) shows all of it. A
// phone's stage is at least 60svh tall (docs/design/map-polish-audit.md § 5),
// so it shows the drawing's full height and part of its width, centred on the
Expand Down Expand Up @@ -292,7 +291,6 @@ export function panMapView(view: MapBox, edge: MapEdge, drawing: MapBox = MAP_DR
return { ...view, x: Math.min(Math.max(drawing.x, x), drawing.x + drawing.width - view.width) };
}

// ---- The inspector over the map -------------------------------------------
// docs/design/map-polish-audit.md § 5: "When the node would sit under the
// dock, the map pans it into the open area", and on a phone "The map pans
// the node above the sheet." The map never resizes, so the view moves: it may
Expand Down Expand Up @@ -393,7 +391,6 @@ export function pointsBeyondView(view: MapBox, points: readonly MapPoint[]): Rec
return { west, east };
}

// ---- Pins on the drawing's edge -------------------------------------------
// docs/design/map-polish-audit.md § 5, "Edge pins": "A valid point on the
// map's edge, such as a confirmed place on the 180th meridian, still draws
// half outside the drawing. The build keeps the audit's clamp: the rendered
Expand Down Expand Up @@ -473,7 +470,6 @@ export function badgeFallbackCenter(
return keepCircleInside(beside, targetRadius, view, cornerRadius);
}

// ---- Labels at rest -------------------------------------------------------
// § 5: "Chapter labels at rest ... The highest featuredWeight goes first.
// Each label tries right, left, above and below its dot, and hides when it
// would touch another label, a pin, a badge, a bar or the dock."
Expand Down
8 changes: 0 additions & 8 deletions scripts/chapter-image-fields.integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ try {
await sql.unsafe(await readMigration(file));
}

// --- Backfill -----------------------------------------------------------
// Rows as they exist before 029: description in media only, no new columns.
const legacyUpload = await uploadFile();
await insertChapter('legacy-approved', {
Expand Down Expand Up @@ -237,7 +236,6 @@ try {
assert.equal(Object.hasOwn(published ?? {}, 'imageAlt'), false);
assert.equal(Object.hasOwn(published ?? {}, 'imageFileId'), false);

// --- Update request alt text and credit -----------------------------------
for (const file of migrations.filter((name) => name > IMAGE_MIGRATION && name < REQUEST_MIGRATION)) {
await sql.unsafe(await readMigration(file));
}
Expand Down Expand Up @@ -323,7 +321,6 @@ try {
await editRequest(blank, { proposed_image_alt: '', proposed_image_credit: null });
assert.deepEqual(await requestDescription(blank), [null, null]);

// --- New rows ------------------------------------------------------------
// A seeded or imported chapter describes its sourced image in media only.
await insertChapter('new-from-media', { media: sourced('new-from-media', { imageAlt: 'Imported alt.', imageCredit: 'Imported credit' }) });
let row = await chapterRow('new-from-media');
Expand All @@ -334,7 +331,6 @@ try {
row = await chapterRow('new-blank');
assert.deepEqual([row.image_alt, row.image_credit], [null, null]);

// --- Direct edits while the sourced image shows --------------------------
const slug = 'direct';
await insertChapter(slug, {
image: '/images/chapters/direct.jpg',
Expand Down Expand Up @@ -378,7 +374,6 @@ try {
row = await chapterRow(slug);
assert.deepEqual([row.image_alt, row.image_credit], ['Corrected alt for the second image.', 'Second credit']);

// --- Uploads --------------------------------------------------------------
const firstUpload = await uploadFile();
const secondUpload = await uploadFile();

Expand Down Expand Up @@ -455,7 +450,6 @@ try {
assert.deepEqual([row.image_alt, row.image_credit], [null, null]);
assert.equal(Object.hasOwn((await publicChapter('social-only'))?.media ?? {}, 'imageAlt'), false);

// --- Accepted update requests ---------------------------------------------
// Without an image the request describes the image the chapter shows.
await acceptRequest(slug, { alt: 'Reviewed alt.' });
row = await chapterRow(slug);
Expand Down Expand Up @@ -515,7 +509,6 @@ try {
assert.deepEqual([row.image_alt, row.image_credit], ['Second accepted alt.', 'Second Photographer']);
assert.equal(row.seo.ogImage, social);

// --- Prepared steward sync drafts -------------------------------------------
// The prep script starts a draft from the chapter's current values. Until a
// steward edits it, it proposes nothing: accepting it as prepared leaves the
// chapter as it was, whether it shows a sourced image or an uploaded one.
Expand Down Expand Up @@ -569,7 +562,6 @@ try {
await sql!`update content.chapter_update_requests set request_status = 'accepted' where id = ${rewritten}::uuid`;
assert.deepEqual(await chapterFacts('prepared-upload'), { ...beforeRewrite, summary: 'A summary the steward rewrote.' });

// --- Alerts ---------------------------------------------------------------
// An unreviewed sourced image is withheld; the chapter stays, with one alert.
await insertChapter('unreviewed', {
image: '/images/chapters/unreviewed.jpg',
Expand Down
3 changes: 0 additions & 3 deletions scripts/directus-text-fields.integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ try {
await sql.unsafe(await readMigration(file));
}

// --- Before 033 -------------------------------------------------------------
// Rows shaped like production: a request with its child rows, an initiative,
// and a project.
await sql`insert into content.chapters ${sql({ slug: 'proof', name: 'Proof chapter' })}`;
Expand Down Expand Up @@ -201,7 +200,6 @@ try {
// An untouched chapter arrived as '' and met the foreign key.
assert.equal(await refusal(() => insertInitiative({ slug: 'no-chapter', title: 'No chapter' })), FOREIGN_KEY);

// --- 033 --------------------------------------------------------------------
const beforeMigration = await digest();
await sql.unsafe(textFieldMigration);
// Defaults only: no row changes, updated_at included, and no review email queued.
Expand Down Expand Up @@ -246,7 +244,6 @@ try {
assert.equal(await refusal(() => insertInitiative({ slug: 'new-initiative', chapter_slug: 'proof', title: 'New initiative' })), null);
assert.equal(await refusal(() => insertProject({ slug: 'new-project', guild_slug: 'proof-guild', name: 'New project' })), null);

// --- Optional fields ------------------------------------------------------------
// An emptied optional field now arrives as '', and its column takes it.
const emptied = await refusal(() => sql!`
update content.chapter_update_requests
Expand Down
55 changes: 55 additions & 0 deletions scripts/lib/git-guardrails.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Git helpers for the diff-aware checks in scripts/quality. Adapted from Green Goods'
// scripts/lib/git-guardrails.mjs; the default base here is origin/main.
import { spawnSync } from 'node:child_process';

export function runGit(repoRoot, args, { allowFailure = false } = {}) {
const result = spawnSync('git', args, { cwd: repoRoot, encoding: 'utf8', maxBuffer: 16 * 1024 * 1024 });
if (result.error && !allowFailure) throw new Error(`git ${args.join(' ')} failed: ${result.error.message}`);
if (result.status !== 0 && !allowFailure) throw new Error(`git ${args.join(' ')} failed: ${result.stderr.trim()}`);
return result;
}

function resolves(repoRoot, candidate) {
return (
runGit(repoRoot, ['rev-parse', '--verify', '--quiet', `${candidate}^{commit}`], { allowFailure: true }).status === 0
);
}

export function parseBaseArgs(argv) {
let base;
for (let index = 0; index < argv.length; index++) {
if (argv[index] === '--base') {
if (!argv[index + 1]) throw new Error('--base requires a Git ref');
base = argv[++index];
} else {
throw new Error(`unknown argument: ${argv[index]}`);
}
}
return { base };
}

export function resolveGitBase({ repoRoot, explicitBase, environmentVariables = [], fallback = 'origin/main' }) {
if (explicitBase) {
if (!resolves(repoRoot, explicitBase)) throw new Error(`base ref does not resolve to a commit: ${explicitBase}`);
return explicitBase;
}
for (const variable of environmentVariables) {
const candidate = process.env[variable];
if (candidate && resolves(repoRoot, candidate)) return candidate;
}
return fallback && resolves(repoRoot, fallback) ? fallback : undefined;
}

/** A Git environment for test fixtures: no user or system config, a fixed identity. */
export function fixtureGitEnvironment(environment = process.env) {
const inherited = Object.entries(environment).filter(([variable]) => !variable.startsWith('GIT_'));
return {
...Object.fromEntries(inherited),
GIT_CONFIG_GLOBAL: '/dev/null',
GIT_CONFIG_SYSTEM: '/dev/null',
GIT_AUTHOR_NAME: 'Fixture',
GIT_AUTHOR_EMAIL: 'fixture@example.invalid',
GIT_COMMITTER_NAME: 'Fixture',
GIT_COMMITTER_EMAIL: 'fixture@example.invalid',
};
}
17 changes: 17 additions & 0 deletions scripts/lib/vite-parse.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Vite's Oxc parser, for the comment codemod. Vite is not a direct dependency of the repository;
// it comes with Astro, so it is found from the website's Astro install. Declaring it at the root
// instead would re-resolve Rolldown for the whole workspace.
import { createRequire } from 'node:module';
import { readFileSync } from 'node:fs';
import { dirname, resolve } from 'node:path';
import { fileURLToPath, pathToFileURL } from 'node:url';

const repoRoot = resolve(fileURLToPath(new URL('../..', import.meta.url)));
const fromWebsite = createRequire(resolve(repoRoot, 'packages/website/package.json'));
const fromAstro = createRequire(fromWebsite.resolve('astro/package.json'));
const vitePackage = fromAstro.resolve('vite/package.json');
const dot = JSON.parse(readFileSync(vitePackage, 'utf8')).exports['.'];
const entry = typeof dot === 'string' ? dot : (dot.import?.default ?? dot.import ?? dot.default);

export const { parseSync } = await import(pathToFileURL(resolve(dirname(vitePackage), entry)).href);
if (typeof parseSync !== 'function') throw new Error(`Vite at ${dirname(vitePackage)} has no parseSync`);
5 changes: 0 additions & 5 deletions scripts/map-node-approval-guard.integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ try {
await sql.unsafe(await readMigration(file));
}

// --- Rows saved before the guard ------------------------------------------
// Until now an approved node at 0,0 could be saved, as the June 2026 client
// did for two nodes PRD-1409 later repaired.
const legacyHidden = await insertNode({ status: 'approved', latitude: 0, longitude: 0, place_name: 'Port Harcourt' });
Expand Down Expand Up @@ -286,7 +285,6 @@ try {
assert.deepEqual(await state(repairedFromZero), ['archived', '0.000000', '0.000000']);
assert.deepEqual(await state(repairedFromEdge), ['approved', '90.000000', '97.762610']);

// --- Approving a pending node ----------------------------------------------
// At 0,0: refused with a readable error, and the node stays pending.
const pendingAtZero = await insertNode({ latitude: 0, longitude: 0, place_name: 'Rotterdam, Netherlands' });
await assertRefused(() => editNode(pendingAtZero, { status: 'approved' }), pendingAtZero, 'null_island', 'approving at 0,0');
Expand Down Expand Up @@ -332,7 +330,6 @@ try {
assert.equal(approved.status, 'approved');
assert.ok(approved.approved_at instanceof Date);

// --- Saving an approved node directly ---------------------------------------
// Live onboarding and admin edits insert approved rows. Every problem the
// shared rule names is refused with the guard's own message, before the
// column checks from migrations 001 and 018 would refuse the row less clearly.
Expand All @@ -357,7 +354,6 @@ try {
// Pending rows may still hold 0,0, as the June 2026 client wrote them.
await insertNode({ latitude: 0, longitude: 0 });

// --- Owner update requests ---------------------------------------------------
// A request that moves an approved node to 0,0 fails, and stays pending.
const movedToZero = await insertNode({ status: 'approved', latitude: 6.5244, longitude: 3.3792, place_name: 'Lagos' });
const moveRequest = await insertUpdateRequest(movedToZero, { latitude: 0, longitude: 0 });
Expand Down Expand Up @@ -392,7 +388,6 @@ try {
assert.equal(renamedNode.display_name, 'Renamed proof node');
assert.deepEqual(await state(renamed), ['approved', '-16.800000', '180.000000']);

// --- Applying it again -------------------------------------------------------
const settled = await everySubmission();
await sql.unsafe(guardMigration);
assert.equal(await everySubmission(), settled, 'replaying the guard changed a stored row');
Expand Down
3 changes: 0 additions & 3 deletions scripts/map-node-contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3354,7 +3354,6 @@ test('home map inspector: the dock, the sheets and the compact tooltip (map-poli
assert.doesNotMatch(component, /shouldRecoverMobileView/);
});

// ---------------------------------------------------------------------------
// PRD-1409 (qa-map-data): nodes saved at impossible coordinates.
// Live /map/state on 2026-11-06 held these public points. The June 2026
// add-node client produced them: a pin drag clamped to the mini-map edge gave
Expand All @@ -3363,7 +3362,6 @@ test('home map inspector: the dock, the sheets and the compact tooltip (map-poli
// are always refused. An exact edge point is refused from raw coordinates but
// accepted from a confirmed place, because real places sit on the 180th
// meridian (Fiji). Evidence: .plans/archive/website-qa-2026-11/handoffs/qa-map-data.md
// ---------------------------------------------------------------------------
const LIVE_EDGE_POINTS = Object.freeze([
{ place: 'Florida', lat: 90, long: 97.76261 },
{ place: 'Taiwan', lat: 90, long: 176.912492 },
Expand Down Expand Up @@ -3816,7 +3814,6 @@ test('D2: the home map and footer drop the ecoregion layer and its credit', asyn
});

// PRD-1409 review follow-ups: PostgreSQL rounding and chapter anchors.
// ---------------------------------------------------------------------------

test('coordinates are judged at the six decimal places PostgreSQL stores', () => {
// numeric(9, 6) rounds anything finer, so the rule judges the rounded value.
Expand Down
6 changes: 0 additions & 6 deletions scripts/pages-deploy-recovery.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ test('a re-run is not dated by a job it kept from the earlier attempt', () => {
assert.equal(earliestJobStart(jobs, ''), null);
});

// --- Watching -----------------------------------------------------------------

/** A scripted Pages pipeline on a virtual clock. Tests script GitHub's side through the hooks. */
function simulate(initialRuns: PagesRun[], startAt: string) {
const clock = { nowMs: Date.parse(startAt) };
Expand Down Expand Up @@ -314,8 +312,6 @@ test('a fresh run that hangs in turn is cancelled and followed by another', asyn
assert.equal(watch.startedReplacement, true);
});

// --- GitHub API ----------------------------------------------------------------

type FakeResponse = { status?: number; body?: unknown };

function fakeGitHub(
Expand Down Expand Up @@ -523,8 +519,6 @@ test('configuration names what is missing and rejects a malformed repository', (
assert.throws(() => readConfig({ ...env, PAGES_RUN_ID: 'latest' }), /must be a workflow run id/);
});

// --- Workflow wiring -----------------------------------------------------------

test('the recovery workflow is wired to the Pages workflow it watches', () => {
const workflows = new URL('../.github/workflows/', import.meta.url);
const pages = readFileSync(new URL('github-pages.yml', workflows), 'utf8');
Expand Down
Loading
Loading