mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-24 08:01:42 +00:00
Adds a search box and a file-extension filter to the pull request diff sidebar, so reviewers can narrow a large diff down to the files they care about. Both filters apply to the file tree and to the diff itself. The extension menu follows GitHub: extensions sorted alphabetically, dotfiles and extension-less files in their own buckets, and the selection kept in the same `file-filters[]` query parameter, so a filtered view is shareable and survives a reload. The menu can list every extension in a diff, so `createTippy` gains an opt-in `limitSizeToViewport` option that caps a popup to the space left in the viewport and scrolls its content. Popups that do not ask for it are unchanged. Closes https://github.com/go-gitea/gitea/issues/27256 Signed-off-by: silverwind <me@silverwind.io> Signed-off-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Claude (Opus 4.7) <noreply@anthropic.com> Co-authored-by: Copilot <copilot@github.com> Co-authored-by: Nicolas <bircni@icloud.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
54 lines
2.9 KiB
TypeScript
54 lines
2.9 KiB
TypeScript
import {env} from 'node:process';
|
|
import {expect, test} from '@playwright/test';
|
|
import {login, apiCreateRepo, apiCreateFiles, assertFlushWithParent, assertNoJsError, randomString} from './utils.ts';
|
|
|
|
test('external file', async ({page, request}) => {
|
|
const repoName = `e2e-external-render-${randomString(8)}`;
|
|
const owner = env.GITEA_TEST_E2E_USER;
|
|
await Promise.all([
|
|
apiCreateRepo(request, {name: repoName}),
|
|
login(page),
|
|
]);
|
|
await apiCreateFiles(request, owner, repoName, [{path: 'test.external', content: '<p>rendered content</p>'}]);
|
|
await page.goto(`/${owner}/${repoName}/src/branch/main/test.external`);
|
|
const iframe = page.locator('iframe.external-render-iframe');
|
|
await expect(iframe).toBeVisible();
|
|
await expect(iframe).toHaveAttribute('data-src', new RegExp(`/${owner}/${repoName}/render/branch/main/test\\.external`));
|
|
const frame = page.frameLocator('iframe.external-render-iframe');
|
|
await expect(frame.locator('p')).toContainText('rendered content');
|
|
await assertFlushWithParent(iframe, page.locator('.file-view'));
|
|
await assertNoJsError(page);
|
|
});
|
|
|
|
test('openapi file', async ({page, request}) => {
|
|
const repoName = `e2e-openapi-render-${randomString(8)}`;
|
|
const owner = env.GITEA_TEST_E2E_USER;
|
|
await Promise.all([
|
|
apiCreateRepo(request, {name: repoName}),
|
|
login(page),
|
|
]);
|
|
const title = 'Test <API> & "quoted"';
|
|
const spec = JSON.stringify({
|
|
openapi: '3.0.0',
|
|
info: {title, version: '1.0'},
|
|
paths: {'/pets': {get: {responses: {'200': {description: 'OK', content: {'application/json': {schema: {$ref: '#/components/schemas/Pet'}}}}}}}},
|
|
components: {schemas: {Pet: {type: 'object', properties: {children: {type: 'array', items: {$ref: '#/components/schemas/Pet'}}}}}},
|
|
});
|
|
await apiCreateFiles(request, owner, repoName, [{path: 'openapi.json', content: spec}]);
|
|
await page.goto(`/${owner}/${repoName}/src/branch/main/openapi.json`);
|
|
const iframe = page.locator('iframe.external-render-iframe');
|
|
await expect(iframe).toBeVisible();
|
|
const viewer = page.frameLocator('iframe.external-render-iframe').locator('#frontend-render-viewer');
|
|
await expect(viewer.locator('.swagger-ui')).toBeVisible();
|
|
await expect(viewer.locator('.info .title')).toContainText(title);
|
|
// expanding the operation triggers swagger-ui's $ref resolver, which fetches window.location
|
|
// (about:srcdoc since the iframe is loaded via srcdoc); failure surfaces as "Could not resolve reference"
|
|
await viewer.locator('.opblock-tag').first().click();
|
|
await viewer.locator('.opblock').first().click();
|
|
await expect(viewer.getByText('Could not resolve reference')).toHaveCount(0);
|
|
// poll: postMessage resize may not have settled yet when the visibility checks pass
|
|
await expect.poll(async () => (await iframe.boundingBox())!.height).toBeGreaterThan(300);
|
|
await assertFlushWithParent(iframe, page.locator('.file-view'));
|
|
await assertNoJsError(page);
|
|
});
|