test: add complete iOS MVP business suite

This commit is contained in:
selfrelease
2026-07-18 20:54:23 +08:00
parent e19bdb8728
commit 24101398d8
11 changed files with 394 additions and 0 deletions
+2
View File
@@ -5,3 +5,5 @@
`verify-local-auth.sh` 使用 Keycloak Realm 中明确标记为仅限本地开发的账号,注册脚本设备并验证健康检查、Token 获取、设备会话和 `/api/v1/me`。不得把该脚本及其测试凭据用于共享或生产环境。
`verify-all.sh` 执行后端测试、AI 服务测试、Flutter 格式/分析/测试、OpenAPI YAML 和 Git 空白检查。设置 `AIOA_FULL_BUILD=1` 后还会构建 Android Debug APK,并在 macOS 上构建 iOS Simulator App。
`test-ios-mvp.sh` 在已启动的 iOS Simulator 上依次执行员工、部门主管和 OA 管理员真实前端业务场景。测试连接本地 Keycloak、后端、PostgreSQL 和 Flowable,并自动构造互相隔离的业务数据。
+53
View File
@@ -0,0 +1,53 @@
#!/usr/bin/env bash
set -euo pipefail
root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
keycloak_url="${KEYCLOAK_URL:-http://localhost:8081}"
backend_url="${BACKEND_URL:-http://localhost:8080}"
device_id="${IOS_DEVICE_ID:-$(xcrun simctl list devices booted -j | jq -r '.devices[][] | select(.state == "Booted") | .udid' | head -1)}"
if [[ -z "${device_id}" ]]; then
echo 'No booted iOS simulator. Boot one or set IOS_DEVICE_ID.' >&2
exit 1
fi
curl --fail --silent "${backend_url}/actuator/health" >/dev/null
token() {
curl --fail --silent --show-error \
-X POST "${keycloak_url}/realms/aioa/protocol/openid-connect/token" \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode client_id=aioa-mobile \
--data-urlencode grant_type=password \
--data-urlencode "username=$1" \
--data-urlencode "password=$2" | jq -r .access_token
}
run_role() {
local role="$1"
local access_token="$2"
local employee_access_token="$3"
echo "Running iOS MVP scenario: ${role}"
(
cd "${root_dir}/mobile"
flutter test integration_test/mvp_business_test.dart \
-d "${device_id}" \
--dart-define="AIOA_E2E_ACCESS_TOKEN=${access_token}" \
--dart-define="AIOA_E2E_EMPLOYEE_TOKEN=${employee_access_token}" \
--dart-define="AIOA_E2E_ROLE=${role}" \
--dart-define="AIOA_API_BASE_URL=${backend_url}/api/v1"
)
}
employee_token="$(token employee 'Employee123!')"
run_role employee "${employee_token}" "${employee_token}"
employee_token="$(token employee 'Employee123!')"
manager_token="$(token manager 'Manager123!')"
run_role manager "${manager_token}" "${employee_token}"
admin_token="$(token admin 'Admin123!')"
run_role admin "${admin_token}" "${employee_token}"
echo 'All iOS MVP frontend business scenarios passed.'