feat: 初始化居家上门服务系统完整项目代码
- Spring Boot 后端服务 (hss-home-service) - delivery-miniapp 配送小程序 - website 官网 (Nuxt) - docs 架构设计文档 - Docker 容器化部署配置 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
97
hss-home-service/website/tests/platform.spec.ts
Normal file
97
hss-home-service/website/tests/platform.spec.ts
Normal file
@@ -0,0 +1,97 @@
|
||||
import { test, expect } from '@playwright/test'
|
||||
|
||||
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'
|
||||
}))
|
||||
})
|
||||
}
|
||||
|
||||
test.describe('平台登录与角色切换', () => {
|
||||
test('登录页可达', async ({ page }) => {
|
||||
await page.goto('/platform/login')
|
||||
await expect(page.getByText('选择登录角色')).toBeVisible()
|
||||
await expect(page.getByText('系统管理员')).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 page.goto('/platform/login')
|
||||
await page.getByText('系统管理员').click()
|
||||
await page.getByText('进入平台').click()
|
||||
await page.waitForURL(/\/platform/)
|
||||
await page.waitForTimeout(2000)
|
||||
const statCards = page.locator('.bg-white.rounded-xl.p-4')
|
||||
await expect(statCards.first()).toBeVisible()
|
||||
})
|
||||
|
||||
test('未登录访问平台被重定向', async ({ page }) => {
|
||||
await page.goto('/platform')
|
||||
await page.waitForTimeout(1000)
|
||||
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 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()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user