核心修复: - 状态机加 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>
116 lines
4.5 KiB
TypeScript
116 lines
4.5 KiB
TypeScript
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('/')
|
|
await page.evaluate(() => {
|
|
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 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 loginViaForm(page, LOGIN_PHONE, LOGIN_PASSWORD)
|
|
await page.waitForURL(/\/platform/, { timeout: 5000 })
|
|
await expect(page.getByRole('heading', { name: /工作台/ })).toBeVisible()
|
|
})
|
|
|
|
test('工作台显示统计数字', async ({ page }) => {
|
|
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({ timeout: 5000 })
|
|
})
|
|
|
|
test('未登录访问平台被重定向', async ({ page }) => {
|
|
await page.goto('/platform')
|
|
await page.waitForTimeout(2000)
|
|
expect(page.url()).toContain('/platform/login')
|
|
})
|
|
|
|
test('退出登录返回登录页', async ({ page }) => {
|
|
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')
|
|
})
|
|
})
|
|
|
|
test.describe('服务申请管理', () => {
|
|
test('申请管理页可达并显示列表', async ({ page }) => {
|
|
await loginAsAdmin(page)
|
|
await page.goto('/platform/applications')
|
|
await page.waitForTimeout(3000)
|
|
await expect(page.getByText('服务申请管理')).toBeVisible()
|
|
})
|
|
|
|
test('打开新建申请表单', async ({ page }) => {
|
|
await loginAsAdmin(page)
|
|
await page.goto('/platform/applications')
|
|
await page.waitForTimeout(2000)
|
|
await page.getByText('新建申请').click()
|
|
await expect(page.getByText('新建服务申请')).toBeVisible()
|
|
await expect(page.getByPlaceholder('如 2001')).toBeVisible()
|
|
})
|
|
|
|
test('创建新申请', async ({ page }) => {
|
|
await loginAsAdmin(page)
|
|
await page.goto('/platform/applications')
|
|
await page.waitForTimeout(2000)
|
|
await page.getByText('新建申请').click()
|
|
await page.getByPlaceholder('如 2001').fill('2001')
|
|
await page.getByPlaceholder('姓名').fill('PW测试')
|
|
await page.getByPlaceholder('手机号').fill('13800000000')
|
|
await page.getByPlaceholder('详细地址').fill('梅江区')
|
|
await page.getByText('提交申请').click()
|
|
await page.waitForTimeout(3000)
|
|
// New application should appear in the table
|
|
await expect(page.getByText('服务申请管理')).toBeVisible()
|
|
})
|
|
})
|
|
|
|
test.describe('工单管理', () => {
|
|
test('工单管理页可达', async ({ page }) => {
|
|
await loginAsAdmin(page)
|
|
await page.goto('/platform/work-orders')
|
|
await page.waitForTimeout(3000)
|
|
await expect(page.getByText('工单管理')).toBeVisible()
|
|
})
|
|
})
|