1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2025-10-05 19:30:58 +00:00

chore(ui): replace repo-code jQuery use, convert file to typescript (#9337)

This PR moves repo-code.js to repo-code.ts (with appropriate changes for the JS -> TS conversion), adds e2e tests for file folding and file line permalink copying to fully cover the features implemented in repo-code, then removes the jQuery usage in the file in favor of vanilla JS.

* chore(ui): replace jQuery uses in repo-code.ts

* chore(ui): add copy line permalink test

* chore(ui): add file folding test

* chore(ui): convert repo-code to ts

  This commit additionally removes the use of `document.selection` for IE8
support, as we no longer offer support for the browser.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9337
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Reviewed-by: 0ko <0ko@noreply.codeberg.org>
Co-authored-by: Jordan Atwood <nightfirecat@nightfirec.at>
Co-committed-by: Jordan Atwood <nightfirecat@nightfirec.at>
This commit is contained in:
Jordan Atwood 2025-09-21 08:08:47 +02:00 committed by 0ko
parent c08bdaacdb
commit 01419d9c36
4 changed files with 84 additions and 45 deletions

View file

@ -0,0 +1,21 @@
import {singleAnchorRegex, rangeAnchorRegex} from './repo-code.ts';
import {test, expect} from '@playwright/test';
test('singleAnchorRegex', () => {
expect(singleAnchorRegex.test('#L0')).toEqual(false);
expect(singleAnchorRegex.test('#L1')).toEqual(true);
expect(singleAnchorRegex.test('#L01')).toEqual(false);
expect(singleAnchorRegex.test('#n0')).toEqual(false);
expect(singleAnchorRegex.test('#n1')).toEqual(true);
expect(singleAnchorRegex.test('#n01')).toEqual(false);
});
test('rangeAnchorRegex', () => {
expect(rangeAnchorRegex.test('#L0-L10')).toEqual(false);
expect(rangeAnchorRegex.test('#L1-L10')).toEqual(true);
expect(rangeAnchorRegex.test('#L01-L10')).toEqual(false);
expect(rangeAnchorRegex.test('#L1-L01')).toEqual(false);
expect(rangeAnchorRegex.test('#L1-10')).toEqual(true);
expect(rangeAnchorRegex.test('#n1-n10')).toEqual(true);
expect(rangeAnchorRegex.test('#n1-10')).toEqual(true);
});