From 634519e891f7f7f9831ed365fd51f47649b8cb19 Mon Sep 17 00:00:00 2001 From: 0ko <0ko@noreply.codeberg.org> Date: Sun, 10 Nov 2024 17:57:32 +0500 Subject: [PATCH] feat(ui): highlight user mention in comments and commit messages --- templates/base/head.tmpl | 1 + templates/shared/user/mention_highlight.tmpl | 14 +++++++++++++ tests/integration/mention_test.go | 21 ++++++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 templates/shared/user/mention_highlight.tmpl create mode 100644 tests/integration/mention_test.go diff --git a/templates/base/head.tmpl b/templates/base/head.tmpl index 7753f49243..9eb5b5addf 100644 --- a/templates/base/head.tmpl +++ b/templates/base/head.tmpl @@ -26,6 +26,7 @@ .ui.secondary.menu .dropdown.item > .menu { margin-top: 0; } + {{template "shared/user/mention_highlight" .}} {{template "base/head_opengraph" .}} {{template "base/head_style" .}} {{template "custom/header" .}} diff --git a/templates/shared/user/mention_highlight.tmpl b/templates/shared/user/mention_highlight.tmpl new file mode 100644 index 0000000000..1551cef874 --- /dev/null +++ b/templates/shared/user/mention_highlight.tmpl @@ -0,0 +1,14 @@ +{{if .IsSigned}} + +{{end}} diff --git a/tests/integration/mention_test.go b/tests/integration/mention_test.go new file mode 100644 index 0000000000..36a0ccb312 --- /dev/null +++ b/tests/integration/mention_test.go @@ -0,0 +1,21 @@ +// Copyright 2024 The Forgejo Authors. All rights reserved. +// SPDX-License-Identifier: GPL-3.0-or-later + +package integration + +import ( + "net/http" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestHeadMentionCSS(t *testing.T) { + userSession := loginUser(t, "user2") + resp := userSession.MakeRequest(t, NewRequest(t, "GET", "/"), http.StatusOK) + assert.Contains(t, resp.Body.String(), `.mention[href="/user2" i]`) + + guestSession := emptyTestSession(t) + resp = guestSession.MakeRequest(t, NewRequest(t, "GET", "/"), http.StatusOK) + assert.NotContains(t, resp.Body.String(), `.mention[href="`) +}