mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2026-05-12 22:10:25 +00:00
fix(i18n): unhardcode label exclusion tooltips (#11333)
Followup to #10702 where two new strings were hardcoded in the template. ## Changes - added as translatable strings - made the template use a variable to avoid making it a long unreadable - an unrelated change where tests related to this area of the template are moved to a separate file - they were created in Forgejo:c92b4b12c8,192177fc88## Testing Testing translations of all individual strings is considered not needed. Added test for tmpl logic which was missing and that I've touched. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/11333 Reviewed-by: Luis Adame <luisadame@noreply.codeberg.org> Reviewed-by: Gusted <gusted@noreply.codeberg.org>
This commit is contained in:
parent
a81fc2a290
commit
f8bee35e77
4 changed files with 368 additions and 330 deletions
|
|
@ -59,6 +59,8 @@
|
|||
"repo.issues.filter_modified.hint": "Filter by last modified date",
|
||||
"repo.issues.filter_sort.hint": "Sort by: created/comments/updated/deadline",
|
||||
"issues.updated": "updated %s",
|
||||
"issues.filters.labels.exclude": "Exclude label",
|
||||
"issues.filters.labels.unexclude": "Clear exclusion",
|
||||
"repo.pulls.poster_manage_approval": "Manage approval",
|
||||
"repo.pulls.poster_requires_approval": "Some workflows are <a href=\"%[1]s\">waiting to be reviewed.</a>",
|
||||
"repo.pulls.poster_requires_approval.tooltip": "The author of this pull request is not trusted to run workflows triggered by a pull request created from a forked repository or with AGit. The workflows triggered by a `pull_request` event will not run until they are approved.",
|
||||
|
|
|
|||
|
|
@ -43,7 +43,12 @@
|
|||
{{RenderLabel ctx .}}
|
||||
</a>
|
||||
{{template "repo/issue/labels/label_archived" .}}
|
||||
<button type="button" data-tooltip-content="{{if .IsExcluded}}Clear exclusion{{else}}Exclude label{{end}}" class="label-exclude-item-btn {{if .IsExcluded}}active{{end}}">
|
||||
|
||||
{{$exclusionTooltip := ctx.Locale.TrString "issues.filters.labels.exclude"}}
|
||||
{{if .IsExcluded}}
|
||||
{{$exclusionTooltip = ctx.Locale.TrString "issues.filters.labels.unexclude"}}
|
||||
{{end}}
|
||||
<button type="button" data-tooltip-content="{{$exclusionTooltip}}" class="label-exclude-item-btn {{if .IsExcluded}}active{{end}}">
|
||||
{{svg "octicon-no-entry"}}
|
||||
</button>
|
||||
</div>
|
||||
|
|
|
|||
360
tests/integration/issue_list_filters_test.go
Normal file
360
tests/integration/issue_list_filters_test.go
Normal file
|
|
@ -0,0 +1,360 @@
|
|||
// Copyright 2024 The Forgejo Authors
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"forgejo.org/modules/translation"
|
||||
"forgejo.org/tests"
|
||||
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
// Tests for contents of pages .../issues and .../pulls
|
||||
|
||||
func TestIssueFilterLabels(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
|
||||
t.Run("Exclusion tooltips", func(t *testing.T) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
|
||||
url := "/user2/repo1/issues?labels=-2"
|
||||
page := NewHTMLParser(t, MakeRequest(t, NewRequest(t, "GET", url), http.StatusOK).Body)
|
||||
|
||||
page.AssertElement(t, ".label-filter .menu .item:has(a[data-label-id='1']) button[data-tooltip-content='Exclude label']", true)
|
||||
page.AssertElement(t, ".label-filter .menu .item:has(a[data-label-id='2']) button[data-tooltip-content='Clear exclusion']", true)
|
||||
})
|
||||
}
|
||||
|
||||
func TestIssueSorting(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
|
||||
t.Run("Dropdown content", func(t *testing.T) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
|
||||
req := NewRequest(t, "GET", "/user2/repo1/issues")
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
|
||||
assert.Equal(t,
|
||||
9,
|
||||
htmlDoc.Find(`.list-header-sort .menu a`).Length(),
|
||||
"Wrong amount of sort options in dropdown")
|
||||
|
||||
menuItemsHTML := htmlDoc.Find(`.list-header-sort .menu`).Text()
|
||||
locale := translation.NewLocale("en-US")
|
||||
for _, key := range []string{
|
||||
"relevance",
|
||||
"latest",
|
||||
"oldest",
|
||||
"recentupdate",
|
||||
"leastupdate",
|
||||
"mostcomment",
|
||||
"leastcomment",
|
||||
"nearduedate",
|
||||
"farduedate",
|
||||
} {
|
||||
assert.Contains(t,
|
||||
menuItemsHTML,
|
||||
locale.Tr("repo.issues.filter_sort."+key),
|
||||
"Sort option %s ('%s') not found in dropdown", key, locale.Tr("repo.issues.filter_sort."+key))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestIssueFilterLinks(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
|
||||
t.Run("No filters", func(t *testing.T) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
|
||||
req := NewRequest(t, "GET", "/user2/repo1/issues")
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
|
||||
called := false
|
||||
htmlDoc.Find("#issue-filters a[href^='?']").Each(func(_ int, s *goquery.Selection) {
|
||||
called = true
|
||||
href, _ := s.Attr("href")
|
||||
assert.Contains(t, href, "?q=&")
|
||||
assert.Contains(t, href, "&type=")
|
||||
assert.Contains(t, href, "&sort=")
|
||||
assert.Contains(t, href, "&state=")
|
||||
assert.Contains(t, href, "&labels=")
|
||||
assert.Contains(t, href, "&milestone=")
|
||||
assert.Contains(t, href, "&project=")
|
||||
assert.Contains(t, href, "&assignee=")
|
||||
assert.Contains(t, href, "&poster=")
|
||||
})
|
||||
assert.True(t, called)
|
||||
})
|
||||
|
||||
t.Run("Keyword", func(t *testing.T) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
|
||||
req := NewRequest(t, "GET", "/user2/repo1/issues?q=search-on-this")
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
|
||||
called := false
|
||||
htmlDoc.Find("#issue-filters a[href^='?']").Each(func(_ int, s *goquery.Selection) {
|
||||
called = true
|
||||
href, _ := s.Attr("href")
|
||||
assert.Contains(t, href, "?q=search-on-this")
|
||||
assert.Contains(t, href, "&type=")
|
||||
assert.Contains(t, href, "&sort=")
|
||||
assert.Contains(t, href, "&state=")
|
||||
assert.Contains(t, href, "&labels=")
|
||||
assert.Contains(t, href, "&milestone=")
|
||||
assert.Contains(t, href, "&project=")
|
||||
assert.Contains(t, href, "&assignee=")
|
||||
assert.Contains(t, href, "&poster=")
|
||||
})
|
||||
assert.True(t, called)
|
||||
})
|
||||
|
||||
t.Run("Sort", func(t *testing.T) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
|
||||
req := NewRequest(t, "GET", "/user2/repo1/issues?sort=oldest")
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
|
||||
called := false
|
||||
htmlDoc.Find("#issue-filters a[href^='?']:not(.list-header-sort a)").Each(func(_ int, s *goquery.Selection) {
|
||||
called = true
|
||||
href, _ := s.Attr("href")
|
||||
assert.Contains(t, href, "?q=&")
|
||||
assert.Contains(t, href, "&type=")
|
||||
assert.Contains(t, href, "&sort=oldest")
|
||||
assert.Contains(t, href, "&state=")
|
||||
assert.Contains(t, href, "&labels=")
|
||||
assert.Contains(t, href, "&milestone=")
|
||||
assert.Contains(t, href, "&project=")
|
||||
assert.Contains(t, href, "&assignee=")
|
||||
assert.Contains(t, href, "&poster=")
|
||||
})
|
||||
assert.True(t, called)
|
||||
})
|
||||
|
||||
t.Run("Type", func(t *testing.T) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
|
||||
req := NewRequest(t, "GET", "/user2/repo1/issues?type=assigned")
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
|
||||
called := false
|
||||
htmlDoc.Find("#issue-filters a[href^='?']:not(.list-header-type a)").Each(func(_ int, s *goquery.Selection) {
|
||||
called = true
|
||||
href, _ := s.Attr("href")
|
||||
assert.Contains(t, href, "?q=&")
|
||||
assert.Contains(t, href, "&type=assigned")
|
||||
assert.Contains(t, href, "&sort=")
|
||||
assert.Contains(t, href, "&state=")
|
||||
assert.Contains(t, href, "&labels=")
|
||||
assert.Contains(t, href, "&milestone=")
|
||||
assert.Contains(t, href, "&project=")
|
||||
assert.Contains(t, href, "&assignee=")
|
||||
assert.Contains(t, href, "&poster=")
|
||||
})
|
||||
assert.True(t, called)
|
||||
})
|
||||
|
||||
t.Run("State", func(t *testing.T) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
|
||||
req := NewRequest(t, "GET", "/user2/repo1/issues?state=closed")
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
|
||||
called := false
|
||||
htmlDoc.Find("#issue-filters a[href^='?']:not(.issue-list-toolbar-left a)").Each(func(_ int, s *goquery.Selection) {
|
||||
called = true
|
||||
href, _ := s.Attr("href")
|
||||
assert.Contains(t, href, "?q=&")
|
||||
assert.Contains(t, href, "&type=")
|
||||
assert.Contains(t, href, "&sort=")
|
||||
assert.Contains(t, href, "&state=closed")
|
||||
assert.Contains(t, href, "&labels=")
|
||||
assert.Contains(t, href, "&milestone=")
|
||||
assert.Contains(t, href, "&project=")
|
||||
assert.Contains(t, href, "&assignee=")
|
||||
assert.Contains(t, href, "&poster=")
|
||||
})
|
||||
assert.True(t, called)
|
||||
})
|
||||
|
||||
t.Run("Milestone", func(t *testing.T) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
|
||||
req := NewRequest(t, "GET", "/user2/repo1/issues?milestone=1")
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
|
||||
called := false
|
||||
htmlDoc.Find("#issue-filters a[href^='?']:not(.list-header-milestone a)").Each(func(_ int, s *goquery.Selection) {
|
||||
called = true
|
||||
href, _ := s.Attr("href")
|
||||
assert.Contains(t, href, "?q=&")
|
||||
assert.Contains(t, href, "&type=")
|
||||
assert.Contains(t, href, "&sort=")
|
||||
assert.Contains(t, href, "&state=")
|
||||
assert.Contains(t, href, "&labels=")
|
||||
assert.Contains(t, href, "&milestone=1")
|
||||
assert.Contains(t, href, "&project=")
|
||||
assert.Contains(t, href, "&assignee=")
|
||||
assert.Contains(t, href, "&poster=")
|
||||
})
|
||||
assert.True(t, called)
|
||||
})
|
||||
|
||||
t.Run("Milestone", func(t *testing.T) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
|
||||
req := NewRequest(t, "GET", "/user2/repo1/issues?milestone=1")
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
|
||||
called := false
|
||||
htmlDoc.Find("#issue-filters a[href^='?']:not(.list-header-milestone a)").Each(func(_ int, s *goquery.Selection) {
|
||||
called = true
|
||||
href, _ := s.Attr("href")
|
||||
assert.Contains(t, href, "?q=&")
|
||||
assert.Contains(t, href, "&type=")
|
||||
assert.Contains(t, href, "&sort=")
|
||||
assert.Contains(t, href, "&state=")
|
||||
assert.Contains(t, href, "&labels=")
|
||||
assert.Contains(t, href, "&milestone=1")
|
||||
assert.Contains(t, href, "&project=")
|
||||
assert.Contains(t, href, "&assignee=")
|
||||
assert.Contains(t, href, "&poster=")
|
||||
})
|
||||
assert.True(t, called)
|
||||
})
|
||||
|
||||
t.Run("Project", func(t *testing.T) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
|
||||
req := NewRequest(t, "GET", "/user2/repo1/issues?project=1")
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
|
||||
called := false
|
||||
htmlDoc.Find("#issue-filters a[href^='?']:not(.list-header-project a)").Each(func(_ int, s *goquery.Selection) {
|
||||
called = true
|
||||
href, _ := s.Attr("href")
|
||||
assert.Contains(t, href, "?q=&")
|
||||
assert.Contains(t, href, "&type=")
|
||||
assert.Contains(t, href, "&sort=")
|
||||
assert.Contains(t, href, "&state=")
|
||||
assert.Contains(t, href, "&labels=")
|
||||
assert.Contains(t, href, "&milestone=")
|
||||
assert.Contains(t, href, "&project=1")
|
||||
assert.Contains(t, href, "&assignee=")
|
||||
assert.Contains(t, href, "&poster=")
|
||||
})
|
||||
assert.True(t, called)
|
||||
})
|
||||
|
||||
t.Run("Assignee", func(t *testing.T) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
|
||||
req := NewRequest(t, "GET", "/user2/repo1/issues?assignee=1")
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
|
||||
called := false
|
||||
htmlDoc.Find("#issue-filters a[href^='?']:not(.list-header-assignee a)").Each(func(_ int, s *goquery.Selection) {
|
||||
called = true
|
||||
href, _ := s.Attr("href")
|
||||
assert.Contains(t, href, "?q=&")
|
||||
assert.Contains(t, href, "&type=")
|
||||
assert.Contains(t, href, "&sort=")
|
||||
assert.Contains(t, href, "&state=")
|
||||
assert.Contains(t, href, "&labels=")
|
||||
assert.Contains(t, href, "&milestone=")
|
||||
assert.Contains(t, href, "&project=")
|
||||
assert.Contains(t, href, "&assignee=1")
|
||||
assert.Contains(t, href, "&poster=")
|
||||
})
|
||||
assert.True(t, called)
|
||||
})
|
||||
|
||||
t.Run("Poster", func(t *testing.T) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
|
||||
req := NewRequest(t, "GET", "/user2/repo1/issues?poster=1")
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
|
||||
called := false
|
||||
htmlDoc.Find("#issue-filters a[href^='?']:not(.list-header-poster a)").Each(func(_ int, s *goquery.Selection) {
|
||||
called = true
|
||||
href, _ := s.Attr("href")
|
||||
assert.Contains(t, href, "?q=&")
|
||||
assert.Contains(t, href, "&type=")
|
||||
assert.Contains(t, href, "&sort=")
|
||||
assert.Contains(t, href, "&state=")
|
||||
assert.Contains(t, href, "&labels=")
|
||||
assert.Contains(t, href, "&milestone=")
|
||||
assert.Contains(t, href, "&project=")
|
||||
assert.Contains(t, href, "&assignee=")
|
||||
assert.Contains(t, href, "&poster=1")
|
||||
})
|
||||
assert.True(t, called)
|
||||
})
|
||||
|
||||
t.Run("Labels", func(t *testing.T) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
|
||||
req := NewRequest(t, "GET", "/user2/repo1/issues?labels=1")
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
|
||||
called := false
|
||||
htmlDoc.Find("#issue-filters a[href^='?']:not(.label-filter a)").Each(func(_ int, s *goquery.Selection) {
|
||||
called = true
|
||||
href, _ := s.Attr("href")
|
||||
assert.Contains(t, href, "?q=&")
|
||||
assert.Contains(t, href, "&type=")
|
||||
assert.Contains(t, href, "&sort=")
|
||||
assert.Contains(t, href, "&state=")
|
||||
assert.Contains(t, href, "&labels=1")
|
||||
assert.Contains(t, href, "&milestone=")
|
||||
assert.Contains(t, href, "&project=")
|
||||
assert.Contains(t, href, "&assignee=")
|
||||
assert.Contains(t, href, "&poster=")
|
||||
})
|
||||
assert.True(t, called)
|
||||
})
|
||||
|
||||
t.Run("Archived labels", func(t *testing.T) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
|
||||
req := NewRequest(t, "GET", "/user2/repo1/issues?archived=true")
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
|
||||
called := false
|
||||
htmlDoc.Find("#issue-filters a[href^='?']").Each(func(_ int, s *goquery.Selection) {
|
||||
called = true
|
||||
href, _ := s.Attr("href")
|
||||
assert.Contains(t, href, "?q=&")
|
||||
assert.Contains(t, href, "&type=")
|
||||
assert.Contains(t, href, "&sort=")
|
||||
assert.Contains(t, href, "&state=")
|
||||
assert.Contains(t, href, "&labels=")
|
||||
assert.Contains(t, href, "&milestone=")
|
||||
assert.Contains(t, href, "&project=")
|
||||
assert.Contains(t, href, "&assignee=")
|
||||
assert.Contains(t, href, "&poster=")
|
||||
assert.Contains(t, href, "&archived=true")
|
||||
})
|
||||
assert.True(t, called)
|
||||
})
|
||||
}
|
||||
|
|
@ -1219,335 +1219,6 @@ func TestFileHistoryPager(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestRepoIssueSorting(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
|
||||
t.Run("Dropdown content", func(t *testing.T) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
|
||||
req := NewRequest(t, "GET", "/user2/repo1/issues")
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
|
||||
assert.Equal(t,
|
||||
9,
|
||||
htmlDoc.Find(`.list-header-sort .menu a`).Length(),
|
||||
"Wrong amount of sort options in dropdown")
|
||||
|
||||
menuItemsHTML := htmlDoc.Find(`.list-header-sort .menu`).Text()
|
||||
locale := translation.NewLocale("en-US")
|
||||
for _, key := range []string{
|
||||
"relevance",
|
||||
"latest",
|
||||
"oldest",
|
||||
"recentupdate",
|
||||
"leastupdate",
|
||||
"mostcomment",
|
||||
"leastcomment",
|
||||
"nearduedate",
|
||||
"farduedate",
|
||||
} {
|
||||
assert.Contains(t,
|
||||
menuItemsHTML,
|
||||
locale.Tr("repo.issues.filter_sort."+key),
|
||||
"Sort option %s ('%s') not found in dropdown", key, locale.Tr("repo.issues.filter_sort."+key))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestRepoIssueFilterLinks(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
|
||||
t.Run("No filters", func(t *testing.T) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
|
||||
req := NewRequest(t, "GET", "/user2/repo1/issues")
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
|
||||
called := false
|
||||
htmlDoc.Find("#issue-filters a[href^='?']").Each(func(_ int, s *goquery.Selection) {
|
||||
called = true
|
||||
href, _ := s.Attr("href")
|
||||
assert.Contains(t, href, "?q=&")
|
||||
assert.Contains(t, href, "&type=")
|
||||
assert.Contains(t, href, "&sort=")
|
||||
assert.Contains(t, href, "&state=")
|
||||
assert.Contains(t, href, "&labels=")
|
||||
assert.Contains(t, href, "&milestone=")
|
||||
assert.Contains(t, href, "&project=")
|
||||
assert.Contains(t, href, "&assignee=")
|
||||
assert.Contains(t, href, "&poster=")
|
||||
})
|
||||
assert.True(t, called)
|
||||
})
|
||||
|
||||
t.Run("Keyword", func(t *testing.T) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
|
||||
req := NewRequest(t, "GET", "/user2/repo1/issues?q=search-on-this")
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
|
||||
called := false
|
||||
htmlDoc.Find("#issue-filters a[href^='?']").Each(func(_ int, s *goquery.Selection) {
|
||||
called = true
|
||||
href, _ := s.Attr("href")
|
||||
assert.Contains(t, href, "?q=search-on-this")
|
||||
assert.Contains(t, href, "&type=")
|
||||
assert.Contains(t, href, "&sort=")
|
||||
assert.Contains(t, href, "&state=")
|
||||
assert.Contains(t, href, "&labels=")
|
||||
assert.Contains(t, href, "&milestone=")
|
||||
assert.Contains(t, href, "&project=")
|
||||
assert.Contains(t, href, "&assignee=")
|
||||
assert.Contains(t, href, "&poster=")
|
||||
})
|
||||
assert.True(t, called)
|
||||
})
|
||||
|
||||
t.Run("Sort", func(t *testing.T) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
|
||||
req := NewRequest(t, "GET", "/user2/repo1/issues?sort=oldest")
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
|
||||
called := false
|
||||
htmlDoc.Find("#issue-filters a[href^='?']:not(.list-header-sort a)").Each(func(_ int, s *goquery.Selection) {
|
||||
called = true
|
||||
href, _ := s.Attr("href")
|
||||
assert.Contains(t, href, "?q=&")
|
||||
assert.Contains(t, href, "&type=")
|
||||
assert.Contains(t, href, "&sort=oldest")
|
||||
assert.Contains(t, href, "&state=")
|
||||
assert.Contains(t, href, "&labels=")
|
||||
assert.Contains(t, href, "&milestone=")
|
||||
assert.Contains(t, href, "&project=")
|
||||
assert.Contains(t, href, "&assignee=")
|
||||
assert.Contains(t, href, "&poster=")
|
||||
})
|
||||
assert.True(t, called)
|
||||
})
|
||||
|
||||
t.Run("Type", func(t *testing.T) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
|
||||
req := NewRequest(t, "GET", "/user2/repo1/issues?type=assigned")
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
|
||||
called := false
|
||||
htmlDoc.Find("#issue-filters a[href^='?']:not(.list-header-type a)").Each(func(_ int, s *goquery.Selection) {
|
||||
called = true
|
||||
href, _ := s.Attr("href")
|
||||
assert.Contains(t, href, "?q=&")
|
||||
assert.Contains(t, href, "&type=assigned")
|
||||
assert.Contains(t, href, "&sort=")
|
||||
assert.Contains(t, href, "&state=")
|
||||
assert.Contains(t, href, "&labels=")
|
||||
assert.Contains(t, href, "&milestone=")
|
||||
assert.Contains(t, href, "&project=")
|
||||
assert.Contains(t, href, "&assignee=")
|
||||
assert.Contains(t, href, "&poster=")
|
||||
})
|
||||
assert.True(t, called)
|
||||
})
|
||||
|
||||
t.Run("State", func(t *testing.T) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
|
||||
req := NewRequest(t, "GET", "/user2/repo1/issues?state=closed")
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
|
||||
called := false
|
||||
htmlDoc.Find("#issue-filters a[href^='?']:not(.issue-list-toolbar-left a)").Each(func(_ int, s *goquery.Selection) {
|
||||
called = true
|
||||
href, _ := s.Attr("href")
|
||||
assert.Contains(t, href, "?q=&")
|
||||
assert.Contains(t, href, "&type=")
|
||||
assert.Contains(t, href, "&sort=")
|
||||
assert.Contains(t, href, "&state=closed")
|
||||
assert.Contains(t, href, "&labels=")
|
||||
assert.Contains(t, href, "&milestone=")
|
||||
assert.Contains(t, href, "&project=")
|
||||
assert.Contains(t, href, "&assignee=")
|
||||
assert.Contains(t, href, "&poster=")
|
||||
})
|
||||
assert.True(t, called)
|
||||
})
|
||||
|
||||
t.Run("Milestone", func(t *testing.T) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
|
||||
req := NewRequest(t, "GET", "/user2/repo1/issues?milestone=1")
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
|
||||
called := false
|
||||
htmlDoc.Find("#issue-filters a[href^='?']:not(.list-header-milestone a)").Each(func(_ int, s *goquery.Selection) {
|
||||
called = true
|
||||
href, _ := s.Attr("href")
|
||||
assert.Contains(t, href, "?q=&")
|
||||
assert.Contains(t, href, "&type=")
|
||||
assert.Contains(t, href, "&sort=")
|
||||
assert.Contains(t, href, "&state=")
|
||||
assert.Contains(t, href, "&labels=")
|
||||
assert.Contains(t, href, "&milestone=1")
|
||||
assert.Contains(t, href, "&project=")
|
||||
assert.Contains(t, href, "&assignee=")
|
||||
assert.Contains(t, href, "&poster=")
|
||||
})
|
||||
assert.True(t, called)
|
||||
})
|
||||
|
||||
t.Run("Milestone", func(t *testing.T) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
|
||||
req := NewRequest(t, "GET", "/user2/repo1/issues?milestone=1")
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
|
||||
called := false
|
||||
htmlDoc.Find("#issue-filters a[href^='?']:not(.list-header-milestone a)").Each(func(_ int, s *goquery.Selection) {
|
||||
called = true
|
||||
href, _ := s.Attr("href")
|
||||
assert.Contains(t, href, "?q=&")
|
||||
assert.Contains(t, href, "&type=")
|
||||
assert.Contains(t, href, "&sort=")
|
||||
assert.Contains(t, href, "&state=")
|
||||
assert.Contains(t, href, "&labels=")
|
||||
assert.Contains(t, href, "&milestone=1")
|
||||
assert.Contains(t, href, "&project=")
|
||||
assert.Contains(t, href, "&assignee=")
|
||||
assert.Contains(t, href, "&poster=")
|
||||
})
|
||||
assert.True(t, called)
|
||||
})
|
||||
|
||||
t.Run("Project", func(t *testing.T) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
|
||||
req := NewRequest(t, "GET", "/user2/repo1/issues?project=1")
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
|
||||
called := false
|
||||
htmlDoc.Find("#issue-filters a[href^='?']:not(.list-header-project a)").Each(func(_ int, s *goquery.Selection) {
|
||||
called = true
|
||||
href, _ := s.Attr("href")
|
||||
assert.Contains(t, href, "?q=&")
|
||||
assert.Contains(t, href, "&type=")
|
||||
assert.Contains(t, href, "&sort=")
|
||||
assert.Contains(t, href, "&state=")
|
||||
assert.Contains(t, href, "&labels=")
|
||||
assert.Contains(t, href, "&milestone=")
|
||||
assert.Contains(t, href, "&project=1")
|
||||
assert.Contains(t, href, "&assignee=")
|
||||
assert.Contains(t, href, "&poster=")
|
||||
})
|
||||
assert.True(t, called)
|
||||
})
|
||||
|
||||
t.Run("Assignee", func(t *testing.T) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
|
||||
req := NewRequest(t, "GET", "/user2/repo1/issues?assignee=1")
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
|
||||
called := false
|
||||
htmlDoc.Find("#issue-filters a[href^='?']:not(.list-header-assignee a)").Each(func(_ int, s *goquery.Selection) {
|
||||
called = true
|
||||
href, _ := s.Attr("href")
|
||||
assert.Contains(t, href, "?q=&")
|
||||
assert.Contains(t, href, "&type=")
|
||||
assert.Contains(t, href, "&sort=")
|
||||
assert.Contains(t, href, "&state=")
|
||||
assert.Contains(t, href, "&labels=")
|
||||
assert.Contains(t, href, "&milestone=")
|
||||
assert.Contains(t, href, "&project=")
|
||||
assert.Contains(t, href, "&assignee=1")
|
||||
assert.Contains(t, href, "&poster=")
|
||||
})
|
||||
assert.True(t, called)
|
||||
})
|
||||
|
||||
t.Run("Poster", func(t *testing.T) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
|
||||
req := NewRequest(t, "GET", "/user2/repo1/issues?poster=1")
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
|
||||
called := false
|
||||
htmlDoc.Find("#issue-filters a[href^='?']:not(.list-header-poster a)").Each(func(_ int, s *goquery.Selection) {
|
||||
called = true
|
||||
href, _ := s.Attr("href")
|
||||
assert.Contains(t, href, "?q=&")
|
||||
assert.Contains(t, href, "&type=")
|
||||
assert.Contains(t, href, "&sort=")
|
||||
assert.Contains(t, href, "&state=")
|
||||
assert.Contains(t, href, "&labels=")
|
||||
assert.Contains(t, href, "&milestone=")
|
||||
assert.Contains(t, href, "&project=")
|
||||
assert.Contains(t, href, "&assignee=")
|
||||
assert.Contains(t, href, "&poster=1")
|
||||
})
|
||||
assert.True(t, called)
|
||||
})
|
||||
|
||||
t.Run("Labels", func(t *testing.T) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
|
||||
req := NewRequest(t, "GET", "/user2/repo1/issues?labels=1")
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
|
||||
called := false
|
||||
htmlDoc.Find("#issue-filters a[href^='?']:not(.label-filter a)").Each(func(_ int, s *goquery.Selection) {
|
||||
called = true
|
||||
href, _ := s.Attr("href")
|
||||
assert.Contains(t, href, "?q=&")
|
||||
assert.Contains(t, href, "&type=")
|
||||
assert.Contains(t, href, "&sort=")
|
||||
assert.Contains(t, href, "&state=")
|
||||
assert.Contains(t, href, "&labels=1")
|
||||
assert.Contains(t, href, "&milestone=")
|
||||
assert.Contains(t, href, "&project=")
|
||||
assert.Contains(t, href, "&assignee=")
|
||||
assert.Contains(t, href, "&poster=")
|
||||
})
|
||||
assert.True(t, called)
|
||||
})
|
||||
|
||||
t.Run("Archived labels", func(t *testing.T) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
|
||||
req := NewRequest(t, "GET", "/user2/repo1/issues?archived=true")
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
|
||||
called := false
|
||||
htmlDoc.Find("#issue-filters a[href^='?']").Each(func(_ int, s *goquery.Selection) {
|
||||
called = true
|
||||
href, _ := s.Attr("href")
|
||||
assert.Contains(t, href, "?q=&")
|
||||
assert.Contains(t, href, "&type=")
|
||||
assert.Contains(t, href, "&sort=")
|
||||
assert.Contains(t, href, "&state=")
|
||||
assert.Contains(t, href, "&labels=")
|
||||
assert.Contains(t, href, "&milestone=")
|
||||
assert.Contains(t, href, "&project=")
|
||||
assert.Contains(t, href, "&assignee=")
|
||||
assert.Contains(t, href, "&poster=")
|
||||
assert.Contains(t, href, "&archived=true")
|
||||
})
|
||||
assert.True(t, called)
|
||||
})
|
||||
}
|
||||
|
||||
func TestRepoSubmoduleView(t *testing.T) {
|
||||
onApplicationRun(t, func(t *testing.T, u *url.URL) {
|
||||
user2 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue