Files
forge/tests/e2e/file-view-render.test.ts
zeekayandHanzo Dev a0b748828a refactor(brand): purge upstream naming from user- and operator-visible surfaces
Audited what users and operators actually see, not raw grep counts. The
rendered DOM, page titles, meta and footer on git.hanzo.ai were already
clean; the frontend bundle is clean on main (the live hits were a stale
deployed image, v1.26.19). What survived was server-side text and locales.

User-visible:
- Locale values: 12 -> 0 across 11 languages. The bulk was the admin
  self-check telling operators to run "gitea doctor convert"; our binary
  is gitd, so the instruction was wrong as well as off-brand.
- Credential prompt realm when OAuth2 is disabled (the branch whose job is
  to NOT match Git Credential Manager's "Gitea" probe).
- Admin diagnosis download is hanzo-git-diagnosis-*.zip; dump artifacts are
  hanzo-git-dump-*.zip / hanzo-git-db.sql.
- Azure AD icon gradient ids no longer carry the upstream name. Source
  hygiene only: svgo cleanupIds already rewrote them before shipping.

Outbound identity (what third parties see):
- User-Agent to OAuth providers, haveibeenpwned and remote LFS servers is
  now Hanzo Git. The git-lfs "git-lfs/<version>" prefix is untouched;
  some LFS servers parse it.

Operator-visible:
- CLI help, descriptions and examples name gitd, not gitea. Several were
  telling operators to run commands that do not exist.
- Migration/startup failure text (wrong-DB-version, no-SQLite-support,
  collation warning, internal-API contact error). The "upgrade to Gitea
  1.6.4 first" note keeps the upstream name: that release is a real point
  in the schema lineage and renaming it would make it a lie.
- Prometheus namespace gitea_ -> hanzogit_. Verified metrics are disabled
  on git.hanzo.ai, so no dashboard exists to break; this is the cheapest
  moment to do it.
- Default log file, PID file, and the container entrypoint message.
- Our own X-* headers are now function-namespaced per the platform's
  vendor-free convention: X-Cache-Debug, X-Internal-Auth,
  X-LFS-Content-Length, X-Vite-Dev-Server. Every side ships in one binary,
  so the rename is atomic.

Correctness found on the way:
- LLM.md documented GITEA__<section>__<KEY>; only GIT__ is accepted and
  there is no fallback, so a stale GITEA__ var is silently ignored.
- EnvConfigKeyPrefixGitea held "GIT__" — name now matches its value.
- api_packages_container_test.go still asserted the old registry realm
  while the code emits ours, so that test could not pass.
- README told developers to run ./gitea web; docs/build-setup.md told
  contributors to clone go-gitea/gitea instead of this fork.

Deliberately kept, and why, recorded in LLM.md: MIT attribution, dependency
import paths, addressing values whose rename silently redirects (webhook
type, .gitea/ repo conventions, index and analyzer names, /data/gitea),
the GCM interop realm, and three wire contracts with external consumers
(X-GITEA-OTP, webhook delivery headers, mail headers) that need an owner
decision rather than a blind rename.

Co-authored-by: Hanzo Dev <[email protected]>
2026-07-26 13:50:17 -07:00

64 lines
3.8 KiB
TypeScript

import {env} from 'node:process';
import {expect, test} from '@playwright/test';
import {apiCreateRepo, apiCreateFile, assertFlushWithParent, assertNoJsError, login, randomString} from './utils.ts';
test('3d model file', async ({page, request, browserName}) => {
test.skip(browserName === 'firefox', 'unclear firefox-only CI-only failure'); // eslint-disable-line playwright/no-skipped-test
const repoName = `e2e-3d-render-${randomString(8)}`;
const owner = env.GIT_TEST_E2E_USER;
await apiCreateRepo(request, {name: repoName});
const stl = 'solid test\nfacet normal 0 0 1\nouter loop\nvertex 0 0 0\nvertex 1 0 0\nvertex 0 1 0\nendloop\nendfacet\nendsolid test\n';
await apiCreateFile(request, owner, repoName, 'test.stl', stl);
await page.goto(`/${owner}/${repoName}/src/branch/main/test.stl?display=rendered`);
const iframe = page.locator('iframe.external-render-iframe');
await expect(iframe).toBeVisible();
const frame = page.frameLocator('iframe.external-render-iframe');
const viewer = frame.locator('#frontend-render-viewer');
await expect(viewer.locator('canvas')).toBeVisible(); // unclear firefox-only CI-only failure
expect((await viewer.boundingBox())!.height).toBeGreaterThan(300);
await assertFlushWithParent(iframe, page.locator('.file-view'));
// bgcolor passed via hanzo-iframe-bgcolor; 3D viewer reads it from body bgcolor — must match parent
const [parentBg, iframeBg] = await Promise.all([
page.evaluate(() => getComputedStyle(document.body).backgroundColor),
frame.locator('body').evaluate((el) => getComputedStyle(el).backgroundColor),
]);
expect(iframeBg).toBe(parentBg);
await assertNoJsError(page);
});
test('pdf file', async ({page, request}) => {
// headless playwright cannot render PDFs (PDFObject.embed returns false), so this is a limited test
const repoName = `e2e-pdf-render-${randomString(8)}`;
const owner = env.GIT_TEST_E2E_USER;
await apiCreateRepo(request, {name: repoName});
await apiCreateFile(request, owner, repoName, 'test.pdf', '%PDF-1.0\n%%EOF\n');
await page.goto(`/${owner}/${repoName}/src/branch/main/test.pdf`);
const container = page.locator('.file-view-render-container');
await expect(container).toHaveAttribute('data-render-name', 'pdf-viewer');
await expect.poll(async () => (await container.boundingBox())!.height).toBeGreaterThan(300);
await assertFlushWithParent(container, page.locator('.file-view'));
});
test('asciicast file', async ({page, request}) => {
const repoName = `e2e-asciicast-render-${randomString(8)}`;
const owner = env.GIT_TEST_E2E_USER;
const branch = '日本語-branch';
const branchEnc = encodeURIComponent(branch);
await Promise.all([apiCreateRepo(request, {name: repoName, autoInit: false}), login(page)]);
const cast = '{"version": 2, "width": 80, "height": 24}\n[0.0, "o", "test-content"]\n';
// on an empty repo, apiCreateFile with newBranch creates that branch as the initial commit
await apiCreateFile(request, owner, repoName, 'test.cast', cast, {newBranch: branch});
await page.goto(`/${owner}/${repoName}/src/branch/${branchEnc}/test.cast`);
const iframe = page.locator('iframe.external-render-iframe');
const frame = iframe.contentFrame();
const viewer = frame.locator('#frontend-render-viewer[data-frontend-render-name]');
await expect(viewer).toHaveAttribute('data-frontend-render-name', 'asciicast'); // render succeeded
await expect(viewer).toHaveAttribute('data-window-origin', 'null'); // no same-origin, avoid XSS
const wrapper = frame.locator('.ap-wrapper');
await expect(wrapper).toBeVisible();
await expect(wrapper).toContainText('test-content');
await expect.poll(async () => (await iframe.boundingBox())!.height).toBeGreaterThan(300);
await assertFlushWithParent(iframe, page.locator('.file-view'));
await assertNoJsError(page);
});