mirror of
https://codeberg.org/forgejo/forgejo
synced 2024-11-22 01:44:24 +01:00
Compare commits
4 commits
0b2750714c
...
a7d3c04cb1
Author | SHA1 | Date | |
---|---|---|---|
a7d3c04cb1 | |||
f5c0570533 | |||
298863c701 | |||
c3653e0eaa |
|
@ -2622,9 +2622,9 @@ diff.browse_source = Browse source
|
|||
diff.parent = parent
|
||||
diff.commit = commit
|
||||
diff.git-notes = Notes
|
||||
diff.git-notes.add = Add Note
|
||||
diff.git-notes.remove-header = Remove Note
|
||||
diff.git-notes.remove-body = This will remove this Note
|
||||
diff.git-notes.add = Add note
|
||||
diff.git-notes.remove-header = Remove note
|
||||
diff.git-notes.remove-body = This note will be removed.
|
||||
diff.data_not_available = Diff content is not available
|
||||
diff.options_button = Diff options
|
||||
diff.show_diff_stats = Show stats
|
||||
|
|
|
@ -128,6 +128,9 @@
|
|||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div id="commit-notes-add-button" class="item">
|
||||
{{ctx.Locale.Tr "repo.diff.git-notes.add"}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
|
@ -277,20 +280,20 @@
|
|||
<span class="text grey" id="note-authored-time">{{DateUtils.TimeSince .NoteCommit.Author.When}}</span>
|
||||
{{if or ($.Permission.CanWrite $.UnitTypeCode) (not $.Repository.IsArchived) (not .IsDeleted)}}
|
||||
<div class="ui right">
|
||||
<button id="commit-notes-edit-button" class="ui tiny button yellow" data-modal="#delete-note-modal">{{ctx.Locale.Tr "edit"}}</button>
|
||||
<button id="commit-notes-edit-button" class="ui tiny primary button" data-modal="#delete-note-modal">{{ctx.Locale.Tr "edit"}}</button>
|
||||
<button class="ui tiny button red show-modal" data-modal="#delete-note-modal">{{ctx.Locale.Tr "remove"}}</button>
|
||||
</div>
|
||||
<div class="ui small modal" id="delete-note-modal">
|
||||
<div class="header">
|
||||
{{ctx.Locale.Tr "repo.diff.git-notes.remove-header"}}
|
||||
</div>
|
||||
<p>{{ctx.Locale.Tr "repo.diff.git-notes.remove-body"}}</p>
|
||||
<div class="content">
|
||||
<p>{{ctx.Locale.Tr "repo.diff.git-notes.remove-body"}}</p>
|
||||
<div class="text right actions">
|
||||
<form action="{{.Link}}/notes/remove" method="post">
|
||||
{{.CsrfTokenHtml}}
|
||||
<button type="button" class="ui cancel button">{{ctx.Locale.Tr "settings.cancel"}}</button>
|
||||
<button type="submit" class="ui primary button red" href="{{.Link}}/notes/remove">{{ctx.Locale.Tr "remove"}}</button>
|
||||
<button type="submit" class="ui red button" href="{{.Link}}/notes/remove">{{ctx.Locale.Tr "remove"}}</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -316,7 +319,6 @@
|
|||
</div>
|
||||
{{end}}
|
||||
{{else if and ($.Permission.CanWrite $.UnitTypeCode) (not $.Repository.IsArchived) (not .IsDeleted)}}
|
||||
<button id="commit-notes-add-button" class="ui primary button green tw-mt-3">{{ctx.Locale.Tr "repo.diff.git-notes.add"}}</button>
|
||||
<div id="commit-notes-add-area" class="ui tw-mt-3 segment tw-hidden">
|
||||
<form class="ui form" action="{{.Link}}/notes" method="post">
|
||||
{{.CsrfTokenHtml}}
|
||||
|
|
|
@ -51,10 +51,12 @@
|
|||
</div>
|
||||
<input id="pronouns-custom" name="pronouns" value="{{.SignedUser.Pronouns}}" maxlength="50">
|
||||
</div>
|
||||
<div class="field {{if .Err_Email}}error{{end}}">
|
||||
{{if not .SignedUser.KeepEmailPrivate}}
|
||||
<div class="field">
|
||||
<label>{{ctx.Locale.Tr "email"}}</label>
|
||||
<p id="signed-user-email">{{.SignedUser.Email}}</p>
|
||||
</div>
|
||||
{{end}}
|
||||
<div class="field {{if .Err_Biography}}error{{end}}">
|
||||
<label for="biography">{{ctx.Locale.Tr "user.user_bio"}}</label>
|
||||
<textarea id="biography" name="biography" rows="2" placeholder="{{ctx.Locale.Tr "settings.biography_placeholder"}}" maxlength="255">{{.SignedUser.Description}}</textarea>
|
||||
|
|
|
@ -14,38 +14,41 @@ import (
|
|||
|
||||
auth_model "code.gitea.io/gitea/models/auth"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
"code.gitea.io/gitea/tests"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
// TestDiscussionEvents is a test for various events displayed in the timelines of pulls and issues
|
||||
func TestDiscussionEvents(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
|
||||
repoName := "discussion-timeline-tests"
|
||||
user2 := "user2"
|
||||
user1 := "user1"
|
||||
description := "This PR will be used for testing events in discussions"
|
||||
// Expected branch name when initializing repo automatically
|
||||
defaultBranch := "master"
|
||||
htmlCleaner := regexp.MustCompile(`[\t\n]`)
|
||||
|
||||
onGiteaRun(t, func(t *testing.T, giteaURL *url.URL) {
|
||||
sessionUser2 := loginUser(t, user2)
|
||||
tokenUser2 := getTokenForLoggedInUser(t, sessionUser2, auth_model.AccessTokenScopeAll)
|
||||
sessionUser1 := loginUser(t, user1)
|
||||
tokenUser1 := getTokenForLoggedInUser(t, sessionUser1, auth_model.AccessTokenScopeAll)
|
||||
|
||||
// Create test repo
|
||||
var repo api.Repository
|
||||
resp := sessionUser2.MakeRequest(t, NewRequestWithJSON(t, "POST", "/api/v1/user/repos", &api.CreateRepoOption{
|
||||
resp := sessionUser1.MakeRequest(t, NewRequestWithJSON(t, "POST", "/api/v1/user/repos", &api.CreateRepoOption{
|
||||
Name: repoName,
|
||||
AutoInit: true,
|
||||
}).AddTokenAuth(tokenUser2), http.StatusCreated)
|
||||
}).AddTokenAuth(tokenUser1), http.StatusCreated)
|
||||
DecodeJSON(t, resp, &repo)
|
||||
|
||||
// == Test pulls ==
|
||||
|
||||
// Open a new PR as user2
|
||||
testEditFileToNewBranch(t, sessionUser2, user2, repo.Name, defaultBranch, "comment-labels", "README.md", description)
|
||||
sessionUser2.MakeRequest(t, NewRequestWithValues(t, "POST", path.Join(repo.FullName, "compare", fmt.Sprintf("%s...comment-labels", defaultBranch)),
|
||||
// Open a new PR as user1
|
||||
testEditFileToNewBranch(t, sessionUser1, user1, repo.Name, defaultBranch, "comment-labels", "README.md", description)
|
||||
sessionUser1.MakeRequest(t, NewRequestWithValues(t, "POST", path.Join(repo.FullName, "compare", fmt.Sprintf("%s...comment-labels", defaultBranch)),
|
||||
map[string]string{
|
||||
"_csrf": GetCSRF(t, sessionUser2, path.Join(repo.FullName, "compare", fmt.Sprintf("%s...comment-labels", defaultBranch))),
|
||||
"_csrf": GetCSRF(t, sessionUser1, path.Join(repo.FullName, "compare", fmt.Sprintf("%s...comment-labels", defaultBranch))),
|
||||
"title": description,
|
||||
},
|
||||
), http.StatusOK)
|
||||
|
@ -54,7 +57,7 @@ func TestDiscussionEvents(t *testing.T) {
|
|||
testPullID := "1"
|
||||
|
||||
// Get the PR page and find all events
|
||||
response := sessionUser2.MakeRequest(t, NewRequest(t, "GET", path.Join(repo.FullName, "pulls", testPullID)), http.StatusOK)
|
||||
response := sessionUser1.MakeRequest(t, NewRequest(t, "GET", path.Join(repo.FullName, "pulls", testPullID)), http.StatusOK)
|
||||
page := NewHTMLParser(t, response.Body)
|
||||
events := page.Find(".timeline .timeline-item.event .text")
|
||||
|
||||
|
@ -62,8 +65,8 @@ func TestDiscussionEvents(t *testing.T) {
|
|||
event := events.Eq(0)
|
||||
eventHTML, _ := event.Html()
|
||||
eventText := htmlCleaner.ReplaceAllString(strings.TrimSpace(event.Text()), "")
|
||||
assert.Contains(t, eventHTML, `href="/user2">user2</a>`)
|
||||
assert.Contains(t, eventHTML, `href="/user1">user1</a>`)
|
||||
assert.Contains(t, eventHTML, `<relative-time`)
|
||||
assert.Contains(t, eventText, `user2 added 1 commit`)
|
||||
assert.Contains(t, eventText, `user1 added 1 commit`)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Copyright 2017 The Gitea Authors. All rights reserved.
|
||||
// Copyright 2024 The Forgejo Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package integration
|
||||
|
@ -156,3 +157,23 @@ func TestSettingSecurityAuthSource(t *testing.T) {
|
|||
assert.Contains(t, resp.Body.String(), `gitlab-active`)
|
||||
assert.Contains(t, resp.Body.String(), `gitlab-inactive`)
|
||||
}
|
||||
|
||||
func TestSettingShowUserEmailSettings(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
|
||||
// user1: keep_email_private = false, user2: keep_email_private = true
|
||||
|
||||
// user1 can see own visible email
|
||||
session := loginUser(t, "user1")
|
||||
req := NewRequest(t, "GET", "/user/settings")
|
||||
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
assert.Contains(t, htmlDoc.doc.Find("#signed-user-email").Text(), "user1@example.com")
|
||||
|
||||
// user2 cannot see own hidden email
|
||||
session = loginUser(t, "user2")
|
||||
req = NewRequest(t, "GET", "/user/settings")
|
||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
||||
htmlDoc = NewHTMLParser(t, resp.Body)
|
||||
assert.NotContains(t, htmlDoc.doc.Find("#signed-user-email").Text(), "user2@example.com")
|
||||
}
|
||||
|
|
|
@ -38,7 +38,6 @@ export function initCommitNotes() {
|
|||
const notesAddButton = document.getElementById('commit-notes-add-button');
|
||||
if (notesAddButton !== null) {
|
||||
notesAddButton.addEventListener('click', () => {
|
||||
notesAddButton.classList.add('tw-hidden');
|
||||
document.getElementById('commit-notes-add-area').classList.remove('tw-hidden');
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue