mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-08 18:04:14 +01:00
Add integration test for (non-)archived label properties
This commit is contained in:
parent
1060b7cfa8
commit
53dc9f3393
1 changed files with 71 additions and 0 deletions
71
tests/integration/archived_labels_display_test.go
Normal file
71
tests/integration/archived_labels_display_test.go
Normal file
|
@ -0,0 +1,71 @@
|
|||
// Copyright 2024 The Forgejo Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestArchivedLabelVisualProperties(t *testing.T) {
|
||||
onGiteaRun(t, func(t *testing.T, u *url.URL) {
|
||||
session := loginUser(t, "user2")
|
||||
|
||||
// Create labels
|
||||
session.MakeRequest(t, NewRequestWithValues(t, "POST", "user2/repo1/labels/new", map[string]string{
|
||||
"_csrf": GetCSRF(t, session, "user2/repo1/labels"),
|
||||
"title": "active_label",
|
||||
"description": "",
|
||||
"color": "#aa00aa",
|
||||
}), http.StatusSeeOther)
|
||||
session.MakeRequest(t, NewRequestWithValues(t, "POST", "user2/repo1/labels/new", map[string]string{
|
||||
"_csrf": GetCSRF(t, session, "user2/repo1/labels"),
|
||||
"title": "archived_label",
|
||||
"description": "",
|
||||
"color": "#00aa00",
|
||||
}), http.StatusSeeOther)
|
||||
|
||||
// Get ID of label to archive it
|
||||
var id string
|
||||
doc := NewHTMLParser(t, session.MakeRequest(t, NewRequest(t, "GET", "user2/repo1/labels"), http.StatusOK).Body)
|
||||
doc.Find(".issue-label-list .item").Each(func(i int, s *goquery.Selection) {
|
||||
label := s.Find(".label-title .label")
|
||||
if label.Text() == "archived_label" {
|
||||
href, _ := s.Find(".label-issues a.open-issues").Attr("href")
|
||||
hrefParts := strings.Split(href, "=")
|
||||
id = hrefParts[len(hrefParts)-1]
|
||||
}
|
||||
})
|
||||
|
||||
// Make label archived
|
||||
session.MakeRequest(t, NewRequestWithValues(t, "POST", "user2/repo1/labels/edit", map[string]string{
|
||||
"_csrf": GetCSRF(t, session, "user2/repo1/labels"),
|
||||
"id": id,
|
||||
"title": "archived_label",
|
||||
"is_archived": "on",
|
||||
"description": "",
|
||||
"color": "#00aa00",
|
||||
}), http.StatusSeeOther)
|
||||
|
||||
// Test label properties
|
||||
doc = NewHTMLParser(t, session.MakeRequest(t, NewRequest(t, "GET", "user2/repo1/labels"), http.StatusOK).Body)
|
||||
doc.Find(".issue-label-list .item").Each(func(i int, s *goquery.Selection) {
|
||||
label := s.Find(".label-title .label")
|
||||
style, _ := label.Attr("style")
|
||||
|
||||
if label.Text() == "active_label" {
|
||||
assert.False(t, label.HasClass("archived-label"))
|
||||
assert.Contains(t, style, "background-color: #aa00aaff")
|
||||
} else if label.Text() == "archived_label" {
|
||||
assert.True(t, label.HasClass("archived-label"))
|
||||
assert.Contains(t, style, "background-color: #00aa007f")
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
Loading…
Reference in a new issue