Files
zeekayandHanzo Dev b8db2962cd Remove the upstream name from tooling, dashboards and issue templates
The Grafana mixin queried gitea_* while modules/metrics/collector.go emits
hanzogit_*, so every stat panel rendered empty with no error. All twelve
queried names now match names the collector registers.

Issue templates sent security reports to [email protected] and help requests
to upstream's Discord and forum, which SECURITY.md explicitly tells people not
to do; both now point at [email protected] and our docs, and the issue search
points at this repository. FUNDING.yml routed sponsorship to upstream's Open
Collective, so it is gone.

The VS Code build task wrote ./gitea. The Makefile, the README beside it and
.gitignore all say gitd.

Frontend: initGiteaFomantic, initGiteaAPIViewer and isGiteaError renamed for
what they do; the Fomantic hard-fork markers read FORGE-PATCH; base.css named
:gitea: as a CUSTOM_EMOJIS example, but the defaults are git, gitlab and github.

Container paths are deliberately untouched. /data/gitea is GIT_WORK_DIR's
default in docker/root/usr/local/bin/gitd, the deployment does not set
GIT_WORK_DIR, and SSH_SERVER_HOST_KEYS is a relative path -- moving the work
directory regenerates the host keys and every existing clone reports a changed
host identity. /var/lib/gitea, /etc/gitea, gitea.db and
gitea-trusted-user-ca-keys.pem keep their names because the matching defaults
live in modules/setting, and a path renamed on one side only is a server that
starts and then cannot find its own files.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-08 19:55:51 -07:00

49 lines
2.5 KiB
TypeScript

import {isOwnError, processWindowErrorEvent, showGlobalErrorMessage} from './errors.ts';
beforeEach(() => {
document.body.innerHTML = '<div class="page-content"></div>';
});
test('isOwnError', () => {
expect(isOwnError('', '')).toBe(true);
expect(isOwnError('moz-extension://abc/content.js', '')).toBe(false);
expect(isOwnError('safari-extension://abc/content.js', '')).toBe(false);
expect(isOwnError('safari-web-extension://abc/content.js', '')).toBe(false);
expect(isOwnError('chrome-extension://abc/content.js', '')).toBe(false);
expect(isOwnError('https://other-site.com/script.js', '')).toBe(false);
expect(isOwnError('http://localhost:3000/some/page', '')).toBe(true);
expect(isOwnError('http://localhost:3000/assets/js/index.abc123.js', '')).toBe(true);
expect(isOwnError('', `Error\n at chrome-extension://abc/content.js:1:1`)).toBe(false);
expect(isOwnError('', `Error\n at https://other-site.com/script.js:1:1`)).toBe(false);
expect(isOwnError('', `Error\n at http://localhost:3000/assets/js/index.abc123.js:1:1`)).toBe(true);
expect(isOwnError('http://localhost:3000/assets/js/index.js', `Error\n at chrome-extension://abc/content.js:1:1`)).toBe(false);
});
test('showGlobalErrorMessage', () => {
showGlobalErrorMessage('test msg 1');
showGlobalErrorMessage('test msg 2');
showGlobalErrorMessage('test msg 1'); // duplicated
expect(document.body.innerHTML).toContain('>test msg 1 (2)<');
expect(document.body.innerHTML).toContain('>test msg 2<');
expect(document.querySelectorAll('.js-global-error').length).toEqual(2);
});
test('processWindowErrorEvent renders stack trace in details', () => {
const error = new Error('boom');
error.stack = `Error: boom\n at fn (${window.location.origin}/assets/js/index.js:1:1)`;
processWindowErrorEvent({error, type: 'error'} as ErrorEvent & PromiseRejectionEvent);
expect(document.querySelector('.js-global-error summary')!.textContent).toContain('JavaScript error: boom');
expect(document.querySelector('.js-global-error pre')!.textContent).toContain('/assets/js/index.js:1:1');
});
test('processWindowErrorEvent falls back to message without stack', () => {
processWindowErrorEvent({
error: {message: 'script error'}, type: 'error',
filename: `${window.location.origin}/assets/js/x.js`, lineno: 5, colno: 10,
} as ErrorEvent & PromiseRejectionEvent);
const msgText = document.querySelector('.js-global-error .ui.message')!.textContent;
expect(msgText).toContain('JavaScript error: script error');
expect(msgText).toContain('@ 5:10');
});