mirror of
https://github.com/go-gitea/gitea.git
synced 2026-11-11 20:57:35 +00:00
Backport #40053 by @silverwind Copying lines from a diff, file view, blame, code search or code preview and pasting them into a comment on Gitea or GitHub produced a markdown table with escaped pipes and stripped indentation. Both use `@github/paste-markdown`, which converts copied HTML tables unless they carry `data-paste-markdown-skip`, as GitHub's own code tables do. Gitea's code tables now set it too. The test is a bit more complicated because of a upstream bug which causes `paste-markdown` to insert pasted content twice, once https://github.com/github/paste-markdown/pull/128 is merged and released, the negative assertion could be removed. Signed-off-by: silverwind <me@silverwind.io> Co-authored-by: silverwind <me@silverwind.io>
26 lines
1.2 KiB
TypeScript
26 lines
1.2 KiB
TypeScript
import {env} from 'node:process';
|
|
import {test, expect} from '@playwright/test';
|
|
import {apiCreateFiles, apiCreatePR, apiCreateRepo, login, randomString} from './utils.ts';
|
|
|
|
test('a copied pull request diff pastes as text', async ({page, request}) => {
|
|
const repoName = `e2e-pr-diff-copy-${randomString(8)}`;
|
|
const owner = env.GITEA_TEST_E2E_USER;
|
|
const [index] = await Promise.all([
|
|
(async () => {
|
|
await apiCreateRepo(request, {name: repoName});
|
|
await apiCreateFiles(request, owner, repoName, [{path: 'copy.txt', content: 'one | two\n'}], {branch: 'main', newBranch: 'feat'});
|
|
return apiCreatePR(request, owner, repoName, 'feat', 'main', 'title');
|
|
})(),
|
|
login(page),
|
|
]);
|
|
await page.goto(`/${owner}/${repoName}/pulls/${index}/files`);
|
|
|
|
await page.getByRole('main').selectText();
|
|
await page.keyboard.press('ControlOrMeta+KeyC');
|
|
await page.getByRole('button', {name: 'Review', exact: true}).click();
|
|
const comment = page.getByRole('textbox', {name: 'Review comment'});
|
|
await comment.press('ControlOrMeta+KeyV');
|
|
await expect(comment).toHaveValue(/one \| two/);
|
|
await expect(comment).not.toHaveValue(/one \\\| two/); // paste-markdown also inserts the table until https://github.com/github/paste-markdown/pull/128
|
|
});
|