优化 PC 登录页桌面布局(07-30-pc-login-desktop-layout)
这个提交包含在:
@@ -1664,7 +1664,10 @@ onNeedRefresh() {
|
|||||||
- Auth routes should use one shared auth panel for brand, page title, subtitle,
|
- Auth routes should use one shared auth panel for brand, page title, subtitle,
|
||||||
content and optional footer links.
|
content and optional footer links.
|
||||||
- `AuthLayout` owns only the auth page shell: background, width constraint,
|
- `AuthLayout` owns only the auth page shell: background, width constraint,
|
||||||
centering, PWA update prompt and route outlet.
|
centering, PWA update prompt and route outlet. Its default variant remains a
|
||||||
|
460px auth form; `/login` may explicitly select the `login` variant to allow
|
||||||
|
the approved desktop entry layout without widening password recovery or
|
||||||
|
forced password change pages.
|
||||||
- Page implementations own only their form fields, submit actions, validation
|
- Page implementations own only their form fields, submit actions, validation
|
||||||
messages and route-specific login-entry choices.
|
messages and route-specific login-entry choices.
|
||||||
|
|
||||||
@@ -1673,8 +1676,12 @@ onNeedRefresh() {
|
|||||||
- Do not nest a form card inside another login card.
|
- Do not nest a form card inside another login card.
|
||||||
- Put the brand block inside the auth panel so logo, system name, title and
|
- Put the brand block inside the auth panel so logo, system name, title and
|
||||||
form share one visual axis.
|
form share one visual axis.
|
||||||
- Keep the panel width stable around the current auth-shell width; auth pages
|
- Keep password recovery, forced password change and login fallback-only panels
|
||||||
should feel like an OA workstation entry, not a marketing split hero.
|
stable around the 460px auth-shell width. When PC Enterprise WeChat login is
|
||||||
|
enabled, `/login` may expand to a functional desktop split up to roughly
|
||||||
|
920px: Enterprise WeChat entry on the left and a form column capped around
|
||||||
|
404px on the right. This remains one shared auth panel, not a marketing split
|
||||||
|
hero or nested form-card layout.
|
||||||
- Place `忘记密码?` beside the password label or directly below the password
|
- Place `忘记密码?` beside the password label or directly below the password
|
||||||
input on the right; do not bury it in help text or page footer.
|
input on the right; do not bury it in help text or page footer.
|
||||||
- Keep the DOM/tab order aligned with the main form flow even when CSS places
|
- Keep the DOM/tab order aligned with the main form flow even when CSS places
|
||||||
@@ -1686,10 +1693,15 @@ onNeedRefresh() {
|
|||||||
|
|
||||||
### 4. Login Entry Hierarchy
|
### 4. Login Entry Hierarchy
|
||||||
|
|
||||||
- Normal browser: account/password or email-code login is primary. Enterprise
|
- Normal browser with `pcWebLoginEnabled=true` and a non-null `pcLoginUrl`:
|
||||||
WeChat is shown as a boundary notice or secondary entry that tells users to
|
Enterprise WeChat is the preferred desktop entry. At 1024px and above, show
|
||||||
open OA from the Enterprise WeChat workbench; do not require a clickable OAuth
|
it in the left functional column and keep account/password plus email-code in
|
||||||
button in ordinary browsers.
|
the right fallback column. Below 1024px, preserve the existing single-column
|
||||||
|
form-first order and show the PC Enterprise WeChat entry afterward.
|
||||||
|
- Normal browser without an available PC login URL: keep the existing 460px
|
||||||
|
single-column form and show only the workbench boundary notice or other
|
||||||
|
configured secondary provider; never render an empty desktop column or a
|
||||||
|
disabled PC login button.
|
||||||
- Enterprise WeChat WebView: Enterprise WeChat one-click entry is primary;
|
- Enterprise WeChat WebView: Enterprise WeChat one-click entry is primary;
|
||||||
account/password login remains available as the fallback path.
|
account/password login remains available as the fallback path.
|
||||||
- Enterprise WeChat entry changes must remain frontend entry hierarchy changes
|
- Enterprise WeChat entry changes must remain frontend entry hierarchy changes
|
||||||
@@ -1706,7 +1718,10 @@ onNeedRefresh() {
|
|||||||
- keyboard Tab from the username/email field lands on the password input, not
|
- keyboard Tab from the username/email field lands on the password input, not
|
||||||
the forgot-password link;
|
the forgot-password link;
|
||||||
- password recovery request-code and reset flow on `/forgot-password`;
|
- password recovery request-code and reset flow on `/forgot-password`;
|
||||||
- normal-browser Enterprise WeChat boundary notice or secondary entry;
|
- 1024px and 1440px normal-browser PC Enterprise WeChat functional split,
|
||||||
|
including column position and controlled form width;
|
||||||
|
- 375px and 768px single-column form-first order without horizontal overflow;
|
||||||
|
- PC login configuration unavailable falling back to the 460px single column;
|
||||||
- WeCom WebView Enterprise WeChat entry as primary CTA with password fallback.
|
- WeCom WebView Enterprise WeChat entry as primary CTA with password fallback.
|
||||||
- UI design rules check and Playwright screenshot evidence when the auth layout
|
- UI design rules check and Playwright screenshot evidence when the auth layout
|
||||||
changes visibly.
|
changes visibly.
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
{"_example": "Fill with {\"file\": \"<path>\", \"reason\": \"<why>\"}. Put spec/research files only — no code paths. Run `python3 .trellis/scripts/get_context.py --mode packages` to list available specs. Delete this line once real entries are added."}
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
# PC 登录页桌面布局优化设计
|
||||||
|
|
||||||
|
## 1. Design Goal
|
||||||
|
|
||||||
|
只调整普通 PC 浏览器登录页的响应式布局和视觉层级:桌面端通过功能双栏突出企业微信扫码主入口,同时保留完整的密码与邮箱验证码回退;所有认证请求、跳转和错误合同保持不变。
|
||||||
|
|
||||||
|
## 2. Current Structure
|
||||||
|
|
||||||
|
```text
|
||||||
|
AuthLayout
|
||||||
|
max-width: 460px(所有认证页共享)
|
||||||
|
└─ LoginPage
|
||||||
|
└─ AuthPanel
|
||||||
|
├─ 品牌与标题
|
||||||
|
├─ 登录方式说明
|
||||||
|
├─ 密码 / 邮箱验证码切换与表单
|
||||||
|
└─ 企业微信扫码入口
|
||||||
|
```
|
||||||
|
|
||||||
|
问题根因是共享 `AuthLayout` 在所有视口统一限制为 460px,`LoginPage` 内部也只有单列内容流。直接扩大共享宽度会连带影响找回密码和修改密码;直接拉伸表单则会造成过长输入框。
|
||||||
|
|
||||||
|
## 3. Target Structure
|
||||||
|
|
||||||
|
```text
|
||||||
|
普通浏览器,桌面 >= 1024px,PC 扫码可用
|
||||||
|
AuthLayout(login variant, wider container)
|
||||||
|
└─ AuthPanel
|
||||||
|
├─ 共享品牌、标题、全局状态
|
||||||
|
└─ desktop grid
|
||||||
|
├─ 左:企业微信扫码主入口
|
||||||
|
└─ 右:密码 / 邮箱验证码切换与表单
|
||||||
|
|
||||||
|
普通浏览器,PC 扫码不可用
|
||||||
|
└─ 宽容器内的受控单列表单,不渲染空白左栏
|
||||||
|
|
||||||
|
窄屏 / 企业微信 WebView
|
||||||
|
└─ 保持现有单列顺序与一键进入/密码回退行为
|
||||||
|
```
|
||||||
|
|
||||||
|
## 4. Component Boundaries
|
||||||
|
|
||||||
|
### 4.1 `AuthLayout`
|
||||||
|
|
||||||
|
- 增加显式页面级布局 variant,由路由仅为 `/login` 选择宽版桌面容器。
|
||||||
|
- 默认 variant 继续保持 460px,因此 `/forgot-password` 和 `/change-password` 不受影响。
|
||||||
|
- PWA 更新提示与页面内容共享同一受控容器,不改变更新行为。
|
||||||
|
|
||||||
|
### 4.2 `LoginPage`
|
||||||
|
|
||||||
|
- 复用现有查询、状态、事件处理函数和 `data-testid`。
|
||||||
|
- 将“企业入口”和“备用登录”整理为可响应式排序的语义分区;桌面扫码可用时启用双栏。
|
||||||
|
- 企业微信扫码按钮在桌面双栏中使用主入口视觉;窄屏沿用现有顺序与按钮行为。
|
||||||
|
- 顶部绑定/登录结果提示属于全局状态,跨双栏显示,避免只附着在某一种登录方式上。
|
||||||
|
|
||||||
|
### 4.3 Shared styles
|
||||||
|
|
||||||
|
- 优先使用现有 Tailwind 断点、主题 token、`AuthPanel`、`Button`、`Input` 和状态提示。
|
||||||
|
- 仅在重复或难以表达的布局规则出现时增加少量 `auth-*` CSS 类,不新增 token 文件或依赖。
|
||||||
|
|
||||||
|
## 5. Responsive Contract
|
||||||
|
|
||||||
|
| 场景 | 布局 |
|
||||||
|
| --- | --- |
|
||||||
|
| 375px | 单列,无横向滚动;保持现有普通浏览器内容顺序 |
|
||||||
|
| 768px | 单列或受控过渡宽度,不提前挤成双栏 |
|
||||||
|
| 1024px | PC 扫码可用时进入功能双栏 |
|
||||||
|
| 1440px | 双栏居中,外层和列宽均有上限,不把表单拉满 |
|
||||||
|
| 企业微信 WebView | 单列,一键进入优先;不展示 PC 扫码栏 |
|
||||||
|
| PC 扫码关闭/配置缺失 | 单列回退,不显示空栏或失效按钮 |
|
||||||
|
|
||||||
|
## 6. Compatibility and Risk Controls
|
||||||
|
|
||||||
|
- 不修改 `fetchWecomConfig`、`buildWecomLoginUrl`、redirect、设备指纹或任何服务端代码。
|
||||||
|
- 不改现有输入、按钮和提示的测试标识;布局测试只增加容器级标识。
|
||||||
|
- 主要风险是 JSX 重排导致条件渲染遗漏、移动端顺序回退或共享认证页被扩宽。通过场景化 Playwright、边界尺寸断言和截图复核控制。
|
||||||
|
- 不引入新的持久化状态、迁移或生产配置,因此应用回滚只需回滚本任务前端提交。
|
||||||
|
|
||||||
|
## 7. Rollout Boundary
|
||||||
|
|
||||||
|
- 本地验证不等于线上可测。
|
||||||
|
- 若后续需要部署,必须另行获得明确批准,并完成公网登录页、扫码跳转、密码/邮箱入口和构建标识检查后才能通知用户测试。
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{"_example": "Fill with {\"file\": \"<path>\", \"reason\": \"<why>\"}. Put spec/research files only — no code paths. Run `python3 .trellis/scripts/get_context.py --mode packages` to list available specs. Delete this line once real entries are added."}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
# PC 登录页桌面布局优化实施计划
|
||||||
|
|
||||||
|
## 1. Preconditions
|
||||||
|
|
||||||
|
- [x] 用户确认创建独立 Trellis task。
|
||||||
|
- [x] 用户确认桌面端采用“左侧企业微信主入口、右侧备用登录表单”的功能双栏。
|
||||||
|
- [x] 用户已批准本 PRD、设计和实施计划,可以运行 `task.py start` 并修改产品代码。
|
||||||
|
|
||||||
|
## 2. Implementation
|
||||||
|
|
||||||
|
- [x] 为 `AuthLayout` 增加显式登录页宽版 variant,并在路由中只对 `/login` 启用;默认认证页宽度保持不变。
|
||||||
|
- [x] 重组 `LoginPage` 的展示层,把全局提示、企业微信主入口和备用登录表单整理为响应式分区。
|
||||||
|
- [x] 在普通 PC 浏览器且扫码可用时启用桌面功能双栏;扫码不可用、窄屏和企微 WebView 使用受控单栏。
|
||||||
|
- [x] 保留现有认证查询、跳转、回跳、设备指纹、表单状态、错误处理和全部既有控件测试标识。
|
||||||
|
- [x] 未增加依赖、平行设计系统或新的 CSS token,仅复用现有 Tailwind、主题 token 和共享组件。
|
||||||
|
|
||||||
|
## 3. Focused Validation
|
||||||
|
|
||||||
|
- [x] 扩充登录页 Playwright 覆盖:1440px 双栏、1024px 双栏、768px 单栏、375px 单栏、扫码关闭单栏、企业微信 WebView 单栏。
|
||||||
|
- [x] 断言桌面双栏的实际边界、相对位置和合理表单宽度,而不只断言元素存在。
|
||||||
|
- [x] 回归企业微信扫码跳转的 `entrySource`、`returnTo` 和设备指纹,以及密码/邮箱切换、找回密码和 PWA 输入保持。
|
||||||
|
- [x] 生成代表性桌面与移动截图并人工复核信息层级、留白、对比度、焦点和无横向滚动。
|
||||||
|
|
||||||
|
建议命令:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd client && npx playwright test tests/e2e/wecom-entry.spec.ts tests/e2e/login-portal-ux.spec.ts --workers=1 --reporter=list
|
||||||
|
cd client && npm run typecheck
|
||||||
|
cd client && npm run build
|
||||||
|
```
|
||||||
|
|
||||||
|
## 4. Project Gates
|
||||||
|
|
||||||
|
- [x] `python3 ./.trellis/scripts/task.py validate 07-30-pc-login-desktop-layout`
|
||||||
|
- [x] `node scripts/qa/check-process-contract.mjs --baseline --json`
|
||||||
|
- [x] `node scripts/qa/audit-docs.mjs --check-registry`
|
||||||
|
- [x] `node scripts/qa/check-trellis-governance.mjs`
|
||||||
|
- [x] `git diff --check`
|
||||||
|
|
||||||
|
## 5. Review and Rollback
|
||||||
|
|
||||||
|
- [x] 对最终 diff 做认证零变更复核,确认没有服务端、接口、配置、回调或生产文件变化。
|
||||||
|
- [x] 已通过 1024px 首轮测试发现备用列过宽并收敛到约 404px;未通过改认证逻辑绕过视觉问题。
|
||||||
|
- [x] 已确认生产部署不属于当前规划批准;如需部署,另行申请并按项目公网检查边界执行。
|
||||||
|
|
||||||
|
## 6. Local Evidence (2026-07-31)
|
||||||
|
|
||||||
|
- `E2E_BASE_URL=http://127.0.0.1:5173 npx playwright test tests/e2e/wecom-entry.spec.ts tests/e2e/login-portal-ux.spec.ts --workers=1 --reporter=list`:19 passed。
|
||||||
|
- `npm run build`:通过;Vite 2383 modules transformed,PWA 102 entries。
|
||||||
|
- 代表性截图保存在本地忽略目录 `output/playwright/pc-login-{375,768,1024,1440}.png`,人工复核通过。
|
||||||
|
- 项目门禁全部通过;`audit-docs` 只有既有 22 个未注册 docs 文件 warning。
|
||||||
|
- 本地开发完成,尚未部署,不能告知用户线上可测。
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
# PC 登录页桌面布局优化
|
||||||
|
|
||||||
|
## Goal
|
||||||
|
|
||||||
|
让普通 PC 浏览器中的 OA 登录页呈现明确的桌面端信息层级和合理空间利用,不再像放大后的手机卡片;同时保持已经完成真实验收的企业微信扫码登录、账号密码、邮箱验证码、找回密码、回跳和错误提示行为不变。
|
||||||
|
|
||||||
|
## Background
|
||||||
|
|
||||||
|
- 当前普通浏览器登录页由共享 `AuthLayout` 约束为最大宽度 460px,桌面视口仍使用单列卡片,因此用户明确反馈“过窄、像手机页面”。
|
||||||
|
- 登录页同时承载企业微信扫码入口、账号密码和邮箱验证码;现有企业微信扫码链路已经完成生产真实验收。
|
||||||
|
- `AuthLayout` 也被找回密码和修改密码页面复用,不能为了登录页变宽而无意改变全部认证页面。
|
||||||
|
- 现有移动端和企业微信 WebView 登录路径已有独立行为,本任务只处理普通 PC 浏览器的桌面布局表达。
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
|
||||||
|
- 普通 PC 浏览器 `/login` 的页面级宽版容器和响应式功能双栏。
|
||||||
|
- 企业微信扫码主入口、密码/邮箱验证码备用登录区的视觉层级与布局重组。
|
||||||
|
- 375px、768px、1024px、1440px 代表性视口和企业微信 WebView 的布局回归。
|
||||||
|
- 登录页聚焦 Playwright、截图复核和前端/项目治理门禁。
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
### R1 桌面布局
|
||||||
|
|
||||||
|
- 普通 PC 浏览器在桌面断点采用“左侧企业微信主入口、右侧备用登录表单”的功能双栏,使用更符合桌面操作的宽度、分区和留白,不能只把现有 460px 单列卡片机械拉宽。
|
||||||
|
- 登录方式的优先级必须清晰:企业微信扫码为日常首选,账号密码和邮箱验证码为可见、可用的回退方式。
|
||||||
|
- 表单控件保持适合阅读和输入的宽度,不因外层加宽而出现过长输入框。
|
||||||
|
- PC 扫码入口不可用时,页面应自然退回受控的单栏表单表达,不保留空白主入口栏。
|
||||||
|
|
||||||
|
### R2 响应式与共享页面边界
|
||||||
|
|
||||||
|
- 手机和窄屏继续使用现有单列登录体验,不出现横向滚动、截断或双栏挤压。
|
||||||
|
- 企业微信 WebView 继续优先展示一键进入及必要的密码回退,不套用普通 PC 扫码布局。
|
||||||
|
- 找回密码、修改密码等共享 `AuthLayout` 页面默认保持现状;如需调整共享容器,只能通过页面级布局能力显式启用。
|
||||||
|
|
||||||
|
### R3 认证行为零变更
|
||||||
|
|
||||||
|
- 不修改企业微信配置接口、扫码跳转、OAuth/state/cookie、回调、账号映射、会话、审计和生产开关。
|
||||||
|
- 不修改账号密码、邮箱验证码、找回密码、PWA 更新提示、安全 redirect 或设备指纹行为。
|
||||||
|
- 保留现有自动化依赖的登录控件语义和 `data-testid`;仅在视觉验收确有需要时增加布局测试标识。
|
||||||
|
|
||||||
|
### R4 视觉与可访问性
|
||||||
|
|
||||||
|
- 复用现有品牌、主题 token、`AuthPanel`、按钮、输入框和状态提示,不新建平行设计系统,不引入额外 UI 依赖。
|
||||||
|
- 保持可见标签、键盘焦点、足够对比度、状态提示语义和 `prefers-reduced-motion` 边界。
|
||||||
|
- 桌面布局至少覆盖 1024px 和 1440px;响应式回归至少覆盖 375px 和 768px。
|
||||||
|
|
||||||
|
## Acceptance Criteria
|
||||||
|
|
||||||
|
- [x] 1024px 与 1440px 普通浏览器中,登录页形成明确的桌面端布局,不再呈现居中的 460px 手机式窄卡片。
|
||||||
|
- [x] 企业微信扫码入口在桌面首屏具有清晰主入口地位,账号密码和邮箱验证码仍可直接找到并正常切换。
|
||||||
|
- [x] 375px 与 768px 视口保持单列、无横向滚动,现有输入、提示和按钮完整可用。
|
||||||
|
- [x] 企业微信 WebView 的一键进入、失败提示和账号密码回退布局及行为不回退。
|
||||||
|
- [x] 找回密码和修改密码页面未被登录页的桌面专属布局意外扩宽或改版。
|
||||||
|
- [x] 现有登录方式、returnTo、设备指纹、PWA 输入保持和扫码入口自动化回归通过。
|
||||||
|
- [x] 前端 typecheck、build、聚焦 Playwright、代表性视口截图、Trellis 治理检查和 `git diff --check` 通过。
|
||||||
|
- [x] 未经另行批准未修改生产配置或部署;当前仅能说明本地验证通过,尚未线上可测。
|
||||||
|
|
||||||
|
## Local Verification Evidence (2026-07-31)
|
||||||
|
|
||||||
|
- 1024px 与 1440px 截图确认桌面功能双栏、企业微信主入口和约 404px 备用表单列;375px 与 768px 截图确认单列、表单先于企业入口且无横向滚动。
|
||||||
|
- 聚焦 Playwright 共 19 项通过,覆盖扫码跳转参数、企微 WebView、密码/邮箱验证码、找回密码、PWA 输入保持、扫码关闭回退及四档视口布局。
|
||||||
|
- `npm run build` 通过,Vite 转换 2383 个模块,PWA 生成 102 个预缓存条目。
|
||||||
|
- task validate、流程合同、文档注册审计、Trellis 治理和 `git diff --check` 通过;文档审计保留 22 个未注册 docs 文件的既有 warning,本任务未新增文档。
|
||||||
|
- 未修改服务端、认证接口、企微配置、生产配置或业务数据,未执行部署和公网检查。
|
||||||
|
|
||||||
|
## Out of Scope
|
||||||
|
|
||||||
|
- 认证协议、服务端接口、企业微信后台配置、生产功能开关和账号映射规则。
|
||||||
|
- 在 OA 页面内嵌企业微信二维码、引入企微 SDK/script/iframe 或重做扫码流程。
|
||||||
|
- 找回密码、验证码失效提示、首次改密和全员账号回退体验收口。
|
||||||
|
- 移动端或企业微信 WebView 的视觉重构。
|
||||||
|
- 新增营销式欢迎页、功能宣传、轮播、客户背书或无实际作用的装饰内容。
|
||||||
|
|
||||||
|
## Key Decision
|
||||||
|
|
||||||
|
- 用户已确认:普通 PC 浏览器在桌面断点采用功能双栏,左侧突出企业微信扫码入口,右侧承载账号密码与邮箱验证码回退;窄屏和企业微信 WebView 不采用该双栏。
|
||||||
|
|
||||||
|
## Test Plan
|
||||||
|
|
||||||
|
- Playwright 覆盖 1024px/1440px 双栏,375px/768px 单栏,扫码关闭单栏和企业微信 WebView 单栏,并断言实际布局边界与无横向滚动。
|
||||||
|
- 回归企业微信扫码入口的 `entrySource`、`returnTo` 和设备指纹,密码/邮箱验证码切换、找回密码入口及 PWA 输入保持。
|
||||||
|
- 生成桌面与移动代表性截图,人工复核信息层级、表单宽度、间距、对比度和焦点状态。
|
||||||
|
- 执行 `cd client && npm run typecheck && npm run build`、聚焦 Playwright、Trellis task validate、流程/文档/治理检查及 `git diff --check`。
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"id": "pc-login-desktop-layout",
|
||||||
|
"name": "pc-login-desktop-layout",
|
||||||
|
"title": "PC 登录页桌面布局优化",
|
||||||
|
"description": "优化普通 PC 浏览器登录页的桌面布局,保持既有认证与回调链路不变。",
|
||||||
|
"status": "in_progress",
|
||||||
|
"dev_type": null,
|
||||||
|
"scope": "client 登录页桌面响应式布局、共享认证布局的页面级 variant、聚焦前端回归测试",
|
||||||
|
"package": null,
|
||||||
|
"priority": "P2",
|
||||||
|
"creator": "shunli",
|
||||||
|
"assignee": "shunli",
|
||||||
|
"createdAt": "2026-07-30",
|
||||||
|
"completedAt": null,
|
||||||
|
"branch": null,
|
||||||
|
"base_branch": "main",
|
||||||
|
"worktree_path": null,
|
||||||
|
"commit": null,
|
||||||
|
"pr_url": null,
|
||||||
|
"subtasks": [],
|
||||||
|
"children": [],
|
||||||
|
"parent": null,
|
||||||
|
"relatedFiles": [
|
||||||
|
"client/src/layouts/AuthLayout.tsx",
|
||||||
|
"client/src/router/index.tsx",
|
||||||
|
"client/src/pages/LoginPage.tsx",
|
||||||
|
"client/src/index.css",
|
||||||
|
"client/tests/e2e/wecom-entry.spec.ts",
|
||||||
|
"client/tests/e2e/login-portal-ux.spec.ts"
|
||||||
|
],
|
||||||
|
"notes": "本地实现与验证完成:PC 登录页桌面双栏、窄屏/企微单栏、扫码关闭回退均通过;未部署,尚未线上可测。",
|
||||||
|
"meta": {}
|
||||||
|
}
|
||||||
@@ -1,9 +1,15 @@
|
|||||||
import { Outlet } from "react-router-dom";
|
import { Outlet } from "react-router-dom";
|
||||||
import { Button } from "../components/ui/button";
|
import { Button } from "../components/ui/button";
|
||||||
import { usePwaUpdatePrompt } from "../hooks/usePwaUpdatePrompt";
|
import { usePwaUpdatePrompt } from "../hooks/usePwaUpdatePrompt";
|
||||||
|
import { cn } from "../lib/utils";
|
||||||
|
|
||||||
export function AuthLayout() {
|
type AuthLayoutProps = {
|
||||||
|
variant?: "default" | "login";
|
||||||
|
};
|
||||||
|
|
||||||
|
export function AuthLayout({ variant = "default" }: AuthLayoutProps) {
|
||||||
const { updateReady, applyUpdate, dismissUpdate } = usePwaUpdatePrompt();
|
const { updateReady, applyUpdate, dismissUpdate } = usePwaUpdatePrompt();
|
||||||
|
const isLoginLayout = variant === "login";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="auth-shell relative min-h-screen overflow-hidden px-4 py-8 sm:px-6 lg:px-10">
|
<div className="auth-shell relative min-h-screen overflow-hidden px-4 py-8 sm:px-6 lg:px-10">
|
||||||
@@ -11,8 +17,23 @@ export function AuthLayout() {
|
|||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
className="auth-shell__grid pointer-events-none absolute inset-0"
|
className="auth-shell__grid pointer-events-none absolute inset-0"
|
||||||
/>
|
/>
|
||||||
<div aria-hidden="true" className="auth-shell__rail pointer-events-none absolute inset-y-8 left-[max(1rem,calc((100vw-520px)/2-88px))] hidden w-px lg:block" />
|
<div
|
||||||
<div className="relative mx-auto flex min-h-[calc(100vh-4rem)] max-w-[460px] flex-col justify-center">
|
aria-hidden="true"
|
||||||
|
className={cn(
|
||||||
|
"auth-shell__rail pointer-events-none absolute inset-y-8 hidden w-px lg:block",
|
||||||
|
isLoginLayout
|
||||||
|
? "left-[max(1rem,calc((100vw-960px)/2-48px))]"
|
||||||
|
: "left-[max(1rem,calc((100vw-520px)/2-88px))]",
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
"relative mx-auto flex min-h-[calc(100vh-4rem)] flex-col justify-center",
|
||||||
|
isLoginLayout ? "max-w-[460px] lg:max-w-[920px]" : "max-w-[460px]",
|
||||||
|
)}
|
||||||
|
data-layout-variant={variant}
|
||||||
|
data-testid="auth-layout-container"
|
||||||
|
>
|
||||||
{updateReady ? (
|
{updateReady ? (
|
||||||
<div className="mb-4 rounded-lg border border-primary/20 bg-white/95 px-4 py-3 text-sm text-slate-700 shadow-sm" data-testid="auth-pwa-update-notice">
|
<div className="mb-4 rounded-lg border border-primary/20 bg-white/95 px-4 py-3 text-sm text-slate-700 shadow-sm" data-testid="auth-pwa-update-notice">
|
||||||
<div className="font-medium text-slate-900">系统有新版本</div>
|
<div className="font-medium text-slate-900">系统有新版本</div>
|
||||||
|
|||||||
+130
-79
@@ -233,6 +233,78 @@ export function LoginPage() {
|
|||||||
setEmailCodeMessage("");
|
setEmailCodeMessage("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function renderBrowserEnterprisePanel() {
|
||||||
|
if (!pcWecomEntry && !showBrowserWecomNotice && !oidcProvider) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<section
|
||||||
|
className={pcWecomEntry
|
||||||
|
? "order-2 space-y-3 lg:order-1 lg:flex lg:min-h-[320px] lg:flex-col lg:justify-center lg:border-r lg:border-slate-200 lg:pr-8"
|
||||||
|
: "space-y-3"}
|
||||||
|
data-testid="login-enterprise-panel"
|
||||||
|
>
|
||||||
|
<div className={pcWecomEntry ? "lg:hidden" : ""}>
|
||||||
|
<div className="flex items-center gap-3 text-xs text-slate-400">
|
||||||
|
<span className="h-px flex-1 bg-slate-100" />
|
||||||
|
<span>企业入口</span>
|
||||||
|
<span className="h-px flex-1 bg-slate-100" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{pcWecomEntry ? (
|
||||||
|
<div className="hidden lg:block">
|
||||||
|
<div className="flex h-11 w-11 items-center justify-center rounded-xl bg-primary/10 text-primary">
|
||||||
|
<Building2 aria-hidden="true" className="h-5 w-5" />
|
||||||
|
</div>
|
||||||
|
<h2 className="mt-5 text-lg font-semibold text-slate-950">企业微信登录</h2>
|
||||||
|
<p className="mt-2 text-sm leading-6 text-slate-600">
|
||||||
|
前往企业微信官方登录页,使用手机企业微信扫码后进入 OA 工作台。
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
{pcWecomEntry ? (
|
||||||
|
<Button
|
||||||
|
className="w-full lg:h-12 lg:border-transparent lg:bg-[var(--color-accent-primary)] lg:text-white lg:hover:border-transparent lg:hover:bg-[var(--color-accent-primary-hover)]"
|
||||||
|
data-testid="wecom-entry-pc"
|
||||||
|
type="button"
|
||||||
|
variant="secondary"
|
||||||
|
onClick={handlePcWecomLogin}
|
||||||
|
>
|
||||||
|
<Building2 aria-hidden="true" className="mr-2 hidden h-4 w-4 lg:block" />
|
||||||
|
企业微信扫码登录
|
||||||
|
</Button>
|
||||||
|
) : showBrowserWecomNotice ? (
|
||||||
|
<div
|
||||||
|
className="auth-side-entry flex gap-3 text-slate-600"
|
||||||
|
data-testid="wecom-entry-browser-notice"
|
||||||
|
>
|
||||||
|
<Building2 aria-hidden="true" className="mt-0.5 h-4 w-4 flex-none text-primary" />
|
||||||
|
<div>
|
||||||
|
<div className="font-medium text-slate-900">企业微信一键进入</div>
|
||||||
|
<div>请从企业微信工作台打开 OA;普通浏览器使用密码或邮箱验证码。</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
{oidcProvider ? (
|
||||||
|
<Button
|
||||||
|
className="w-full"
|
||||||
|
type="button"
|
||||||
|
variant="secondary"
|
||||||
|
onClick={() => {
|
||||||
|
window.location.assign(`${oidcProvider.loginUrl}?returnTo=${encodeURIComponent(redirectTo)}`);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
使用{oidcProvider.label}
|
||||||
|
</Button>
|
||||||
|
) : null}
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function renderPasswordPanel(testId: string) {
|
function renderPasswordPanel(testId: string) {
|
||||||
return (
|
return (
|
||||||
<div data-testid={testId}>
|
<div data-testid={testId}>
|
||||||
@@ -376,16 +448,13 @@ export function LoginPage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AuthPanel title="海音达 OA" subtitle={showWecomPrimary ? "企业微信环境优先免登" : "选择一种方式进入工作台"}>
|
<AuthPanel
|
||||||
|
className={pcWecomEntry ? "lg:p-8" : "lg:mx-auto lg:max-w-[460px]"}
|
||||||
|
data-testid="login-auth-panel"
|
||||||
|
title="海音达 OA"
|
||||||
|
subtitle={showWecomPrimary ? "企业微信环境优先免登" : "选择一种方式进入工作台"}
|
||||||
|
>
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
{!showWecomPrimary ? (
|
|
||||||
<div className="ux-command-note">
|
|
||||||
{pcWecomEntry
|
|
||||||
? "可使用企业微信扫码登录;企业邮箱验证码和账号密码作为备用方式。"
|
|
||||||
: "员工日常建议用企业邮箱验证码;固定办公电脑可使用账号密码。企业微信免登需要从企业微信工作台打开。"}
|
|
||||||
</div>
|
|
||||||
) : null}
|
|
||||||
|
|
||||||
{wecomNotice ? (
|
{wecomNotice ? (
|
||||||
<div className={`rounded-lg border px-3.5 py-2.5 text-sm ${noticeClasses(wecomNotice.tone)}`} data-testid="login-wecom-notice">
|
<div className={`rounded-lg border px-3.5 py-2.5 text-sm ${noticeClasses(wecomNotice.tone)}`} data-testid="login-wecom-notice">
|
||||||
<div className="font-medium">{wecomNotice.title}</div>
|
<div className="font-medium">{wecomNotice.title}</div>
|
||||||
@@ -415,80 +484,62 @@ export function LoginPage() {
|
|||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{!showWecomPrimary ? (
|
{showWecomPrimary ? (
|
||||||
<div className="auth-mode-switch" data-testid="login-mode-switch">
|
showPasswordPanel ? renderPasswordPanel("login-password-secondary-panel") : null
|
||||||
<button
|
) : (
|
||||||
aria-pressed={loginMode === "password"}
|
<div
|
||||||
className={`auth-mode-switch__item ${loginMode === "password" ? "auth-mode-switch__item--active" : "auth-mode-switch__item--idle"}`}
|
className={pcWecomEntry
|
||||||
data-testid="login-mode-password"
|
? "flex flex-col gap-5 lg:grid lg:grid-cols-[minmax(0,1fr)_minmax(360px,404px)] lg:gap-8"
|
||||||
type="button"
|
: "mx-auto max-w-[404px] space-y-4"}
|
||||||
onClick={() => selectLoginMode("password")}
|
data-layout={pcWecomEntry ? "desktop-split" : "single-column"}
|
||||||
|
data-testid="login-browser-layout"
|
||||||
|
>
|
||||||
|
<section
|
||||||
|
className={pcWecomEntry ? "order-1 space-y-4 lg:order-2" : "space-y-4"}
|
||||||
|
data-testid="login-fallback-panel"
|
||||||
>
|
>
|
||||||
账号密码
|
<div className="ux-command-note lg:hidden">
|
||||||
</button>
|
{pcWecomEntry
|
||||||
<button
|
? "可使用企业微信扫码登录;企业邮箱验证码和账号密码作为备用方式。"
|
||||||
aria-pressed={loginMode === "email_code"}
|
: "员工日常建议用企业邮箱验证码;固定办公电脑可使用账号密码。企业微信免登需要从企业微信工作台打开。"}
|
||||||
className={`auth-mode-switch__item ${loginMode === "email_code" ? "auth-mode-switch__item--active" : "auth-mode-switch__item--idle"}`}
|
|
||||||
data-testid="login-mode-email-code"
|
|
||||||
type="button"
|
|
||||||
onClick={() => selectLoginMode("email_code")}
|
|
||||||
>
|
|
||||||
邮箱验证码
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
) : null}
|
|
||||||
|
|
||||||
{showPasswordPanel
|
|
||||||
? !showWecomPrimary && loginMode === "email_code"
|
|
||||||
? renderEmailCodePanel("login-email-code-panel")
|
|
||||||
: renderPasswordPanel(showWecomPrimary ? "login-password-secondary-panel" : "login-password-primary-panel")
|
|
||||||
: null}
|
|
||||||
|
|
||||||
{!showWecomPrimary && (pcWecomEntry || showBrowserWecomNotice || oidcProvider) ? (
|
|
||||||
<div className="space-y-3">
|
|
||||||
<div className="flex items-center gap-3 text-xs text-slate-400">
|
|
||||||
<span className="h-px flex-1 bg-slate-100" />
|
|
||||||
<span>企业入口</span>
|
|
||||||
<span className="h-px flex-1 bg-slate-100" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{pcWecomEntry ? (
|
|
||||||
<Button
|
|
||||||
className="w-full"
|
|
||||||
data-testid="wecom-entry-pc"
|
|
||||||
type="button"
|
|
||||||
variant="secondary"
|
|
||||||
onClick={handlePcWecomLogin}
|
|
||||||
>
|
|
||||||
企业微信扫码登录
|
|
||||||
</Button>
|
|
||||||
) : showBrowserWecomNotice ? (
|
|
||||||
<div
|
|
||||||
className="auth-side-entry flex gap-3 text-slate-600"
|
|
||||||
data-testid="wecom-entry-browser-notice"
|
|
||||||
>
|
|
||||||
<Building2 aria-hidden="true" className="mt-0.5 h-4 w-4 flex-none text-primary" />
|
|
||||||
<div>
|
|
||||||
<div className="font-medium text-slate-900">企业微信一键进入</div>
|
|
||||||
<div>请从企业微信工作台打开 OA;普通浏览器使用密码或邮箱验证码。</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
|
||||||
|
|
||||||
{oidcProvider ? (
|
{pcWecomEntry ? (
|
||||||
<Button
|
<div className="hidden lg:block">
|
||||||
className="w-full"
|
<h2 className="text-base font-semibold text-slate-950">备用登录</h2>
|
||||||
type="button"
|
<p className="mt-1 text-sm leading-6 text-slate-500">使用账号密码或企业邮箱验证码。</p>
|
||||||
variant="secondary"
|
</div>
|
||||||
onClick={() => {
|
) : null}
|
||||||
window.location.assign(`${oidcProvider.loginUrl}?returnTo=${encodeURIComponent(redirectTo)}`);
|
|
||||||
}}
|
<div className="auth-mode-switch" data-testid="login-mode-switch">
|
||||||
>
|
<button
|
||||||
使用{oidcProvider.label}
|
aria-pressed={loginMode === "password"}
|
||||||
</Button>
|
className={`auth-mode-switch__item ${loginMode === "password" ? "auth-mode-switch__item--active" : "auth-mode-switch__item--idle"}`}
|
||||||
) : null}
|
data-testid="login-mode-password"
|
||||||
|
type="button"
|
||||||
|
onClick={() => selectLoginMode("password")}
|
||||||
|
>
|
||||||
|
账号密码
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
aria-pressed={loginMode === "email_code"}
|
||||||
|
className={`auth-mode-switch__item ${loginMode === "email_code" ? "auth-mode-switch__item--active" : "auth-mode-switch__item--idle"}`}
|
||||||
|
data-testid="login-mode-email-code"
|
||||||
|
type="button"
|
||||||
|
onClick={() => selectLoginMode("email_code")}
|
||||||
|
>
|
||||||
|
邮箱验证码
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{loginMode === "email_code"
|
||||||
|
? renderEmailCodePanel("login-email-code-panel")
|
||||||
|
: renderPasswordPanel("login-password-primary-panel")}
|
||||||
|
</section>
|
||||||
|
|
||||||
|
{renderBrowserEnterprisePanel()}
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</AuthPanel>
|
</AuthPanel>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ const routeElements = (
|
|||||||
path="/login"
|
path="/login"
|
||||||
element={
|
element={
|
||||||
<GuestOnly>
|
<GuestOnly>
|
||||||
<AuthLayout />
|
<AuthLayout variant="login" />
|
||||||
</GuestOnly>
|
</GuestOnly>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -386,6 +386,10 @@ test("登录页提供找回密码、密码显隐,PWA 更新不会清空正在
|
|||||||
|
|
||||||
await page.getByRole("link", { name: "忘记密码?" }).click();
|
await page.getByRole("link", { name: "忘记密码?" }).click();
|
||||||
await expect(page).toHaveURL(/\/forgot-password$/);
|
await expect(page).toHaveURL(/\/forgot-password$/);
|
||||||
|
await expect(page.getByTestId("auth-layout-container")).toHaveAttribute("data-layout-variant", "default");
|
||||||
|
const forgotPasswordLayoutBox = await page.getByTestId("auth-layout-container").boundingBox();
|
||||||
|
expect(forgotPasswordLayoutBox).not.toBeNull();
|
||||||
|
expect(forgotPasswordLayoutBox!.width).toBeLessThanOrEqual(460);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("邮箱验证码登录可发送验证码并进入工作台", async ({ page }) => {
|
test("邮箱验证码登录可发送验证码并进入工作台", async ({ page }) => {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { expect, test } from "@playwright/test";
|
import { expect, test } from "@playwright/test";
|
||||||
|
|
||||||
function mockWecomConfigPayload() {
|
function mockWecomConfigPayload(overrides: Record<string, unknown> = {}) {
|
||||||
return {
|
return {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
entryEnabled: true,
|
entryEnabled: true,
|
||||||
@@ -14,6 +14,7 @@ function mockWecomConfigPayload() {
|
|||||||
defaultReturnTo: "/mobile",
|
defaultReturnTo: "/mobile",
|
||||||
status: "ready",
|
status: "ready",
|
||||||
statusReasons: [],
|
statusReasons: [],
|
||||||
|
...overrides,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,12 +46,12 @@ async function mockAuthBase(page: import("@playwright/test").Page) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function mockWecomConfig(page: import("@playwright/test").Page) {
|
async function mockWecomConfig(page: import("@playwright/test").Page, overrides: Record<string, unknown> = {}) {
|
||||||
await page.route("**/api/auth/wecom/config", async (route) => {
|
await page.route("**/api/auth/wecom/config", async (route) => {
|
||||||
await route.fulfill({
|
await route.fulfill({
|
||||||
status: 200,
|
status: 200,
|
||||||
contentType: "application/json",
|
contentType: "application/json",
|
||||||
body: JSON.stringify(envelope(mockWecomConfigPayload())),
|
body: JSON.stringify(envelope(mockWecomConfigPayload(overrides))),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -75,6 +76,7 @@ test("E2E 企微入口:普通浏览器显示托管扫码入口并保留安全
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("E2E 企微入口:企业微信场景优先显示企微 CTA,并展示映射缺失提示", async ({ page }) => {
|
test("E2E 企微入口:企业微信场景优先显示企微 CTA,并展示映射缺失提示", async ({ page }) => {
|
||||||
|
await page.setViewportSize({ width: 1440, height: 960 });
|
||||||
await page.addInitScript(() => {
|
await page.addInitScript(() => {
|
||||||
Object.defineProperty(window.navigator, "userAgent", {
|
Object.defineProperty(window.navigator, "userAgent", {
|
||||||
configurable: true,
|
configurable: true,
|
||||||
@@ -98,4 +100,106 @@ test("E2E 企微入口:企业微信场景优先显示企微 CTA,并展示映
|
|||||||
await expect(page.getByTestId("login-wecom-notice")).toContainText("企业微信账号映射尚未完成");
|
await expect(page.getByTestId("login-wecom-notice")).toContainText("企业微信账号映射尚未完成");
|
||||||
await expect(page.getByTestId("login-wecom-notice")).not.toContainText("账号密码登录");
|
await expect(page.getByTestId("login-wecom-notice")).not.toContainText("账号密码登录");
|
||||||
await expect(page.getByTestId("login-password-secondary-panel")).toBeVisible();
|
await expect(page.getByTestId("login-password-secondary-panel")).toBeVisible();
|
||||||
|
await expect(page.getByTestId("login-browser-layout")).toHaveCount(0);
|
||||||
|
const panelBox = await page.getByTestId("login-auth-panel").boundingBox();
|
||||||
|
expect(panelBox).not.toBeNull();
|
||||||
|
expect(panelBox!.width).toBeLessThanOrEqual(460);
|
||||||
|
});
|
||||||
|
|
||||||
|
for (const viewport of [
|
||||||
|
{ width: 1024, height: 768 },
|
||||||
|
{ width: 1440, height: 960 },
|
||||||
|
]) {
|
||||||
|
test(`PC 登录布局:${viewport.width}px 使用企业微信与备用登录功能双栏`, async ({ page }) => {
|
||||||
|
await page.setViewportSize(viewport);
|
||||||
|
await mockAuthBase(page);
|
||||||
|
await mockWecomConfig(page);
|
||||||
|
|
||||||
|
await page.goto("/login");
|
||||||
|
|
||||||
|
const layout = page.getByTestId("auth-layout-container");
|
||||||
|
const browserLayout = page.getByTestId("login-browser-layout");
|
||||||
|
const enterprise = page.getByTestId("login-enterprise-panel");
|
||||||
|
const fallback = page.getByTestId("login-fallback-panel");
|
||||||
|
|
||||||
|
await expect(layout).toHaveAttribute("data-layout-variant", "login");
|
||||||
|
await expect(browserLayout).toHaveAttribute("data-layout", "desktop-split");
|
||||||
|
|
||||||
|
const [layoutBox, enterpriseBox, fallbackBox] = await Promise.all([
|
||||||
|
layout.boundingBox(),
|
||||||
|
enterprise.boundingBox(),
|
||||||
|
fallback.boundingBox(),
|
||||||
|
]);
|
||||||
|
expect(layoutBox).not.toBeNull();
|
||||||
|
expect(enterpriseBox).not.toBeNull();
|
||||||
|
expect(fallbackBox).not.toBeNull();
|
||||||
|
expect(layoutBox!.width).toBeGreaterThanOrEqual(880);
|
||||||
|
expect(enterpriseBox!.x).toBeLessThan(fallbackBox!.x);
|
||||||
|
expect(enterpriseBox!.width).toBeGreaterThan(280);
|
||||||
|
expect(fallbackBox!.width).toBeGreaterThan(340);
|
||||||
|
expect(fallbackBox!.width).toBeLessThan(440);
|
||||||
|
expect(Math.abs(enterpriseBox!.y - fallbackBox!.y)).toBeLessThan(2);
|
||||||
|
await expect(page.getByRole("heading", { name: "企业微信登录" })).toBeVisible();
|
||||||
|
await expect(page.getByRole("heading", { name: "备用登录" })).toBeVisible();
|
||||||
|
if (process.env.PC_LOGIN_LAYOUT_SCREENSHOTS === "1") {
|
||||||
|
await page.screenshot({
|
||||||
|
fullPage: true,
|
||||||
|
path: `../output/playwright/pc-login-${viewport.width}.png`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const viewport of [
|
||||||
|
{ width: 375, height: 812 },
|
||||||
|
{ width: 768, height: 900 },
|
||||||
|
]) {
|
||||||
|
test(`窄屏登录布局:${viewport.width}px 保持单列且表单先于企业入口`, async ({ page }) => {
|
||||||
|
await page.setViewportSize(viewport);
|
||||||
|
await mockAuthBase(page);
|
||||||
|
await mockWecomConfig(page);
|
||||||
|
|
||||||
|
await page.goto("/login");
|
||||||
|
|
||||||
|
const layoutBox = await page.getByTestId("auth-layout-container").boundingBox();
|
||||||
|
const enterpriseBox = await page.getByTestId("login-enterprise-panel").boundingBox();
|
||||||
|
const fallbackBox = await page.getByTestId("login-fallback-panel").boundingBox();
|
||||||
|
expect(layoutBox).not.toBeNull();
|
||||||
|
expect(enterpriseBox).not.toBeNull();
|
||||||
|
expect(fallbackBox).not.toBeNull();
|
||||||
|
expect(layoutBox!.width).toBeLessThanOrEqual(460);
|
||||||
|
expect(fallbackBox!.y).toBeLessThan(enterpriseBox!.y);
|
||||||
|
expect(await page.evaluate(() => document.documentElement.scrollWidth)).toBeLessThanOrEqual(viewport.width);
|
||||||
|
await expect(page.getByRole("heading", { name: "企业微信登录" })).toBeHidden();
|
||||||
|
await expect(page.getByRole("heading", { name: "备用登录" })).toBeHidden();
|
||||||
|
if (process.env.PC_LOGIN_LAYOUT_SCREENSHOTS === "1") {
|
||||||
|
await page.screenshot({
|
||||||
|
fullPage: true,
|
||||||
|
path: `../output/playwright/pc-login-${viewport.width}.png`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
test("PC 登录布局:扫码配置关闭时回退为受控单栏", async ({ page }) => {
|
||||||
|
await page.setViewportSize({ width: 1440, height: 960 });
|
||||||
|
await mockAuthBase(page);
|
||||||
|
await mockWecomConfig(page, {
|
||||||
|
pcWebLoginEnabled: false,
|
||||||
|
pcLoginUrl: null,
|
||||||
|
});
|
||||||
|
|
||||||
|
await page.goto("/login");
|
||||||
|
|
||||||
|
await expect(page.getByTestId("login-browser-layout")).toHaveAttribute("data-layout", "single-column");
|
||||||
|
await expect(page.getByTestId("wecom-entry-pc")).toHaveCount(0);
|
||||||
|
await expect(page.getByTestId("wecom-entry-browser-notice")).toBeVisible();
|
||||||
|
const panelBox = await page.getByTestId("login-auth-panel").boundingBox();
|
||||||
|
const fallbackBox = await page.getByTestId("login-fallback-panel").boundingBox();
|
||||||
|
const enterpriseBox = await page.getByTestId("login-enterprise-panel").boundingBox();
|
||||||
|
expect(panelBox).not.toBeNull();
|
||||||
|
expect(fallbackBox).not.toBeNull();
|
||||||
|
expect(enterpriseBox).not.toBeNull();
|
||||||
|
expect(panelBox!.width).toBeLessThanOrEqual(460);
|
||||||
|
expect(fallbackBox!.y).toBeLessThan(enterpriseBox!.y);
|
||||||
});
|
});
|
||||||
|
|||||||
在新工单中引用
屏蔽一个用户