feat: 全系统优化 — 并发控制 + 冗余清理 + 数据流修复 + 全面测试
核心修复: - 状态机加 SELECT FOR UPDATE 行锁,消除并发竞态 - hss_md_staff 加 role 列,登录从数据库读取真实角色 - 申请重复校验排除自身,全流程 20 步闭环通过 - 派单 SQL 修复 + 支付状态机过渡 + 完成服务 plan_item_id 修复 并发控制新增: - RedisLockService (SET NX PX + Lua 安全解锁) - RateLimiterService (Redis 滑动窗口 + API 拦截器) - TransactionIsolationConfig (SERIALIZABLE for 支付回调) - MqttPublisher (异步队列 + JDK TCP 探测) - ObjectStorageService (AWS SigV4 预签名, 纯 JDK) 冗余清理: - 删除 6 个死代码文件 (~620 行) - hutool-all → JDK MessageDigest, 去 MapStruct, 去 jsr310 - haversine 提取到 GeoUtil, count/round 提取到 JdbcUtil - 创建 platform layout 组件 前端修复: - 登录页移除角色选择器, 由后端 JWT 返回 - 移除 ClientOnly 包裹, 页面正常渲染 - SPA fallback Nginx 配置修复 Docker: 运行时镜像 eclipse-temurin:17-jre-jammy (缩小 ~300MB) 文档: 新增系统实现与修复报告.md Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,18 @@
|
||||
import { test, expect } from '@playwright/test'
|
||||
|
||||
const LOGIN_PHONE = '13900000001'
|
||||
const LOGIN_PASSWORD = 'test123456'
|
||||
|
||||
async function loginViaForm(page: any, phone: string, password: string) {
|
||||
await page.goto('/platform/login')
|
||||
await page.waitForSelector('input[placeholder="11位手机号"]', { timeout: 10000 })
|
||||
await page.getByPlaceholder('11位手机号').fill(phone)
|
||||
await page.getByPlaceholder('输入密码').fill(password)
|
||||
// Click submit button (bg-primary button, not the tab)
|
||||
await page.locator('button.bg-primary').click()
|
||||
await page.waitForTimeout(3000)
|
||||
}
|
||||
|
||||
async function loginAsAdmin(page: any) {
|
||||
// Inject auth directly via localStorage to bypass login flow
|
||||
await page.goto('/')
|
||||
@@ -7,48 +20,53 @@ async function loginAsAdmin(page: any) {
|
||||
localStorage.setItem('hss_platform_user', JSON.stringify({
|
||||
userId: '1', userName: '系统管理员', userRole: 'ADMIN', tenantId: '1', orgId: '1'
|
||||
}))
|
||||
localStorage.setItem('hss_token', 'test-token')
|
||||
})
|
||||
}
|
||||
|
||||
test.describe('平台登录与角色切换', () => {
|
||||
test('登录页可达', async ({ page }) => {
|
||||
await page.goto('/platform/login')
|
||||
await expect(page.getByText('选择登录角色')).toBeVisible()
|
||||
await expect(page.getByText('系统管理员')).toBeVisible()
|
||||
await page.waitForSelector('input[placeholder="11位手机号"]', { timeout: 10000 })
|
||||
await expect(page.locator('h1').filter({ hasText: '智慧医养' })).toBeVisible()
|
||||
await expect(page.getByPlaceholder('11位手机号')).toBeVisible()
|
||||
await expect(page.getByPlaceholder('输入密码')).toBeVisible()
|
||||
await expect(page.locator('button.bg-primary')).toBeVisible()
|
||||
})
|
||||
|
||||
test('选择管理员登录并进入工作台', async ({ page }) => {
|
||||
await page.goto('/platform/login')
|
||||
await page.getByText('系统管理员').click()
|
||||
await page.getByText('进入平台').click()
|
||||
await page.waitForURL(/\/platform/)
|
||||
await page.waitForTimeout(1500)
|
||||
await expect(page.getByText('工作台')).toBeVisible()
|
||||
await expect(page.getByText('今日工单')).toBeVisible()
|
||||
test('表单登录进入工作台', async ({ page }) => {
|
||||
await loginViaForm(page, LOGIN_PHONE, LOGIN_PASSWORD)
|
||||
await page.waitForURL(/\/platform/, { timeout: 5000 })
|
||||
await expect(page.getByRole('heading', { name: /工作台/ })).toBeVisible()
|
||||
})
|
||||
|
||||
test('工作台显示统计数字', async ({ page }) => {
|
||||
await page.goto('/platform/login')
|
||||
await page.getByText('系统管理员').click()
|
||||
await page.getByText('进入平台').click()
|
||||
await page.waitForURL(/\/platform/)
|
||||
await loginAsAdmin(page)
|
||||
await page.goto('/platform')
|
||||
await page.waitForURL(/\/platform/, { timeout: 10000 })
|
||||
await page.waitForTimeout(2000)
|
||||
const statCards = page.locator('.bg-white.rounded-xl.p-4')
|
||||
await expect(statCards.first()).toBeVisible()
|
||||
await expect(statCards.first()).toBeVisible({ timeout: 5000 })
|
||||
})
|
||||
|
||||
test('未登录访问平台被重定向', async ({ page }) => {
|
||||
await page.goto('/platform')
|
||||
await page.waitForTimeout(1000)
|
||||
await page.waitForTimeout(2000)
|
||||
expect(page.url()).toContain('/platform/login')
|
||||
})
|
||||
|
||||
test('退出登录返回登录页', async ({ page }) => {
|
||||
await page.goto('/platform/login')
|
||||
await page.getByText('系统管理员').click()
|
||||
await page.getByText('进入平台').click()
|
||||
await page.waitForURL(/\/platform/)
|
||||
await page.getByText('退出登录').first().click()
|
||||
await loginAsAdmin(page)
|
||||
await page.goto('/platform')
|
||||
await page.waitForTimeout(2000)
|
||||
// Try sidebar logout first, fall back to mobile logout
|
||||
const sidebarLogout = page.locator('aside button', { hasText: '退出' })
|
||||
const mobileLogout = page.locator('button', { hasText: '退出' })
|
||||
if (await sidebarLogout.isVisible().catch(() => false)) {
|
||||
await sidebarLogout.click()
|
||||
} else if (await mobileLogout.isVisible().catch(() => false)) {
|
||||
await mobileLogout.click()
|
||||
}
|
||||
await page.waitForTimeout(500)
|
||||
expect(page.url()).toContain('/platform/login')
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user