Skip to content

Commit 06ee142

Browse files
authored
chore(cli/test_admin_ui): use a real built dashboard (#12683)
1 parent ebe8d6c commit 06ee142

File tree

1 file changed

+33
-11
lines changed

1 file changed

+33
-11
lines changed

t/cli/test_admin_ui.sh

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,22 @@ if [ ! $? -eq 0 ]; then
3131
exit 1
3232
fi
3333

34+
# build apisix-dashboard
35+
corepack enable pnpm
36+
37+
## prepare apisix-dashboard source code
38+
source .requirements
39+
git clone --revision=${APISIX_DASHBOARD_COMMIT} --depth 1 https://github.com/apache/apisix-dashboard.git
40+
pushd apisix-dashboard
41+
42+
## compile
43+
pnpm install --frozen-lockfile && pnpm run build
44+
popd
45+
46+
## copy the dist files to the ui directory
47+
mkdir ui
48+
cp -R apisix-dashboard/dist/* ui/ && rm -r apisix-dashboard
49+
3450
make run
3551

3652
## check /ui redirects to /ui/ with 301
@@ -50,11 +66,6 @@ fi
5066

5167
## check /ui/ accessible
5268

53-
mkdir -p ui/assets
54-
echo "test_html" > ui/index.html
55-
echo "test_js" > ui/assets/test.js
56-
echo "test_css" > ui/assets/test.css
57-
5869
code=$(curl -v -k -i -m 20 -o /dev/null -s -w %{http_code} http://127.0.0.1:9180/ui/)
5970
if [ ! $code -eq 200 ]; then
6071
echo "failed: /ui/ not accessible"
@@ -69,19 +80,30 @@ if [ ! $code -eq 200 ]; then
6980
exit 1
7081
fi
7182

72-
## check /ui/assets/test.js accessible
83+
## check /ui/assets/*.js accessible
84+
85+
js_file=$(find ui/assets -name "*.js" | head -n 1)
86+
code=$(curl -v -k -i -m 20 -o /dev/null -s -w %{http_code} http://127.0.0.1:9180/${js_file})
87+
if [ ! $code -eq 200 ]; then
88+
echo "failed: ${js_file} not accessible"
89+
exit 1
90+
fi
91+
92+
## check /ui/assets/*.css accessible
7393

74-
code=$(curl -v -k -i -m 20 -o /dev/null -s -w %{http_code} http://127.0.0.1:9180/ui/assets/test.js)
94+
css_file=$(find ui/assets -name "*.css" | head -n 1)
95+
code=$(curl -v -k -i -m 20 -o /dev/null -s -w %{http_code} http://127.0.0.1:9180/${css_file})
7596
if [ ! $code -eq 200 ]; then
76-
echo "failed: /ui/assets/test.js not accessible"
97+
echo "failed: ${css_file} not accessible"
7798
exit 1
7899
fi
79100

80-
## check /ui/assets/test.css accessible
101+
## check /ui/assets/*.svg accessible
81102

82-
code=$(curl -v -k -i -m 20 -o /dev/null -s -w %{http_code} http://127.0.0.1:9180/ui/assets/test.css)
103+
svg_file=$(find ui/assets -name "*.svg" | head -n 1)
104+
code=$(curl -v -k -i -m 20 -o /dev/null -s -w %{http_code} http://127.0.0.1:9180/${svg_file})
83105
if [ ! $code -eq 200 ]; then
84-
echo "failed: /ui/assets/test.css not accessible"
106+
echo "failed: ${svg_file} not accessible"
85107
exit 1
86108
fi
87109

0 commit comments

Comments
 (0)