Merge pull request 'Refactor repo migration items' (#4710) from 0ko/forgejo:ui-migration-items into forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4710 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
This commit is contained in:
commit
ef7313097c
8 changed files with 199 additions and 44 deletions
|
@ -34,9 +34,19 @@
|
||||||
<div class="inline field">
|
<div class="inline field">
|
||||||
<label>{{ctx.Locale.Tr "repo.migrate_items"}}</label>
|
<label>{{ctx.Locale.Tr "repo.migrate_items"}}</label>
|
||||||
<div class="ui checkbox">
|
<div class="ui checkbox">
|
||||||
<input name="milestones" type="checkbox" {{if .milestones}}checked{{end}}>
|
<input name="issues" type="checkbox" {{if .issues}}checked{{end}}>
|
||||||
<label>{{ctx.Locale.Tr "repo.migrate_items_milestones"}}</label>
|
<label>{{ctx.Locale.Tr "repo.migrate_items_issues"}}</label>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="inline field">
|
||||||
|
<label></label>
|
||||||
|
<div class="ui checkbox">
|
||||||
|
<input name="pull_requests" type="checkbox" {{if .pull_requests}}checked{{end}}>
|
||||||
|
<label>{{ctx.Locale.Tr "repo.migrate_items_merge_requests"}}</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="inline field">
|
||||||
|
<label></label>
|
||||||
<div class="ui checkbox">
|
<div class="ui checkbox">
|
||||||
<input name="labels" type="checkbox" {{if .labels}}checked{{end}}>
|
<input name="labels" type="checkbox" {{if .labels}}checked{{end}}>
|
||||||
<label>{{ctx.Locale.Tr "repo.migrate_items_labels"}}</label>
|
<label>{{ctx.Locale.Tr "repo.migrate_items_labels"}}</label>
|
||||||
|
@ -45,12 +55,8 @@
|
||||||
<div class="inline field">
|
<div class="inline field">
|
||||||
<label></label>
|
<label></label>
|
||||||
<div class="ui checkbox">
|
<div class="ui checkbox">
|
||||||
<input name="issues" type="checkbox" {{if .issues}}checked{{end}}>
|
<input name="milestones" type="checkbox" {{if .milestones}}checked{{end}}>
|
||||||
<label>{{ctx.Locale.Tr "repo.migrate_items_issues"}}</label>
|
<label>{{ctx.Locale.Tr "repo.migrate_items_milestones"}}</label>
|
||||||
</div>
|
|
||||||
<div class="ui checkbox">
|
|
||||||
<input name="pull_requests" type="checkbox" {{if .pull_requests}}checked{{end}}>
|
|
||||||
<label>{{ctx.Locale.Tr "repo.migrate_items_merge_requests"}}</label>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -42,10 +42,6 @@
|
||||||
<span class="help">{{ctx.Locale.Tr "repo.migrate.migrate_items_options"}}</span>
|
<span class="help">{{ctx.Locale.Tr "repo.migrate.migrate_items_options"}}</span>
|
||||||
<div class="inline field">
|
<div class="inline field">
|
||||||
<label></label>
|
<label></label>
|
||||||
<div class="ui checkbox">
|
|
||||||
<input name="labels" type="checkbox" {{if .labels}}checked{{end}}>
|
|
||||||
<label>{{ctx.Locale.Tr "repo.migrate_items_labels"}}</label>
|
|
||||||
</div>
|
|
||||||
<div class="ui checkbox">
|
<div class="ui checkbox">
|
||||||
<input name="issues" type="checkbox" {{if .issues}}checked{{end}}>
|
<input name="issues" type="checkbox" {{if .issues}}checked{{end}}>
|
||||||
<label>{{ctx.Locale.Tr "repo.migrate_items_issues"}}</label>
|
<label>{{ctx.Locale.Tr "repo.migrate_items_issues"}}</label>
|
||||||
|
@ -57,9 +53,12 @@
|
||||||
<input name="pull_requests" type="checkbox" {{if .pull_requests}}checked{{end}}>
|
<input name="pull_requests" type="checkbox" {{if .pull_requests}}checked{{end}}>
|
||||||
<label>{{ctx.Locale.Tr "repo.migrate_items_pullrequests"}}</label>
|
<label>{{ctx.Locale.Tr "repo.migrate_items_pullrequests"}}</label>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="inline field">
|
||||||
|
<label></label>
|
||||||
<div class="ui checkbox">
|
<div class="ui checkbox">
|
||||||
<input name="releases" type="checkbox" {{if .releases}}checked{{end}}>
|
<input name="labels" type="checkbox" {{if .labels}}checked{{end}}>
|
||||||
<label>{{ctx.Locale.Tr "repo.migrate_items_releases"}}</label>
|
<label>{{ctx.Locale.Tr "repo.migrate_items_labels"}}</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="inline field">
|
<div class="inline field">
|
||||||
|
@ -69,6 +68,13 @@
|
||||||
<label>{{ctx.Locale.Tr "repo.migrate_items_milestones"}}</label>
|
<label>{{ctx.Locale.Tr "repo.migrate_items_milestones"}}</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="inline field">
|
||||||
|
<label></label>
|
||||||
|
<div class="ui checkbox">
|
||||||
|
<input name="releases" type="checkbox" {{if .releases}}checked{{end}}>
|
||||||
|
<label>{{ctx.Locale.Tr "repo.migrate_items_releases"}}</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="divider"></div>
|
<div class="divider"></div>
|
||||||
|
|
|
@ -38,10 +38,6 @@
|
||||||
<span class="help">{{ctx.Locale.Tr "repo.migrate.migrate_items_options"}}</span>
|
<span class="help">{{ctx.Locale.Tr "repo.migrate.migrate_items_options"}}</span>
|
||||||
<div class="inline field">
|
<div class="inline field">
|
||||||
<label></label>
|
<label></label>
|
||||||
<div class="ui checkbox">
|
|
||||||
<input name="labels" type="checkbox" {{if .labels}} checked{{end}}>
|
|
||||||
<label>{{ctx.Locale.Tr "repo.migrate_items_labels"}}</label>
|
|
||||||
</div>
|
|
||||||
<div class="ui checkbox">
|
<div class="ui checkbox">
|
||||||
<input name="issues" type="checkbox" {{if .issues}} checked{{end}}>
|
<input name="issues" type="checkbox" {{if .issues}} checked{{end}}>
|
||||||
<label>{{ctx.Locale.Tr "repo.migrate_items_issues"}}</label>
|
<label>{{ctx.Locale.Tr "repo.migrate_items_issues"}}</label>
|
||||||
|
@ -53,9 +49,12 @@
|
||||||
<input name="pull_requests" type="checkbox" {{if .pull_requests}} checked{{end}}>
|
<input name="pull_requests" type="checkbox" {{if .pull_requests}} checked{{end}}>
|
||||||
<label>{{ctx.Locale.Tr "repo.migrate_items_pullrequests"}}</label>
|
<label>{{ctx.Locale.Tr "repo.migrate_items_pullrequests"}}</label>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="inline field">
|
||||||
|
<label></label>
|
||||||
<div class="ui checkbox">
|
<div class="ui checkbox">
|
||||||
<input name="releases" type="checkbox" {{if .releases}} checked{{end}}>
|
<input name="labels" type="checkbox" {{if .labels}} checked{{end}}>
|
||||||
<label>{{ctx.Locale.Tr "repo.migrate_items_releases"}}</label>
|
<label>{{ctx.Locale.Tr "repo.migrate_items_labels"}}</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="inline field">
|
<div class="inline field">
|
||||||
|
@ -65,6 +64,13 @@
|
||||||
<label>{{ctx.Locale.Tr "repo.migrate_items_milestones"}}</label>
|
<label>{{ctx.Locale.Tr "repo.migrate_items_milestones"}}</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="inline field">
|
||||||
|
<label></label>
|
||||||
|
<div class="ui checkbox">
|
||||||
|
<input name="releases" type="checkbox" {{if .releases}} checked{{end}}>
|
||||||
|
<label>{{ctx.Locale.Tr "repo.migrate_items_releases"}}</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="divider"></div>
|
<div class="divider"></div>
|
||||||
|
|
|
@ -40,10 +40,6 @@
|
||||||
<span class="help">{{ctx.Locale.Tr "repo.migrate.migrate_items_options"}}</span>
|
<span class="help">{{ctx.Locale.Tr "repo.migrate.migrate_items_options"}}</span>
|
||||||
<div class="inline field">
|
<div class="inline field">
|
||||||
<label></label>
|
<label></label>
|
||||||
<div class="ui checkbox">
|
|
||||||
<input name="labels" type="checkbox" {{if .labels}}checked{{end}}>
|
|
||||||
<label>{{ctx.Locale.Tr "repo.migrate_items_labels"}}</label>
|
|
||||||
</div>
|
|
||||||
<div class="ui checkbox">
|
<div class="ui checkbox">
|
||||||
<input name="issues" type="checkbox" {{if .issues}}checked{{end}}>
|
<input name="issues" type="checkbox" {{if .issues}}checked{{end}}>
|
||||||
<label>{{ctx.Locale.Tr "repo.migrate_items_issues"}}</label>
|
<label>{{ctx.Locale.Tr "repo.migrate_items_issues"}}</label>
|
||||||
|
@ -55,9 +51,12 @@
|
||||||
<input name="pull_requests" type="checkbox" {{if .pull_requests}}checked{{end}}>
|
<input name="pull_requests" type="checkbox" {{if .pull_requests}}checked{{end}}>
|
||||||
<label>{{ctx.Locale.Tr "repo.migrate_items_pullrequests"}}</label>
|
<label>{{ctx.Locale.Tr "repo.migrate_items_pullrequests"}}</label>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="inline field">
|
||||||
|
<label></label>
|
||||||
<div class="ui checkbox">
|
<div class="ui checkbox">
|
||||||
<input name="releases" type="checkbox" {{if .releases}}checked{{end}}>
|
<input name="labels" type="checkbox" {{if .labels}}checked{{end}}>
|
||||||
<label>{{ctx.Locale.Tr "repo.migrate_items_releases"}}</label>
|
<label>{{ctx.Locale.Tr "repo.migrate_items_labels"}}</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="inline field">
|
<div class="inline field">
|
||||||
|
@ -67,6 +66,13 @@
|
||||||
<label>{{ctx.Locale.Tr "repo.migrate_items_milestones"}}</label>
|
<label>{{ctx.Locale.Tr "repo.migrate_items_milestones"}}</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="inline field">
|
||||||
|
<label></label>
|
||||||
|
<div class="ui checkbox">
|
||||||
|
<input name="releases" type="checkbox" {{if .releases}}checked{{end}}>
|
||||||
|
<label>{{ctx.Locale.Tr "repo.migrate_items_releases"}}</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="divider"></div>
|
<div class="divider"></div>
|
||||||
|
|
|
@ -37,10 +37,6 @@
|
||||||
<span class="help">{{ctx.Locale.Tr "repo.migrate.migrate_items_options"}}</span>
|
<span class="help">{{ctx.Locale.Tr "repo.migrate.migrate_items_options"}}</span>
|
||||||
<div class="inline field">
|
<div class="inline field">
|
||||||
<label></label>
|
<label></label>
|
||||||
<div class="ui checkbox">
|
|
||||||
<input name="labels" type="checkbox" {{if .labels}}checked{{end}}>
|
|
||||||
<label>{{ctx.Locale.Tr "repo.migrate_items_labels"}}</label>
|
|
||||||
</div>
|
|
||||||
<div class="ui checkbox">
|
<div class="ui checkbox">
|
||||||
<input name="issues" type="checkbox" {{if .issues}}checked{{end}}>
|
<input name="issues" type="checkbox" {{if .issues}}checked{{end}}>
|
||||||
<label>{{ctx.Locale.Tr "repo.migrate_items_issues"}}</label>
|
<label>{{ctx.Locale.Tr "repo.migrate_items_issues"}}</label>
|
||||||
|
@ -52,9 +48,12 @@
|
||||||
<input name="pull_requests" type="checkbox" {{if .pull_requests}}checked{{end}}>
|
<input name="pull_requests" type="checkbox" {{if .pull_requests}}checked{{end}}>
|
||||||
<label>{{ctx.Locale.Tr "repo.migrate_items_merge_requests"}}</label>
|
<label>{{ctx.Locale.Tr "repo.migrate_items_merge_requests"}}</label>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="inline field">
|
||||||
|
<label></label>
|
||||||
<div class="ui checkbox">
|
<div class="ui checkbox">
|
||||||
<input name="releases" type="checkbox" {{if .releases}}checked{{end}}>
|
<input name="labels" type="checkbox" {{if .labels}}checked{{end}}>
|
||||||
<label>{{ctx.Locale.Tr "repo.migrate_items_releases"}}</label>
|
<label>{{ctx.Locale.Tr "repo.migrate_items_labels"}}</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="inline field">
|
<div class="inline field">
|
||||||
|
@ -64,6 +63,13 @@
|
||||||
<label>{{ctx.Locale.Tr "repo.migrate_items_milestones"}}</label>
|
<label>{{ctx.Locale.Tr "repo.migrate_items_milestones"}}</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="inline field">
|
||||||
|
<label></label>
|
||||||
|
<div class="ui checkbox">
|
||||||
|
<input name="releases" type="checkbox" {{if .releases}}checked{{end}}>
|
||||||
|
<label>{{ctx.Locale.Tr "repo.migrate_items_releases"}}</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="divider"></div>
|
<div class="divider"></div>
|
||||||
|
|
|
@ -38,15 +38,18 @@
|
||||||
<span class="help">{{ctx.Locale.Tr "repo.migrate.migrate_items_options"}}</span>
|
<span class="help">{{ctx.Locale.Tr "repo.migrate.migrate_items_options"}}</span>
|
||||||
<div class="inline field">
|
<div class="inline field">
|
||||||
<label></label>
|
<label></label>
|
||||||
<div class="ui checkbox">
|
|
||||||
<input name="labels" type="checkbox" {{if .labels}} checked{{end}}>
|
|
||||||
<label>{{ctx.Locale.Tr "repo.migrate_items_labels"}}</label>
|
|
||||||
</div>
|
|
||||||
<div class="ui checkbox">
|
<div class="ui checkbox">
|
||||||
<input name="issues" type="checkbox" {{if .issues}} checked{{end}}>
|
<input name="issues" type="checkbox" {{if .issues}} checked{{end}}>
|
||||||
<label>{{ctx.Locale.Tr "repo.migrate_items_issues"}}</label>
|
<label>{{ctx.Locale.Tr "repo.migrate_items_issues"}}</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="inline field">
|
||||||
|
<label></label>
|
||||||
|
<div class="ui checkbox">
|
||||||
|
<input name="labels" type="checkbox" {{if .labels}} checked{{end}}>
|
||||||
|
<label>{{ctx.Locale.Tr "repo.migrate_items_labels"}}</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="inline field">
|
<div class="inline field">
|
||||||
<label></label>
|
<label></label>
|
||||||
<div class="ui checkbox">
|
<div class="ui checkbox">
|
||||||
|
|
|
@ -34,9 +34,19 @@
|
||||||
<div class="inline field">
|
<div class="inline field">
|
||||||
<label>{{ctx.Locale.Tr "repo.migrate_items"}}</label>
|
<label>{{ctx.Locale.Tr "repo.migrate_items"}}</label>
|
||||||
<div class="ui checkbox">
|
<div class="ui checkbox">
|
||||||
<input name="milestones" type="checkbox" {{if .milestones}}checked{{end}}>
|
<input name="issues" type="checkbox" {{if .issues}}checked{{end}}>
|
||||||
<label>{{ctx.Locale.Tr "repo.migrate_items_milestones"}}</label>
|
<label>{{ctx.Locale.Tr "repo.migrate_items_issues"}}</label>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="inline field">
|
||||||
|
<label></label>
|
||||||
|
<div class="ui checkbox">
|
||||||
|
<input name="pull_requests" type="checkbox" {{if .pull_requests}}checked{{end}}>
|
||||||
|
<label>{{ctx.Locale.Tr "repo.migrate_items_pullrequests"}}</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="inline field">
|
||||||
|
<label></label>
|
||||||
<div class="ui checkbox">
|
<div class="ui checkbox">
|
||||||
<input name="labels" type="checkbox" {{if .labels}}checked{{end}}>
|
<input name="labels" type="checkbox" {{if .labels}}checked{{end}}>
|
||||||
<label>{{ctx.Locale.Tr "repo.migrate_items_labels"}}</label>
|
<label>{{ctx.Locale.Tr "repo.migrate_items_labels"}}</label>
|
||||||
|
@ -45,12 +55,8 @@
|
||||||
<div class="inline field">
|
<div class="inline field">
|
||||||
<label></label>
|
<label></label>
|
||||||
<div class="ui checkbox">
|
<div class="ui checkbox">
|
||||||
<input name="issues" type="checkbox" {{if .issues}}checked{{end}}>
|
<input name="milestones" type="checkbox" {{if .milestones}}checked{{end}}>
|
||||||
<label>{{ctx.Locale.Tr "repo.migrate_items_issues"}}</label>
|
<label>{{ctx.Locale.Tr "repo.migrate_items_milestones"}}</label>
|
||||||
</div>
|
|
||||||
<div class="ui checkbox">
|
|
||||||
<input name="pull_requests" type="checkbox" {{if .pull_requests}}checked{{end}}>
|
|
||||||
<label>{{ctx.Locale.Tr "repo.migrate_items_pullrequests"}}</label>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
116
tests/integration/repo_migration_ui_test.go
Normal file
116
tests/integration/repo_migration_ui_test.go
Normal file
|
@ -0,0 +1,116 @@
|
||||||
|
// Copyright 2024 The Forgejo Authors. All rights reserved.
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
package integration
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/PuerkitoBio/goquery"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestRepoMigrationUI(t *testing.T) {
|
||||||
|
onGiteaRun(t, func(t *testing.T, giteaURL *url.URL) {
|
||||||
|
sessionUser1 := loginUser(t, "user1")
|
||||||
|
// Nothing is tested in plain Git migration form right now
|
||||||
|
testRepoMigrationFormGitHub(t, sessionUser1)
|
||||||
|
testRepoMigrationFormGitea(t, sessionUser1)
|
||||||
|
testRepoMigrationFormGitLab(t, sessionUser1)
|
||||||
|
testRepoMigrationFormGogs(t, sessionUser1)
|
||||||
|
testRepoMigrationFormOneDev(t, sessionUser1)
|
||||||
|
testRepoMigrationFormGitBucket(t, sessionUser1)
|
||||||
|
testRepoMigrationFormCodebase(t, sessionUser1)
|
||||||
|
testRepoMigrationFormForgejo(t, sessionUser1)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func testRepoMigrationFormGitHub(t *testing.T, session *TestSession) {
|
||||||
|
response := session.MakeRequest(t, NewRequest(t, "GET", "/repo/migrate?service_type=2"), http.StatusOK)
|
||||||
|
page := NewHTMLParser(t, response.Body)
|
||||||
|
|
||||||
|
items := page.Find("#migrate_items .field .checkbox input")
|
||||||
|
expectedItems := []string{"issues", "pull_requests", "labels", "milestones", "releases"}
|
||||||
|
testRepoMigrationFormItems(t, items, expectedItems)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testRepoMigrationFormGitea(t *testing.T, session *TestSession) {
|
||||||
|
response := session.MakeRequest(t, NewRequest(t, "GET", "/repo/migrate?service_type=3"), http.StatusOK)
|
||||||
|
page := NewHTMLParser(t, response.Body)
|
||||||
|
|
||||||
|
items := page.Find("#migrate_items .field .checkbox input")
|
||||||
|
expectedItems := []string{"issues", "pull_requests", "labels", "milestones", "releases"}
|
||||||
|
testRepoMigrationFormItems(t, items, expectedItems)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testRepoMigrationFormGitLab(t *testing.T, session *TestSession) {
|
||||||
|
response := session.MakeRequest(t, NewRequest(t, "GET", "/repo/migrate?service_type=4"), http.StatusOK)
|
||||||
|
page := NewHTMLParser(t, response.Body)
|
||||||
|
|
||||||
|
items := page.Find("#migrate_items .field .checkbox input")
|
||||||
|
// Note: the checkbox "Merge requests" has name "pull_requests"
|
||||||
|
expectedItems := []string{"issues", "pull_requests", "labels", "milestones", "releases"}
|
||||||
|
testRepoMigrationFormItems(t, items, expectedItems)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testRepoMigrationFormGogs(t *testing.T, session *TestSession) {
|
||||||
|
response := session.MakeRequest(t, NewRequest(t, "GET", "/repo/migrate?service_type=5"), http.StatusOK)
|
||||||
|
page := NewHTMLParser(t, response.Body)
|
||||||
|
|
||||||
|
items := page.Find("#migrate_items .field .checkbox input")
|
||||||
|
expectedItems := []string{"issues", "labels", "milestones"}
|
||||||
|
testRepoMigrationFormItems(t, items, expectedItems)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testRepoMigrationFormOneDev(t *testing.T, session *TestSession) {
|
||||||
|
response := session.MakeRequest(t, NewRequest(t, "GET", "/repo/migrate?service_type=6"), http.StatusOK)
|
||||||
|
page := NewHTMLParser(t, response.Body)
|
||||||
|
|
||||||
|
items := page.Find("#migrate_items .field .checkbox input")
|
||||||
|
expectedItems := []string{"issues", "pull_requests", "labels", "milestones"}
|
||||||
|
testRepoMigrationFormItems(t, items, expectedItems)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testRepoMigrationFormGitBucket(t *testing.T, session *TestSession) {
|
||||||
|
response := session.MakeRequest(t, NewRequest(t, "GET", "/repo/migrate?service_type=7"), http.StatusOK)
|
||||||
|
page := NewHTMLParser(t, response.Body)
|
||||||
|
|
||||||
|
items := page.Find("#migrate_items .field .checkbox input")
|
||||||
|
expectedItems := []string{"issues", "pull_requests", "labels", "milestones", "releases"}
|
||||||
|
testRepoMigrationFormItems(t, items, expectedItems)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testRepoMigrationFormCodebase(t *testing.T, session *TestSession) {
|
||||||
|
response := session.MakeRequest(t, NewRequest(t, "GET", "/repo/migrate?service_type=8"), http.StatusOK)
|
||||||
|
page := NewHTMLParser(t, response.Body)
|
||||||
|
|
||||||
|
items := page.Find("#migrate_items .field .checkbox input")
|
||||||
|
// Note: the checkbox "Merge requests" has name "pull_requests"
|
||||||
|
expectedItems := []string{"issues", "pull_requests", "labels", "milestones"}
|
||||||
|
testRepoMigrationFormItems(t, items, expectedItems)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testRepoMigrationFormForgejo(t *testing.T, session *TestSession) {
|
||||||
|
response := session.MakeRequest(t, NewRequest(t, "GET", "/repo/migrate?service_type=9"), http.StatusOK)
|
||||||
|
page := NewHTMLParser(t, response.Body)
|
||||||
|
|
||||||
|
items := page.Find("#migrate_items .field .checkbox input")
|
||||||
|
expectedItems := []string{"issues", "pull_requests", "labels", "milestones", "releases"}
|
||||||
|
testRepoMigrationFormItems(t, items, expectedItems)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testRepoMigrationFormItems(t *testing.T, items *goquery.Selection, expectedItems []string) {
|
||||||
|
t.Helper()
|
||||||
|
|
||||||
|
// Compare lengths of item lists
|
||||||
|
assert.EqualValues(t, len(expectedItems), items.Length())
|
||||||
|
|
||||||
|
// Compare contents of item lists
|
||||||
|
for index, expectedName := range expectedItems {
|
||||||
|
name, exists := items.Eq(index).Attr("name")
|
||||||
|
assert.True(t, exists)
|
||||||
|
assert.EqualValues(t, expectedName, name)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue