chore: add favicon for the web page (#316)

Co-authored-by: rick <LinuxSuRen@users.noreply.github.com>
This commit is contained in:
Rick 2023-12-15 12:32:18 +08:00 committed by GitHub
parent 105cea6caf
commit ba51c74b33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 44 additions and 2 deletions

View File

@ -54,6 +54,9 @@ jobs:
sudo atest service install
sudo atest service restart
sudo atest service status
# make test-ui-e2e
atest run -p '.github/testing/*.yaml' --request-ignore-error --report github --report-file bin/report.json --report-github-repo linuxsuren/api-testing --report-github-pr ${{ github.event.number }}
sudo atest service status
sudo atest service stop

View File

@ -95,7 +95,7 @@ testlong:
test-ui:
cd console/atest-ui && npm run test:unit
test-ui-e2e:
cd console/atest-ui && npm run test:e2e
cd console/atest-ui && npm i && npm run test:e2e
test-collector:
go test github.com/linuxsuren/api-testing/extensions/collector/./... -cover -v -coverprofile=collector-coverage.out
go tool cover -func=collector-coverage.out

BIN
cmd/data/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

@ -255,6 +255,7 @@ func (o *serverOption) runE(cmd *cobra.Command, args []string) (err error) {
mux.HandlePath(http.MethodGet, "/", frontEndHandlerWithLocation(o.consolePath))
mux.HandlePath(http.MethodGet, "/assets/{asset}", frontEndHandlerWithLocation(o.consolePath))
mux.HandlePath(http.MethodGet, "/healthz", frontEndHandlerWithLocation(o.consolePath))
mux.HandlePath(http.MethodGet, "/favicon.ico", frontEndHandlerWithLocation(o.consolePath))
mux.HandlePath(http.MethodGet, "/get", o.getAtestBinary)
postRequestProxyFunc := postRequestProxy(o.skyWalking)
@ -340,6 +341,9 @@ func frontEndHandlerWithLocation(consolePath string) func(w http.ResponseWriter,
case strings.HasSuffix(target, ".css"):
content = uiResourceCSS
customHeader[util.ContentType] = "text/css"
case strings.HasSuffix(target, ".ico"):
content = uiResourceIcon
customHeader[util.ContentType] = "image/x-icon"
}
if content != "" {
@ -447,3 +451,6 @@ var uiResourceCSS string
//go:embed data/index.html
var uiResourceIndex string
//go:embed data/favicon.ico
var uiResourceIcon string

View File

@ -117,6 +117,15 @@ func TestFrontEndHandlerWithLocation(t *testing.T) {
assert.Equal(t, expect404, resp.GetBody().String())
})
t.Run("favicon", func(t *testing.T) {
req, err := http.NewRequest(http.MethodGet, "/favicon.ico", nil)
assert.NoError(t, err)
resp := newFakeResponseWriter()
handler(resp, req, map[string]string{})
assert.Equal(t, "image/x-icon", resp.Header().Get(util.ContentType))
})
t.Run("healthz", func(t *testing.T) {
req, err := http.NewRequest(http.MethodGet, "/healthz", nil)
assert.NoError(t, err)

View File

@ -4,10 +4,26 @@ import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
function removeDataTestAttrs(node) {
if (node.type === 1 /* NodeTypes.ELEMENT */) {
node.props = node.props.filter(prop =>
prop.type === 6 /* NodeTypes.ATTRIBUTE */
? prop.name !== 'test-id'
: true
)
}
}
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
vue({
template: {
compilerOptions: {
nodeTransforms: true ? [removeDataTestAttrs] : [],
},
},
}),
vueJsx(),
],
resolve: {

View File

@ -286,3 +286,10 @@ items:
request:
api: |
{{.param.server}}/debug/pprof/cmdline
- name: favicon
request:
api: |
{{ .param.server }}/favicon.ico
expect:
header:
Content-Type: image/x-icon