mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-10-10 19:32:02 +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:
parent
c08bdaacdb
commit
01419d9c36
4 changed files with 84 additions and 45 deletions
|
@ -127,3 +127,30 @@ test('Unicode escape highlight', async ({page}) => {
|
|||
await expect(page.locator('.tippy-box .view_git_blame[href$="/a-file#L1"]')).toBeVisible();
|
||||
await expect(page.locator('.tippy-box .copy-line-permalink[data-url$="/a-file#L1"]')).toBeVisible();
|
||||
});
|
||||
|
||||
test('File folding', async ({page}) => {
|
||||
const filePath = '/user2/repo1/commit/65f1bf27bc3bf70f64657658635e66094edbcb4d';
|
||||
|
||||
const response = await page.goto(filePath);
|
||||
expect(response?.status()).toBe(200);
|
||||
|
||||
const foldFileButton = page.locator('.fold-file');
|
||||
const diffFileBody = page.locator('.diff-file-body');
|
||||
await foldFileButton.click();
|
||||
await expect(diffFileBody).toBeHidden();
|
||||
await foldFileButton.click();
|
||||
await expect(diffFileBody).toBeVisible();
|
||||
});
|
||||
|
||||
test('Copy line permalink', async ({page}, workerInfo) => {
|
||||
test.skip(['Mobile Safari', 'webkit'].includes(workerInfo.project.name), 'Apple clipboard API addon - starting at just $499!');
|
||||
|
||||
const response = await page.goto('/user2/repo1/src/branch/master/README.md?display=source#L1');
|
||||
expect(response?.status()).toBe(200);
|
||||
|
||||
await page.locator('.code-line-button').click();
|
||||
// eslint-disable-next-line playwright/no-force-option
|
||||
await page.locator('.tippy-box .copy-line-permalink').click({force: true});
|
||||
const clipboardText = await page.evaluate(() => navigator.clipboard.readText());
|
||||
expect(clipboardText).toContain('README.md?display=source#L1');
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue