0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-06-29 07:45:43 +02:00

fix tests

This commit is contained in:
Lunny Xiao 2026-05-17 11:13:30 -07:00
parent d2db150558
commit b6a219fde8
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
3 changed files with 26 additions and 22 deletions

View File

@ -12,23 +12,22 @@ import type {Page} from '@playwright/test';
async function setupWorkflowPage(page: Page, repoName: string) {
const user = env.GITEA_TEST_E2E_USER;
const project = await createProject(page, {owner: user, repo: repoName, title: 'WF Project'});
await Promise.all([
createProjectColumn(page.request, user, repoName, String(project.id), 'Backlog'),
createProjectColumn(page.request, user, repoName, String(project.id), 'Done'),
]);
// Create columns sequentially so their option order stays deterministic.
await createProjectColumn(page.request, user, repoName, String(project.id), 'Backlog');
await createProjectColumn(page.request, user, repoName, String(project.id), 'Done');
await page.goto(`/${user}/${repoName}/projects/${project.id}/workflows`);
await expect(page.locator('.workflow-sidebar')).toBeVisible();
return project;
}
/** Click the first sidebar item and save it with the first column option. */
/** Click the first sidebar item and save it with the Backlog column. */
async function configureFirstWorkflow(page: Page) {
const firstItem = page.locator('.workflow-item').first();
await firstItem.click();
await expect(editorActionButton(page, 'Save')).toBeVisible();
// Use the "Move to column" action field specifically; the first select in the form
// is "Apply to" (issue-type filter), not the column action select.
await moveToColumnSelect(page).selectOption({index: 1});
await moveToColumnSelect(page).selectOption({label: 'Backlog'});
await clickEditorAction(page, 'Save');
await expect(page.locator('.workflow-editor .workflow-status.status-enabled')).toBeVisible();
}
@ -76,10 +75,8 @@ test('project workflow: configure and toggle enable/disable', async ({page}) =>
try {
const project = await createProject(page, {owner: user, repo: repoName, title: 'Workflow Project'});
await Promise.all([
createProjectColumn(page.request, user, repoName, String(project.id), 'Backlog'),
createProjectColumn(page.request, user, repoName, String(project.id), 'Done'),
]);
await createProjectColumn(page.request, user, repoName, String(project.id), 'Backlog');
await createProjectColumn(page.request, user, repoName, String(project.id), 'Done');
await page.goto(`/${user}/${repoName}/projects/${project.id}/workflows`);
@ -245,7 +242,7 @@ test('project workflow: "Apply to" filter persists across save and re-open', asy
await applyToSelect(page).selectOption({label: 'Issues only'});
// Set the required column action too.
await moveToColumnSelect(page).selectOption({index: 1});
await moveToColumnSelect(page).selectOption({label: 'Backlog'});
await clickEditorAction(page, 'Save');
await expect(page.locator('.workflow-editor .workflow-status.status-enabled')).toBeVisible();
@ -264,11 +261,11 @@ test('project workflow: editing a saved workflow updates its configuration', asy
await Promise.all([login(page), apiCreateRepo(page.request, {name: repoName})]);
try {
await setupWorkflowPage(page, repoName);
await configureFirstWorkflow(page); // saves with 'Backlog' (index 1)
await configureFirstWorkflow(page);
// Edit the workflow and switch to the second column ('Done', index 2).
// Edit the workflow and switch to the Done column.
await clickEditorAction(page, 'Edit');
await moveToColumnSelect(page).selectOption({index: 2});
await moveToColumnSelect(page).selectOption({label: 'Done'});
await clickEditorAction(page, 'Save');
// After save, view mode should reflect the updated column title.

View File

@ -139,12 +139,16 @@ func testNewIssue(t *testing.T, session *TestSession, user, repo string, opts ne
assert.True(t, exists, "The template has changed")
labelIDs := base.Int64sToStrings(opts.LabelIDs)
projectIDs := ""
if opts.ProjectID > 0 {
projectIDs = strconv.FormatInt(opts.ProjectID, 10)
}
req = NewRequestWithValues(t, "POST", link, map[string]string{
"title": opts.Title,
"content": opts.Content,
"project_id": strconv.FormatInt(opts.ProjectID, 10),
"label_ids": strings.Join(labelIDs, ","),
"title": opts.Title,
"content": opts.Content,
"project_ids": projectIDs,
"label_ids": strings.Join(labelIDs, ","),
})
resp = session.MakeRequest(t, req, http.StatusOK)

View File

@ -56,11 +56,14 @@ func testNewIssueReturnIssue(t *testing.T, session *TestSession, repo *repo_mode
// testAddIssueToProject adds the issue to the project via web form if projectID == 0, it removes the issue from the project
func testAddIssueToProject(t *testing.T, session *TestSession, userName, repoName string, projectID, issueID int64) {
addToProjectReq := NewRequestWithValues(t, "POST", fmt.Sprintf("/%s/%s/issues/projects",
userName, repoName),
projectValue := ""
if projectID > 0 {
projectValue = strconv.FormatInt(projectID, 10)
}
addToProjectReq := NewRequestWithValues(t, "POST", fmt.Sprintf("/%s/%s/issues/projects?issue_ids=%d",
userName, repoName, issueID),
map[string]string{
"id": strconv.FormatInt(projectID, 10),
"issue_ids": strconv.FormatInt(issueID, 10),
"id": projectValue,
})
session.MakeRequest(t, addToProjectReq, http.StatusOK)
}