diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 8a71c00..35c2f9d 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -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 diff --git a/Makefile b/Makefile index 6799215..67ebb2f 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/cmd/data/favicon.ico b/cmd/data/favicon.ico new file mode 100644 index 0000000..5036269 Binary files /dev/null and b/cmd/data/favicon.ico differ diff --git a/cmd/server.go b/cmd/server.go index fbfb00f..086a6f5 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -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 diff --git a/cmd/server_test.go b/cmd/server_test.go index e2ef807..4d88cd8 100644 --- a/cmd/server_test.go +++ b/cmd/server_test.go @@ -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) diff --git a/console/atest-ui/vite.config.ts b/console/atest-ui/vite.config.ts index da7895f..e988ed2 100644 --- a/console/atest-ui/vite.config.ts +++ b/console/atest-ui/vite.config.ts @@ -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: { diff --git a/e2e/test-suite-common.yaml b/e2e/test-suite-common.yaml index cb1a65d..4d4ac03 100644 --- a/e2e/test-suite-common.yaml +++ b/e2e/test-suite-common.yaml @@ -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