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]>
78 lines
2.7 KiB
Go
78 lines
2.7 KiB
Go
// Copyright 2026 Hanzo AI, Inc. All rights reserved.
|
|
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package public
|
|
|
|
import (
|
|
"html/template"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/hanzoai/git/modules/setting"
|
|
"github.com/hanzoai/git/modules/test"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestViteManifest(t *testing.T) {
|
|
defer test.MockVariableValue(&setting.IsProd, true)()
|
|
|
|
const testManifest = `{
|
|
"web_src/js/index.ts": {
|
|
"file": "js/index.C6Z2MRVQ.js",
|
|
"name": "index",
|
|
"src": "web_src/js/index.ts",
|
|
"isEntry": true,
|
|
"imports": ["_shared.AaAaAaAa.js"],
|
|
"css": ["css/index.B3zrQPqD.css", "css/index-extra.CcCcCcCc.css"]
|
|
},
|
|
"_shared.AaAaAaAa.js": {
|
|
"file": "js/shared.AaAaAaAa.js",
|
|
"name": "shared",
|
|
"css": ["css/shared.BbBbBbBb.css"]
|
|
},
|
|
"web_src/css/themes/theme-hanzo-dark.css": {
|
|
"file": "css/theme-hanzo-dark.CyAaQnn5.css",
|
|
"name": "theme-hanzo-dark",
|
|
"src": "web_src/css/themes/theme-hanzo-dark.css",
|
|
"isEntry": true
|
|
}
|
|
}`
|
|
|
|
t.Run("EmptyManifest", func(t *testing.T) {
|
|
storeManifestFromBytes([]byte(``), 0, time.Now())
|
|
// not in manifest -> custom theme fallback
|
|
assert.Equal(t, "/assets/css/theme-hanzo-dark.css", AssetURI("web_src/css/themes/theme-hanzo-dark.css"))
|
|
assert.Empty(t, entryStyleURLs("web_src/js/index.ts", "web_src/css/index.css"))
|
|
assert.Empty(t, AssetNameFromHashedPath("css/no-such-file.css"))
|
|
})
|
|
|
|
t.Run("ParseManifest", func(t *testing.T) {
|
|
storeManifestFromBytes([]byte(testManifest), 0, time.Now())
|
|
|
|
// assets are addressed by their source path (the manifest key)
|
|
assert.Equal(t, "/assets/js/index.C6Z2MRVQ.js", AssetURI("web_src/js/index.ts"))
|
|
assert.Equal(t, "/assets/css/theme-hanzo-dark.CyAaQnn5.css", AssetURI("web_src/css/themes/theme-hanzo-dark.css"))
|
|
|
|
// custom theme not in the manifest falls back to the static asset location
|
|
assert.Equal(t, "/assets/css/theme-custom.css", AssetURI("web_src/css/themes/theme-custom.css"))
|
|
|
|
// a JS entry's stylesheets: all of the entry's own CSS plus the CSS of statically-imported chunks
|
|
assert.Equal(t, []string{
|
|
"/assets/css/index.B3zrQPqD.css",
|
|
"/assets/css/index-extra.CcCcCcCc.css",
|
|
"/assets/css/shared.BbBbBbBb.css",
|
|
}, entryStyleURLs("web_src/js/index.ts", "web_src/css/index.css"))
|
|
assert.Equal(t, template.HTML(
|
|
`<link rel="stylesheet" href="/assets/css/index.B3zrQPqD.css">`+
|
|
`<link rel="stylesheet" href="/assets/css/index-extra.CcCcCcCc.css">`+
|
|
`<link rel="stylesheet" href="/assets/css/shared.BbBbBbBb.css">`,
|
|
), AssetCSSLinks("web_src/js/index.ts", "web_src/css/index.css"))
|
|
|
|
// hashed output file -> entry name
|
|
assert.Equal(t, "theme-hanzo-dark", AssetNameFromHashedPath("css/theme-hanzo-dark.CyAaQnn5.css"))
|
|
assert.Empty(t, AssetNameFromHashedPath("css/no-such-file.css"))
|
|
})
|
|
}
|