fix(ui): use correct string for pagure description (#8987)

Followup to https://codeberg.org/forgejo/forgejo/pulls/8513

As we already got translated strings w/ incorrect key, I prefer to not touch them and teach the UI a workaround. Maybe later all related INI strings will be migrated to JSON without the prefix, too.

Preview
Before: https://codeberg.org/forgejo/forgejo/attachments/8e603325-bb2b-4e32-a9bc-f1fa20b6c40b
After: https://codeberg.org/forgejo/forgejo/attachments/38e8afeb-5214-4085-bd6c-3ba8ff3894cd

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8987
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Reviewed-by: Beowulf <beowulf@beocode.eu>
This commit is contained in:
0ko 2025-08-22 12:00:08 +02:00
commit f58f84562a
2 changed files with 33 additions and 3 deletions

View file

@ -16,7 +16,11 @@
{{.Title}}
</h3>
<div class="description">
{{ctx.Locale.Tr (printf "repo.migrate.%s.description" .Name)}}
{{if eq .Name "pagure"}}
{{ctx.Locale.Tr "migrate.pagure.description"}}
{{else}}
{{ctx.Locale.Tr (printf "repo.migrate.%s.description" .Name)}}
{{end}}
</div>
</div>
</a>

View file

@ -1,4 +1,4 @@
// Copyright 2024 The Forgejo Authors. All rights reserved.
// Copyright 2024-2025 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: GPL-3.0-or-later
package integration
@ -6,15 +6,18 @@ package integration
import (
"fmt"
"net/http"
"strings"
"testing"
"forgejo.org/modules/translation"
"forgejo.org/tests"
"github.com/PuerkitoBio/goquery"
"github.com/stretchr/testify/assert"
)
// TestRepoMigrationUI is used to test various form properties of different migration types
// TestRepoMigrationUI is used to test various form properties of different
// migration types on /repo/migrate?service_type=%d
func TestRepoMigrationUI(t *testing.T) {
defer tests.PrepareTestEnv(t)()
session := loginUser(t, "user1")
@ -103,3 +106,26 @@ func testRepoMigrationFormItems(t *testing.T, items *goquery.Selection, expected
assert.Equal(t, expectedName, name)
}
}
// TestRepoMigrationTypeSelect is a simple content test for page /repo/migrate
// where migration source type is selected
func TestRepoMigrationTypeSelect(t *testing.T) {
defer tests.PrepareTestEnv(t)()
session := loginUser(t, "user1")
locale := translation.NewLocale("en-US")
page := NewHTMLParser(t, session.MakeRequest(t, NewRequest(t, "GET", "/repo/migrate"), http.StatusOK).Body)
headers := page.Find(".migrate-entry h3").Text()
descriptions := page.Find(".migrate-entry .description").Text()
sourceNames := []string{"github", "gitea", "gitlab", "gogs", "onedev", "gitbucket", "codebase", "forgejo"}
for _, sourceName := range sourceNames {
assert.Contains(t, strings.ToLower(headers), sourceName)
assert.Contains(t, descriptions, locale.Tr(fmt.Sprintf("repo.migrate.%s.description", sourceName)))
}
// Special case
assert.Contains(t, strings.ToLower(headers), "pagure")
assert.Contains(t, descriptions, locale.Tr("migrate.pagure.description")) // Not prefixed with repo.
}