mirror of
https://github.com/hanzoai/forge.git
synced 2026-10-30 15:00:39 +00:00
2978 files. The fork is 2026-07-15 (rebrand: gitea.dev -> github.com/hanzoai/git), so 2026 is the year, and "Copyright 2026 Hanzo AI, Inc." was already the form used by the handful of files that had ours. Shape is now: // Copyright 2026 Hanzo AI, Inc. All rights reserved. // Copyright 2015 The Gogs Authors. All rights reserved. // Copyright 2019 The Gitea Authors. All rights reserved. // SPDX-License-Identifier: MIT Ours on top, theirs retained verbatim. Retained because MIT requires it, and separately because they are true — those authors did write that code. Not renamed to "The Git Authors": Git is a different project under a different license, and putting its name here would attribute this code to people who have nothing to do with it. Adding our line is the fix; overwriting theirs would have been both a licence violation and a false statement. gofmt still reports import-order drift in some of these files. It predates this change (verified against a stash) and is left alone rather than burying a one-line-per-file legal change under 3000 files of unrelated reordering. Build clean. Co-authored-by: Hanzo Dev <[email protected]>
64 lines
1.7 KiB
Go
64 lines
1.7 KiB
Go
// Copyright 2026 Hanzo AI, Inc. All rights reserved.
|
|
// Copyright 2017 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package integration
|
|
|
|
import (
|
|
"io"
|
|
"testing"
|
|
|
|
"github.com/hanzoai/git/modules/test"
|
|
|
|
"github.com/PuerkitoBio/goquery"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
// HTMLDoc struct
|
|
type HTMLDoc struct {
|
|
doc *goquery.Document
|
|
}
|
|
|
|
// NewHTMLParser parse html file
|
|
func NewHTMLParser(t testing.TB, body io.Reader) *HTMLDoc {
|
|
t.Helper()
|
|
doc, err := goquery.NewDocumentFromReader(body)
|
|
assert.NoError(t, err)
|
|
return &HTMLDoc{doc: doc}
|
|
}
|
|
|
|
// GetInputValueByName for get input value by name
|
|
func (doc *HTMLDoc) GetInputValueByName(name string) string {
|
|
text, _ := doc.doc.Find(`input[name="` + name + `"]`).Attr("value")
|
|
return text
|
|
}
|
|
|
|
// Find gets the descendants of each element in the current set of
|
|
// matched elements, filtered by a selector. It returns a new Selection
|
|
// object containing these matched elements.
|
|
func (doc *HTMLDoc) Find(selector string) *goquery.Selection {
|
|
return doc.doc.Find(selector)
|
|
}
|
|
|
|
// AssertHTMLElement check if the element by selector exists or does not exist depending on checkExists
|
|
func AssertHTMLElement[T int | bool](t testing.TB, doc *HTMLDoc, selector string, checkExists T) {
|
|
t.Helper()
|
|
sel := doc.doc.Find(selector)
|
|
switch v := any(checkExists).(type) {
|
|
case bool:
|
|
assert.Equal(t, v, sel.Length() > 0)
|
|
case int:
|
|
assert.Equal(t, v, sel.Length())
|
|
}
|
|
}
|
|
|
|
func assertHTMLEq(t testing.TB, expected, actual string) {
|
|
t.Helper()
|
|
if expected == actual { // fast path
|
|
return
|
|
}
|
|
exp := test.NormalizeHTMLAttributes(t, expected)
|
|
act := test.NormalizeHTMLAttributes(t, actual)
|
|
assert.Equal(t, exp, act)
|
|
}
|