From a23d0453a37620e3ca5e3d057bd16da3e166a1c0 Mon Sep 17 00:00:00 2001 From: 0ko <0ko@noreply.codeberg.org> Date: Sun, 30 Mar 2025 11:31:42 +0000 Subject: [PATCH] feat(ui/migrations): clarify desired autocompletion type for clone_addr (#7377) * Firefox thinks that this is a login form and that `clone_addr` is it's username field * It would have been an easy fix with with `autocomplete="off"`, but there's an issue with that approach: Firefox plays a cat-mouse game with web developers and intentionally ignores `autocomplete="off"` "for users' security". * Set it to the `url` autocompletion type, Firefox and maybe other browsers give actually somewhat relevant completion entries. They will not be always relevant, but they may be when a migration has to be re-done with different settings. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7377 Reviewed-by: Gusted Co-authored-by: 0ko <0ko@noreply.codeberg.org> Co-committed-by: 0ko <0ko@noreply.codeberg.org> --- templates/repo/migrate/codebase.tmpl | 2 +- templates/repo/migrate/git.tmpl | 2 +- templates/repo/migrate/gitbucket.tmpl | 2 +- templates/repo/migrate/gitea.tmpl | 2 +- templates/repo/migrate/github.tmpl | 2 +- templates/repo/migrate/gitlab.tmpl | 2 +- templates/repo/migrate/gogs.tmpl | 2 +- templates/repo/migrate/onedev.tmpl | 2 +- tests/integration/repo_migration_ui_test.go | 8 +++++--- 9 files changed, 13 insertions(+), 11 deletions(-) diff --git a/templates/repo/migrate/codebase.tmpl b/templates/repo/migrate/codebase.tmpl index 0b71c0d9b3..1343e52cdc 100644 --- a/templates/repo/migrate/codebase.tmpl +++ b/templates/repo/migrate/codebase.tmpl @@ -13,7 +13,7 @@ {{template "base/alert" .}}
- + {{ctx.Locale.Tr "repo.migrate.clone_address_desc"}}{{if .ContextUser.CanImportLocal}} {{ctx.Locale.Tr "repo.migrate.clone_local_path"}}{{end}} diff --git a/templates/repo/migrate/git.tmpl b/templates/repo/migrate/git.tmpl index 5ebf4cfd6a..981260de5a 100644 --- a/templates/repo/migrate/git.tmpl +++ b/templates/repo/migrate/git.tmpl @@ -13,7 +13,7 @@ {{template "base/alert" .}}
- + {{ctx.Locale.Tr "repo.migrate.clone_address_desc"}}{{if .ContextUser.CanImportLocal}} {{ctx.Locale.Tr "repo.migrate.clone_local_path"}}{{end}} diff --git a/templates/repo/migrate/gitbucket.tmpl b/templates/repo/migrate/gitbucket.tmpl index e8d6b60dea..b8d82eb7e2 100644 --- a/templates/repo/migrate/gitbucket.tmpl +++ b/templates/repo/migrate/gitbucket.tmpl @@ -13,7 +13,7 @@ {{template "base/alert" .}}
- + {{ctx.Locale.Tr "repo.migrate.clone_address_desc"}}{{if .ContextUser.CanImportLocal}} {{ctx.Locale.Tr "repo.migrate.clone_local_path"}}{{end}} diff --git a/templates/repo/migrate/gitea.tmpl b/templates/repo/migrate/gitea.tmpl index f85ed4d2ab..baaff53d8d 100644 --- a/templates/repo/migrate/gitea.tmpl +++ b/templates/repo/migrate/gitea.tmpl @@ -12,7 +12,7 @@ {{template "base/alert" .}}
- + {{ctx.Locale.Tr "repo.migrate.clone_address_desc"}}{{if .ContextUser.CanImportLocal}} {{ctx.Locale.Tr "repo.migrate.clone_local_path"}}{{end}} diff --git a/templates/repo/migrate/github.tmpl b/templates/repo/migrate/github.tmpl index ebea97d807..a23baf9780 100644 --- a/templates/repo/migrate/github.tmpl +++ b/templates/repo/migrate/github.tmpl @@ -12,7 +12,7 @@ {{template "base/alert" .}}
- + {{ctx.Locale.Tr "repo.migrate.clone_address_desc"}} diff --git a/templates/repo/migrate/gitlab.tmpl b/templates/repo/migrate/gitlab.tmpl index c73a10529e..03edf5c787 100644 --- a/templates/repo/migrate/gitlab.tmpl +++ b/templates/repo/migrate/gitlab.tmpl @@ -12,7 +12,7 @@ {{template "base/alert" .}}
- + {{ctx.Locale.Tr "repo.migrate.clone_address_desc"}}{{if .ContextUser.CanImportLocal}} {{ctx.Locale.Tr "repo.migrate.clone_local_path"}}{{end}} diff --git a/templates/repo/migrate/gogs.tmpl b/templates/repo/migrate/gogs.tmpl index 1d7623f9a2..52da3d243b 100644 --- a/templates/repo/migrate/gogs.tmpl +++ b/templates/repo/migrate/gogs.tmpl @@ -12,7 +12,7 @@ {{template "base/alert" .}}
- + {{ctx.Locale.Tr "repo.migrate.clone_address_desc"}}{{if .ContextUser.CanImportLocal}} {{ctx.Locale.Tr "repo.migrate.clone_local_path"}}{{end}} diff --git a/templates/repo/migrate/onedev.tmpl b/templates/repo/migrate/onedev.tmpl index 7f1b3a900d..0434bcbe68 100644 --- a/templates/repo/migrate/onedev.tmpl +++ b/templates/repo/migrate/onedev.tmpl @@ -13,7 +13,7 @@ {{template "base/alert" .}}
- + {{ctx.Locale.Tr "repo.migrate.clone_address_desc"}}{{if .ContextUser.CanImportLocal}} {{ctx.Locale.Tr "repo.migrate.clone_local_path"}}{{end}} diff --git a/tests/integration/repo_migration_ui_test.go b/tests/integration/repo_migration_ui_test.go index 7251da5d7a..279e9861fe 100644 --- a/tests/integration/repo_migration_ui_test.go +++ b/tests/integration/repo_migration_ui_test.go @@ -79,10 +79,12 @@ func TestRepoMigrationUI(t *testing.T) { items := page.Find("#migrate_items .field .checkbox input") testRepoMigrationFormItems(t, items, migration.ExpectedItems) - descriptionInput := page.Find("#description") - assert.Equal(t, 1, descriptionInput.Length()) + page.AssertElement(t, "#clone_addr", true) + autocomplete, _ := page.Find("#clone_addr").Attr("autocomplete") + assert.Equal(t, "url", autocomplete) - _, descriptionHasPlaceholder := descriptionInput.Attr("placeholder") + page.AssertElement(t, "#description", true) + _, descriptionHasPlaceholder := page.Find("#description").Attr("placeholder") assert.Equal(t, migration.DescriptionHasPlaceholder, descriptionHasPlaceholder) }) }