mirror of
https://github.com/go-gitea/gitea.git
synced 2026-11-19 15:14:40 +09:00
test(e2e): add more e2e test coverage (#40429)
Add e2e coverage for browser flows that regressed before and had no browser test. - Web editor: preview with relative links, diff preview and proposing on a new branch, catching CRLF in the diff and the commit - Task lists: toggling in preview and after save with non-ASCII text - Actions: cancel, rerun and view the earlier attempt - File navigation: tree, go to file and tag selector on a nested file with special characters Assisted-by: Claude Code:claude-opus-5-5
This commit is contained in:
1 parent
44e4b6a8d2
commit
84c9f8ad76
4 files changed
+132
-9
No files matched your search
@@ -39,7 +39,7 @@ test('workflow graph opens a job and steps expand by click or log permalink', as
|
||||
await expect(page.getByRole('link', {name: '23', exact: true})).toBeInViewport();
|
||||
});
|
||||
|
||||
test('run workflow dispatches a queued run with an input', async ({page, request}) => {
|
||||
test('dispatch with an input, cancel, rerun and view the first attempt', async ({page, request}) => {
|
||||
const owner = env.GITEA_TEST_E2E_USER;
|
||||
const repo = `e2e-dispatch-${randomString(8)}`;
|
||||
await Promise.all([
|
||||
@@ -68,5 +68,17 @@ jobs:
|
||||
const dispatchDialog = page.getByRole('dialog');
|
||||
await dispatchDialog.getByLabel('Run message').fill('from UI');
|
||||
await dispatchDialog.getByRole('button', {name: 'Run Workflow', exact: true}).click();
|
||||
await expect(page.getByRole('link', {name: 'Dispatch from UI', exact: true})).toBeVisible();
|
||||
await page.getByRole('link', {name: 'Dispatch from UI', exact: true}).click();
|
||||
|
||||
const cancelButton = page.getByRole('button', {name: 'Cancel workflow run', exact: true});
|
||||
await cancelButton.click();
|
||||
await page.getByRole('button', {name: 'Re-run failed jobs', exact: true}).click();
|
||||
await expect(page.getByText('Waiting', {exact: true}).filter({visible: true}).first()).toBeVisible();
|
||||
await expect(cancelButton).toBeVisible();
|
||||
|
||||
await page.getByRole('menu').getByText('Latest #2', {exact: true}).click();
|
||||
await page.getByRole('menuitem', {name: /^Attempt #1\b/}).click();
|
||||
await page.waitForURL('**/attempts/1');
|
||||
await expect(page.getByText('Canceled', {exact: true}).filter({visible: true}).first()).toBeVisible();
|
||||
await expect(page.getByRole('button', {name: /^Re-run\b/})).toBeHidden();
|
||||
});
|
||||
@@ -17,3 +17,55 @@ test('codeeditor textarea updates correctly', async ({page, request}) => {
|
||||
await page.keyboard.press('Tab');
|
||||
await expect(page.locator('textarea[name="content"]')).toHaveValue(' ');
|
||||
});
|
||||
|
||||
test('preview and propose a markdown edit', async ({page, request}) => {
|
||||
const repoName = `e2e-editor-preview-${randomString(8)}`;
|
||||
const owner = env.GITEA_TEST_E2E_USER;
|
||||
const repoPath = `/${owner}/${repoName}`;
|
||||
const filePath = 'docs/guide.md';
|
||||
const unchangedLine = 'Original guide context.';
|
||||
const proposedHeading = 'Proposed guide heading';
|
||||
await Promise.all([
|
||||
(async () => {
|
||||
await apiCreateRepo(request, {name: repoName, autoInit: false});
|
||||
await apiCreateFiles(request, owner, repoName, [{path: filePath, content: `${unchangedLine}\n`}]);
|
||||
})(),
|
||||
login(page),
|
||||
]);
|
||||
|
||||
await page.goto(`${repoPath}/src/branch/main/${filePath}`);
|
||||
await page.getByRole('link', {name: 'Edit File', exact: true}).click();
|
||||
await page.waitForURL(`${repoPath}/_edit/main/${filePath}`);
|
||||
|
||||
const main = page.getByRole('main');
|
||||
const commitButton = main.getByRole('button', {name: 'Commit Changes', exact: true});
|
||||
await expect(commitButton).toBeDisabled();
|
||||
await main.getByRole('textbox').filter({hasText: unchangedLine}).fill(
|
||||
`${unchangedLine}\n\n### ${proposedHeading}\n\n[Notes](notes.md)\n`,
|
||||
);
|
||||
await expect(commitButton).toBeEnabled();
|
||||
|
||||
await main.getByText('Preview', {exact: true}).click();
|
||||
await expect(main.getByRole('heading', {name: proposedHeading, exact: true})).toBeVisible();
|
||||
await expect(main.getByRole('link', {name: 'Notes', exact: true})).toHaveJSProperty(
|
||||
'href', new URL(`${repoPath}/src/branch/main/docs/notes.md`, page.url()).href,
|
||||
);
|
||||
|
||||
await main.getByText('Preview Changes', {exact: true}).click();
|
||||
const addedRow = main.getByRole('row', {name: `3 + ### ${proposedHeading}`, exact: true});
|
||||
const unchangedRow = main.getByRole('row', {name: `1 1 ${unchangedLine}`, exact: true});
|
||||
await expect(addedRow).toBeVisible();
|
||||
await expect(unchangedRow).toBeVisible();
|
||||
|
||||
await main.getByRole('radio', {
|
||||
name: 'Create a new branch for this commit and start a pull request.', exact: true,
|
||||
}).check();
|
||||
await main.getByPlaceholder('New branch name…', {exact: true}).fill('docs-preview');
|
||||
await main.getByRole('button', {name: 'Propose file change', exact: true}).click();
|
||||
await page.waitForURL(`${repoPath}/compare/main...docs-preview`);
|
||||
await expect(addedRow).toBeVisible();
|
||||
await expect(unchangedRow).toBeVisible();
|
||||
|
||||
await main.getByRole('button', {name: 'New Pull Request', exact: true}).click();
|
||||
await expect(main.getByPlaceholder('Title', {exact: true})).toBeVisible();
|
||||
});
|
||||
@@ -92,3 +92,43 @@ test('delete an edit history entry via a confirm over the history modal', async
|
||||
await page.getByRole('dialog', {name: 'Delete from history?'}).getByRole('button', {name: 'Confirm'}).click();
|
||||
await expect(page.getByRole('dialog')).toHaveCount(0);
|
||||
});
|
||||
|
||||
test('toggle tasks in preview and after save', async ({page, request}) => {
|
||||
const repoName = `e2e-issue-tasklist-${randomString(8)}`;
|
||||
const owner = env.GITEA_TEST_E2E_USER;
|
||||
const originalBody = 'Résumé\n\n- [X] Verify input';
|
||||
const [{index}] = await Promise.all([
|
||||
(async () => {
|
||||
await apiCreateRepo(request, {name: repoName, autoInit: false});
|
||||
return apiCreateIssue(request, {owner, repo: repoName, title: 'Checklist test', body: originalBody});
|
||||
})(),
|
||||
login(page),
|
||||
]);
|
||||
await page.goto(`/${owner}/${repoName}/issues/${index}`);
|
||||
|
||||
const contextMenu = page.getByRole('heading', {level: 3}).getByRole('menu').filter({hasNotText: 'Edited'});
|
||||
const editItem = contextMenu.getByRole('menuitem', {name: 'Edit', exact: true});
|
||||
const issueBody = page.getByRole('article');
|
||||
const editor = issueBody.getByRole('textbox');
|
||||
await contextMenu.click();
|
||||
await editItem.click();
|
||||
await expect(editor).toHaveValue(originalBody);
|
||||
await page.keyboard.press('Enter');
|
||||
await page.keyboard.insertText('Record result');
|
||||
|
||||
await issueBody.getByText('Preview', {exact: true}).click();
|
||||
await issueBody.getByRole('listitem').filter({hasText: 'Verify input'}).getByRole('checkbox').uncheck();
|
||||
await issueBody.getByText('Write', {exact: true}).click();
|
||||
await expect(editor).toHaveValue('Résumé\n\n- [ ] Verify input\n- [ ] Record result');
|
||||
|
||||
await issueBody.getByRole('button', {name: 'Save', exact: true}).click();
|
||||
await issueBody.getByRole('listitem').filter({hasText: 'Record result'}).getByRole('checkbox').check();
|
||||
const updatedBody = 'Résumé\n\n- [ ] Verify input\n- [x] Record result';
|
||||
await expect(issueBody.getByText(updatedBody, {exact: true})).toBeAttached();
|
||||
|
||||
await contextMenu.click();
|
||||
await editItem.click();
|
||||
await expect(editor).toHaveValue(updatedBody);
|
||||
const response = await request.get(`/api/v1/repos/${owner}/${repoName}/issues/${index}`);
|
||||
expect((await response.json()).body).toContain('- [x] Record result');
|
||||
});
|
||||
+26
-7
@@ -1,6 +1,6 @@
|
||||
import {env} from 'node:process';
|
||||
import {test, expect} from '@playwright/test';
|
||||
import {login, apiCreateBranch, apiCreateFiles, apiCreateRepo, randomString} from './utils.ts';
|
||||
import {login, apiCreateBranch, apiCreateFiles, apiCreateRepo, apiHeaders, randomString} from './utils.ts';
|
||||
|
||||
test('create a repository', async ({page}) => {
|
||||
const repoName = `e2e-repo-${randomString(8)}`;
|
||||
@@ -47,30 +47,49 @@ test('search code', async ({page, request}) => {
|
||||
await expect(page.getByText('src/main.go', {exact: true})).toBeVisible();
|
||||
});
|
||||
|
||||
test('file tree, history and go to file navigate between nested files', async ({page, request}) => {
|
||||
test('file tree, go to file and tag selector navigate nested files', async ({page, request}) => {
|
||||
const repoName = `e2e-file-nav-${randomString(8)}`;
|
||||
const owner = env.GITEA_TEST_E2E_USER;
|
||||
const tagName = 'review/café';
|
||||
const guideUrlPath = 'docs/%231%20guide.txt';
|
||||
await Promise.all([
|
||||
(async () => {
|
||||
await apiCreateRepo(request, {name: repoName, autoInit: false});
|
||||
await apiCreateFiles(request, owner, repoName, [
|
||||
{path: 'start.txt', content: 'Starting file content\n'},
|
||||
{path: 'docs/guide.txt', content: 'Nested guide content\n'},
|
||||
{path: 'docs/#1 guide.txt', content: 'Nested guide content\n'},
|
||||
]);
|
||||
expect((await request.post(`/api/v1/repos/${owner}/${repoName}/tags`, {
|
||||
headers: apiHeaders(), data: {tag_name: tagName},
|
||||
})).status()).toBe(201);
|
||||
})(),
|
||||
login(page),
|
||||
]);
|
||||
await page.goto(`/${owner}/${repoName}/src/branch/main/start.txt`);
|
||||
const tree = page.locator('#view-file-tree');
|
||||
await tree.getByRole('link', {name: 'docs', exact: true}).locator('.item-toggle svg').click();
|
||||
await tree.getByRole('link', {name: 'guide.txt', exact: true}).click();
|
||||
await expect(page.getByText('Nested guide content', {exact: true})).toBeVisible();
|
||||
await tree.getByRole('link', {name: '#1 guide.txt', exact: true}).click();
|
||||
const guideContent = page.getByText('Nested guide content', {exact: true});
|
||||
await expect(guideContent).toBeVisible();
|
||||
await page.goBack();
|
||||
await expect(page.getByText('Starting file content', {exact: true})).toBeVisible();
|
||||
|
||||
const search = page.getByRole('combobox', {name: 'Go to file'});
|
||||
await search.fill('docs/gu');
|
||||
await expect(page.getByRole('option')).toHaveText(['docs/guide.txt']);
|
||||
await expect(page.getByRole('option')).toHaveText(['docs/#1 guide.txt']);
|
||||
await search.press('Enter');
|
||||
await expect(page.getByText('Nested guide content', {exact: true})).toBeVisible();
|
||||
await page.waitForURL(`/${owner}/${repoName}/src/branch/main/${guideUrlPath}`);
|
||||
await expect(guideContent).toBeVisible();
|
||||
|
||||
await page.getByText('main', {exact: true}).click();
|
||||
await expect(page.getByText('default', {exact: true})).toBeVisible();
|
||||
await page.getByRole('button', {name: 'Tags', exact: true}).click();
|
||||
await page.keyboard.insertText(tagName);
|
||||
const tagText = page.getByText(tagName, {exact: true});
|
||||
await expect(tagText).toBeVisible();
|
||||
await page.keyboard.press('ArrowDown');
|
||||
await page.keyboard.press('Enter');
|
||||
await page.waitForURL(`/${owner}/${repoName}/src/tag/review/caf%C3%A9/${guideUrlPath}`);
|
||||
await expect(guideContent).toBeVisible();
|
||||
await expect(tagText).toBeVisible();
|
||||
});
|
||||
Reference in new issue
Block a user