From ea42b1eadbc7fe914bb64beed37b929d558e3f32 Mon Sep 17 00:00:00 2001 From: 0ko <0ko@noreply.codeberg.org> Date: Mon, 24 Feb 2025 00:41:15 +0000 Subject: [PATCH] feat(ui): include MIME type for archive links in folder download (#7037) This is the same PR as https://codeberg.org/forgejo/forgejo/pulls/6959, but for the new links from https://codeberg.org/forgejo/forgejo/pulls/4736. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7037 Reviewed-by: Gusted Reviewed-by: Otto Co-authored-by: 0ko <0ko@noreply.codeberg.org> Co-committed-by: 0ko <0ko@noreply.codeberg.org> --- templates/repo/home.tmpl | 4 ++-- tests/integration/repo_archive_test.go | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/templates/repo/home.tmpl b/templates/repo/home.tmpl index dc336700b6..871790ce28 100644 --- a/templates/repo/home.tmpl +++ b/templates/repo/home.tmpl @@ -149,8 +149,8 @@ {{end}} diff --git a/tests/integration/repo_archive_test.go b/tests/integration/repo_archive_test.go index 277ead4a28..a5c076952c 100644 --- a/tests/integration/repo_archive_test.go +++ b/tests/integration/repo_archive_test.go @@ -1,4 +1,5 @@ // Copyright 2024 The Gitea Authors. All rights reserved. +// Copyright 2024 The Forgejo Authors. All rights reserved. // SPDX-License-Identifier: MIT package integration @@ -55,9 +56,10 @@ func TestRepoDownloadArchiveSubdir(t *testing.T) { t.Run("Frontend", func(t *testing.T) { resp := MakeRequest(t, NewRequestf(t, "GET", "/%s/src/branch/master/subdir", repo.FullName()), http.StatusOK) + page := NewHTMLParser(t, resp.Body) - assert.Contains(t, resp.Body.String(), fmt.Sprintf("/%s/archive/master:subdir.zip", repo.FullName())) - assert.Contains(t, resp.Body.String(), fmt.Sprintf("/%s/archive/master:subdir.tar.gz", repo.FullName())) + page.AssertElement(t, fmt.Sprintf(".folder-actions a.archive-link[href='/%s/archive/master:subdir.zip'][type='application/zip']", repo.FullName()), true) + page.AssertElement(t, fmt.Sprintf(".folder-actions a.archive-link[href='/%s/archive/master:subdir.tar.gz'][type='application/gzip']", repo.FullName()), true) }) t.Run("Backend", func(t *testing.T) {