Commit 0b898d58 by 胡悦

feat(ui): 完成三项OpenSpec规范落地与UI优化

- 落地独立页面页头操作规范:将返回按钮从左侧移至右侧操作区,左侧仅保留页面标题与说明,更新全局与项目级OpenSpec、架构文档、相关页面测试与实现
- 优化搜索过滤器组件:修改按钮文案为“查询”,调整按钮顺序为查询、重置、展开/收起,改为流式响应式布局,支持最多两行默认展示与自然换行适配
- 调整方法论配置页步骤倒序展示,保持后端数据提交的正序契约
- 新增对应三项OpenSpec变更的归档文件、设计文档与验证脚本
1 parent 839d179b
Showing 28 changed files with 555 additions and 213 deletions
...@@ -160,9 +160,10 @@ ...@@ -160,9 +160,10 @@
新增、编辑等独立页面的页头操作区 SHALL 统一遵循: 新增、编辑等独立页面的页头操作区 SHALL 统一遵循:
- 左侧展示 `返回`、页面标题和必要说明。 - 左侧只展示页面标题和必要说明,不展示页面级按钮。
- 右侧只展示主操作 `保存`,不再提供 `取消` 按钮。 - 右侧统一展示 `返回` 与其他页面级操作;`返回` 位于右侧操作区左端,主操作(如 `保存`)位于右侧操作区右端。
- 离开当前独立页面由左侧 `返回` 承载。 - 不再提供 `取消` 按钮。
- 离开当前独立页面由右侧操作区的 `返回` 承载。
- 页头在内容滚动容器内使用 sticky 固定;滚动表单内容时,`返回` 和 `保存` 始终保持可见。 - 页头在内容滚动容器内使用 sticky 固定;滚动表单内容时,`返回` 和 `保存` 始终保持可见。
- sticky 页头必须具备不透明背景、边框和合理层级,避免表单内容穿透或覆盖页头。 - sticky 页头必须具备不透明背景、边框和合理层级,避免表单内容穿透或覆盖页头。
......
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
导出默认放在表格工具栏右侧,表达对当前结果集的处理。若同时支持导出筛选结果和导出选中项,使用下拉菜单区分。批量操作默认放在表格工具栏左侧,并在已选择数据时展示 `已选择 N 项`。 导出默认放在表格工具栏右侧,表达对当前结果集的处理。若同时支持导出筛选结果和导出选中项,使用下拉菜单区分。批量操作默认放在表格工具栏左侧,并在已选择数据时展示 `已选择 N 项`。
新增、编辑等独立页面的页头左侧展示 `返回`、页面标题和必要说明,右侧只展示主操作 `保存`,不展示 `取消`。页面内容滚动时,页头操作区必须在内容滚动容器内 sticky 固定,确保 `返回` 和 `保存` 始终可见;sticky 页头需要有不透明背景、边框和合理层级,避免内容穿透。 新增、编辑等独立页面的页头左侧只展示页面标题和必要说明,右侧统一展示 `返回` 与其他页面级操作;右侧操作区内 `返回` 位于左端,主操作(如 `保存`)位于右端,不展示 `取消`。页面内容滚动时,页头操作区必须在内容滚动容器内 sticky 固定,确保 `返回` 和 `保存` 始终可见;sticky 页头需要有不透明背景、边框和合理层级,避免内容穿透。
后台管理页面要保持信息密度和可扫读性。避免营销式首屏、装饰性卡片和过大的标题字号。 后台管理页面要保持信息密度和可扫读性。避免营销式首屏、装饰性卡片和过大的标题字号。
......
...@@ -67,18 +67,27 @@ ...@@ -67,18 +67,27 @@
- **AND** 如已有旧数据,刷新期间优先保留旧数据,避免列表内容跳空 - **AND** 如已有旧数据,刷新期间优先保留旧数据,避免列表内容跳空
### Requirement: 独立新增编辑页必须固定页头操作区 ### Requirement: 独立新增编辑页必须固定页头操作区
后台新增、编辑等独立页面 SHALL 在页面内容区顶部提供统一页头操作区。页头左侧承载 `返回`、标题和说明,右侧只承载主操作 `保存`;页面滚动时页头必须在内容滚动容器内保持可见。 后台新增、编辑、配置等独立页面 SHALL 在页面内容区顶部提供统一页头操作区。页头左侧只承载页面标题、说明和状态摘要等页面识别信息;页头右侧 MUST 承载 `返回` 和其他页面级操作按钮。页面滚动时页头必须在内容滚动容器内保持可见。
#### Scenario: 渲染独立新增编辑页 #### Scenario: 渲染独立新增编辑页
- **WHEN** 前端项目实现新增、编辑等独立页面 - **WHEN** 前端项目实现新增、编辑、配置等独立页面
- **THEN** 页头左侧展示 `返回` 和页面标题 - **THEN** 页头左侧展示页面标题和必要说明
- **AND** 页头右侧展示 `保存` - **AND** 页头左侧不展示 `返回` 或其他按钮
- **AND** 页头右侧展示 `返回`
- **AND** 页头右侧展示 `保存` 等主操作
- **AND** 页头右侧不展示 `取消` - **AND** 页头右侧不展示 `取消`
#### Scenario: 排列右侧页面级操作
- **WHEN** 独立页面同时提供 `返回`、主操作和其他页面级操作
- **THEN** `返回` 位于右侧操作区内靠左位置
- **AND** 主操作位于右侧操作区内靠右位置
- **AND** 其他次级页面级操作位于 `返回` 和主操作之间,或收敛到更多操作菜单
#### Scenario: 滚动独立新增编辑页 #### Scenario: 滚动独立新增编辑页
- **WHEN** 用户滚动独立页面中的表单或配置内容 - **WHEN** 用户滚动独立页面中的表单或配置内容
- **THEN** `返回` 和 `保存` 所在页头操作区保持在屏幕可见区域 - **THEN** `返回` 和 `保存` 等页面级操作所在页头操作区保持在屏幕可见区域
- **AND** sticky 页头具备不透明背景、边框和合理层级,避免内容滚动时穿透或覆盖页头 - **AND** sticky 页头具备不透明背景、边框和合理层级,避免内容滚动时穿透或覆盖页头
- **AND** 页头右侧操作区不得被页面标题或说明挤压到不可见
### Requirement: 后台管理系统表格必须默认使用 BusinessTable ### Requirement: 后台管理系统表格必须默认使用 BusinessTable
......
.root { .root {
display: grid; min-width: 0;
gap: var(--gl-spacing-md);
} }
.viewport { .viewport {
max-width: 100%;
overflow: hidden; overflow: hidden;
transition: max-height 240ms ease; transition: max-height 240ms ease;
} }
...@@ -13,18 +13,24 @@ ...@@ -13,18 +13,24 @@
flex-wrap: wrap; flex-wrap: wrap;
gap: var(--gl-spacing-md) var(--gl-spacing-lg); gap: var(--gl-spacing-md) var(--gl-spacing-lg);
align-items: flex-start; align-items: flex-start;
width: 100%;
max-width: 100%;
min-width: 0;
overflow-x: hidden;
} }
.item { .item {
display: flex; display: flex;
width: var(--gl-search-item-width, 284px); order: var(--search-filter-order, 0);
flex: 0 1 var(--gl-search-item-width, 284px);
max-width: 100%;
min-width: 0; min-width: 0;
align-items: center; align-items: center;
gap: var(--gl-spacing-sm); gap: var(--gl-spacing-sm);
} }
.itemWide { .itemWide {
width: var(--gl-search-item-wide-width, 484px); flex-basis: var(--gl-search-item-wide-width, 484px);
} }
.label { .label {
...@@ -38,13 +44,13 @@ ...@@ -38,13 +44,13 @@
} }
.control { .control {
width: var(--gl-search-control-width, 200px); width: 100%;
min-width: 0; min-width: 0;
} }
.inputLabel { .inputLabel {
display: block; display: block;
width: var(--gl-search-control-width, 200px); flex: 1 1 auto;
min-width: 0; min-width: 0;
} }
...@@ -61,23 +67,44 @@ ...@@ -61,23 +67,44 @@
} }
.controlWide { .controlWide {
width: var(--gl-search-control-wide-width, 400px); width: 100%;
min-width: 0;
} }
.footer { .actions {
display: flex; display: flex;
order: var(--search-filter-order, 0);
flex: 0 0 auto;
align-items: center; align-items: center;
justify-content: flex-end;
gap: var(--gl-spacing-sm); gap: var(--gl-spacing-sm);
max-width: 100%;
white-space: nowrap;
}
.collapsedBreak {
order: var(--search-filter-order, 2);
flex: 0 0 100%;
width: 100%;
height: 0;
} }
.toggleButton { .toggleButton {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
}
.toggleContent {
display: inline-flex;
align-items: center;
gap: var(--gl-spacing-xs); gap: var(--gl-spacing-xs);
line-height: 1;
} }
.toggleIcon { .toggleIcon {
display: block;
width: 1em;
height: 1em;
flex: 0 0 auto;
transition: transform 240ms ease; transition: transform 240ms ease;
} }
......
import { useEffect, useLayoutEffect, useMemo, useRef, useState, type ReactNode } from 'react'; import { useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type ReactNode } from 'react';
import { Button, DatePicker, DateRangePicker, Input, Select } from 'tdesign-react'; import { Button, DatePicker, DateRangePicker, Input, Select } from 'tdesign-react';
import { ChevronDownIcon, RefreshIcon, SearchIcon } from 'tdesign-icons-react'; import { ChevronDownIcon, RefreshIcon, SearchIcon } from 'tdesign-icons-react';
...@@ -99,6 +99,70 @@ function buildInitialValues(fields: SearchFilterField[]) { ...@@ -99,6 +99,70 @@ function buildInitialValues(fields: SearchFilterField[]) {
}, {}); }, {});
} }
const MIN_ROW_HEIGHT = 44;
const MAX_COLLAPSED_ROWS = 2;
const FALLBACK_CONTAINER_WIDTH = 920;
interface SearchFilterLayout {
collapsedHeight: number;
expandedHeight: number;
showToggle: boolean;
visibleFieldCount: number;
}
function parsePixelValue(value: string | undefined) {
const parsed = Number.parseFloat(value ?? '');
return Number.isFinite(parsed) ? parsed : 0;
}
function getElementWidth(element: HTMLElement | null, fallback: number) {
if (!element) return fallback;
return element.offsetWidth || element.getBoundingClientRect().width || fallback;
}
function countWrappedRows(widths: number[], containerWidth: number, columnGap: number) {
if (widths.length === 0) return 0;
if (containerWidth <= 0) return 1;
let rows = 1;
let currentRowWidth = 0;
widths.forEach((width) => {
const itemWidth = Math.min(width, containerWidth);
const nextWidth = currentRowWidth === 0 ? itemWidth : currentRowWidth + columnGap + itemWidth;
if (currentRowWidth > 0 && nextWidth > containerWidth) {
rows += 1;
currentRowWidth = itemWidth;
return;
}
currentRowWidth = nextWidth;
});
return rows;
}
function getVisibleFieldCount(fieldWidths: number[], actionsWidth: number, containerWidth: number, columnGap: number) {
let visibleCount = 0;
for (let index = 0; index <= fieldWidths.length; index += 1) {
const rows = countWrappedRows([...fieldWidths.slice(0, index), actionsWidth], containerWidth, columnGap);
if (rows <= MAX_COLLAPSED_ROWS) {
visibleCount = index;
} else {
break;
}
}
return visibleCount;
}
function getRowsHeight(rowCount: number, rowGap: number) {
if (rowCount <= 0) return MIN_ROW_HEIGHT;
return rowCount * MIN_ROW_HEIGHT + Math.max(rowCount - 1, 0) * rowGap;
}
function SearchFieldControl({ function SearchFieldControl({
field, field,
value, value,
...@@ -182,8 +246,14 @@ export function SearchFilter({ fields, className, 'data-testid': dataTestId, onR ...@@ -182,8 +246,14 @@ export function SearchFilter({ fields, className, 'data-testid': dataTestId, onR
const [innerValues, setInnerValues] = useState<SearchFilterValues>(() => buildInitialValues(fields)); const [innerValues, setInnerValues] = useState<SearchFilterValues>(() => buildInitialValues(fields));
const [expanded, setExpanded] = useState(false); const [expanded, setExpanded] = useState(false);
const viewportRef = useRef<HTMLDivElement>(null); const viewportRef = useRef<HTMLDivElement>(null);
const [viewportHeight, setViewportHeight] = useState(44); const flowRef = useRef<HTMLDivElement>(null);
const [collapsedHeight, setCollapsedHeight] = useState(44); const actionsRef = useRef<HTMLDivElement>(null);
const [layout, setLayout] = useState<SearchFilterLayout>({
collapsedHeight: MIN_ROW_HEIGHT,
expandedHeight: MIN_ROW_HEIGHT,
showToggle: false,
visibleFieldCount: fields.length,
});
const fieldSignature = useMemo( const fieldSignature = useMemo(
() => fields.map((field) => `${field.key}:${field.type}:${field.type === 'datePicker' && field.range ? 'range' : 'single'}`).join('|'), () => fields.map((field) => `${field.key}:${field.type}:${field.type === 'datePicker' && field.range ? 'range' : 'single'}`).join('|'),
[fields], [fields],
...@@ -203,17 +273,58 @@ export function SearchFilter({ fields, className, 'data-testid': dataTestId, onR ...@@ -203,17 +273,58 @@ export function SearchFilter({ fields, className, 'data-testid': dataTestId, onR
}, [fieldSignature]); }, [fieldSignature]);
useLayoutEffect(() => { useLayoutEffect(() => {
const updateHeight = () => { const updateLayout = () => {
const viewport = viewportRef.current; const viewport = viewportRef.current;
if (!viewport) return; const flow = flowRef.current;
const firstItem = viewport.querySelector('[data-field-key]') as HTMLElement | null; const actions = actionsRef.current;
setCollapsedHeight(Math.max(firstItem?.getBoundingClientRect().height ?? 44, 44)); if (!viewport || !flow || !actions) return;
setViewportHeight(viewport.scrollHeight);
const computedStyle = window.getComputedStyle(flow);
const columnGap = parsePixelValue(computedStyle.columnGap);
const rowGap = parsePixelValue(computedStyle.rowGap);
const containerWidth = flow.clientWidth || flow.getBoundingClientRect().width || FALLBACK_CONTAINER_WIDTH;
const fieldElements = Array.from(flow.querySelectorAll<HTMLElement>('[data-field-key]'));
const fieldWidths = fieldElements.map((element) => getElementWidth(element, 284));
const actionsWidth = getElementWidth(actions, 220);
const completeRows = countWrappedRows([...fieldWidths, actionsWidth], containerWidth, columnGap);
const showToggle = completeRows > MAX_COLLAPSED_ROWS;
const visibleFieldCount = showToggle
? getVisibleFieldCount(fieldWidths, actionsWidth, containerWidth, columnGap)
: fields.length;
const expandedHeight = Math.max(flow.scrollHeight, getRowsHeight(completeRows, rowGap));
const collapsedRows = showToggle ? MAX_COLLAPSED_ROWS : Math.max(completeRows, 1);
const collapsedHeight = Math.min(expandedHeight, getRowsHeight(collapsedRows, rowGap));
setLayout((current) => {
const next = { collapsedHeight, expandedHeight, showToggle, visibleFieldCount };
if (
current.collapsedHeight === next.collapsedHeight
&& current.expandedHeight === next.expandedHeight
&& current.showToggle === next.showToggle
&& current.visibleFieldCount === next.visibleFieldCount
) {
return current;
}
return next;
});
}; };
updateHeight(); updateLayout();
window.addEventListener('resize', updateHeight);
return () => window.removeEventListener('resize', updateHeight); const resizeObserver = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(updateLayout);
}, [expanded, fieldSignature]); if (resizeObserver) {
resizeObserver.observe(flowRef.current as Element);
}
window.addEventListener('resize', updateLayout);
return () => {
resizeObserver?.disconnect();
window.removeEventListener('resize', updateLayout);
};
}, [fieldSignature, fields.length, layout.showToggle]);
useEffect(() => {
if (!layout.showToggle && expanded) setExpanded(false);
}, [expanded, layout.showToggle]);
const values = fields.reduce<SearchFilterValues>((current, field) => { const values = fields.reduce<SearchFilterValues>((current, field) => {
current[field.key] = isControlledField(field) ? normalizeFieldValue(field, field.value) : innerValues[field.key]; current[field.key] = isControlledField(field) ? normalizeFieldValue(field, field.value) : innerValues[field.key];
...@@ -234,16 +345,23 @@ export function SearchFilter({ fields, className, 'data-testid': dataTestId, onR ...@@ -234,16 +345,23 @@ export function SearchFilter({ fields, className, 'data-testid': dataTestId, onR
fields.forEach((field) => field.onChange?.(nextValues[field.key] as never)); fields.forEach((field) => field.onChange?.(nextValues[field.key] as never));
onReset?.(); onReset?.();
}; };
const showToggle = fields.reduce((count, field) => count + (field.type === 'datePicker' && field.range ? 2 : 1), 0) > 3; const shouldFold = layout.showToggle && !expanded;
const viewportMaxHeight = expanded ? layout.expandedHeight : layout.collapsedHeight;
return ( return (
<div className={classNames(styles.root, className)} data-testid={dataTestId}> <div className={classNames(styles.root, className)} data-testid={dataTestId} role="search" aria-label="搜索过滤条件">
<div ref={viewportRef} className={styles.viewport} style={{ maxHeight: expanded ? viewportHeight : collapsedHeight }}> <div ref={viewportRef} className={styles.viewport} style={{ maxHeight: viewportMaxHeight }}>
<div className={styles.fields}> <div ref={flowRef} className={styles.fields} data-search-filter-flow="true">
{fields.map((field) => { {fields.map((field, index) => {
const isWide = field.type === 'datePicker' && field.range; const isWide = field.type === 'datePicker' && field.range;
const order = shouldFold && index >= layout.visibleFieldCount ? 3 : 0;
return ( return (
<div key={field.key} className={classNames(styles.item, isWide && styles.itemWide)} data-field-key={field.key}> <div
key={field.key}
className={classNames(styles.item, isWide && styles.itemWide)}
data-field-key={field.key}
style={{ '--search-filter-order': order } as CSSProperties}
>
<span className={styles.label} title={field.label}>{field.label}</span> <span className={styles.label} title={field.label}>{field.label}</span>
<SearchFieldControl <SearchFieldControl
field={field} field={field}
...@@ -254,17 +372,25 @@ export function SearchFilter({ fields, className, 'data-testid': dataTestId, onR ...@@ -254,17 +372,25 @@ export function SearchFilter({ fields, className, 'data-testid': dataTestId, onR
</div> </div>
); );
})} })}
</div> <div
</div> ref={actionsRef}
<div className={styles.footer}> className={styles.actions}
{showToggle ? ( data-search-filter-actions="true"
style={{ '--search-filter-order': shouldFold ? 1 : 0 } as CSSProperties}
>
<Button className={styles.actionButton} icon={<SearchIcon />} theme="primary" onClick={handleSearch}>查询</Button>
<Button className={styles.actionButton} icon={<RefreshIcon />} variant="outline" onClick={handleReset}>重置</Button>
{layout.showToggle ? (
<Button className={styles.toggleButton} variant="text" onClick={() => setExpanded((value) => !value)}> <Button className={styles.toggleButton} variant="text" onClick={() => setExpanded((value) => !value)}>
{expanded ? '收起' : '展开'} <span className={styles.toggleContent}>
<span>{expanded ? '收起' : '展开'}</span>
<ChevronDownIcon className={classNames(styles.toggleIcon, expanded && styles.toggleIconExpanded)} /> <ChevronDownIcon className={classNames(styles.toggleIcon, expanded && styles.toggleIconExpanded)} />
</span>
</Button> </Button>
) : null} ) : null}
<Button className={styles.actionButton} icon={<RefreshIcon />} variant="outline" onClick={handleReset}>重置</Button> </div>
<Button className={styles.actionButton} icon={<SearchIcon />} theme="primary" onClick={handleSearch}>搜索</Button> {shouldFold ? <div className={styles.collapsedBreak} style={{ '--search-filter-order': 2 } as CSSProperties} /> : null}
</div>
</div> </div>
</div> </div>
); );
......
...@@ -97,17 +97,26 @@ TBD - created by archiving change add-admin-login-agent-list-mock. Update Purpos ...@@ -97,17 +97,26 @@ TBD - created by archiving change add-admin-login-agent-list-mock. Update Purpos
- **AND** 点击二级菜单面包屑项返回该二级菜单页面 - **AND** 点击二级菜单面包屑项返回该二级菜单页面
### Requirement: 独立页面页头操作区 ### Requirement: 独立页面页头操作区
岗位 Agent 管理后台 SHALL 为新增、编辑等独立页面提供一致且滚动可见的页头操作区。 岗位 Agent 管理后台 SHALL 为新增、编辑、配置等独立页面提供一致且滚动可见的页头操作区。页头左侧只展示页面标题、说明和状态摘要等页面识别信息;页头右侧 MUST 展示 `返回` 和其他页面级操作按钮。
#### Scenario: 独立页面不展示右侧取消按钮 #### Scenario: 独立页面右侧集中展示操作按钮
- **WHEN** 已登录用户打开新增或编辑等独立页面 - **WHEN** 已登录用户打开新增、编辑、配置等独立页面
- **THEN** 独立页面页头左侧展示 `返回` 入口 - **THEN** 独立页面页头左侧展示页面标题和必要说明
- **AND** 独立页面页头右侧展示 `保存` 主操作 - **AND** 独立页面页头左侧不展示 `返回` 入口或其他按钮
- **AND** 独立页面页头右侧展示 `返回` 入口
- **AND** 独立页面页头右侧展示 `保存` 等主操作
- **AND** 独立页面页头右侧不展示 `取消` 按钮 - **AND** 独立页面页头右侧不展示 `取消` 按钮
#### Scenario: 右侧操作区按钮排序
- **WHEN** 独立页面页头右侧同时存在 `返回`、主操作和其他页面级操作
- **THEN** `返回` 位于右侧操作区内靠左位置
- **AND** 主操作位于右侧操作区内靠右位置
- **AND** 其他次级页面级操作位于 `返回` 和主操作之间,或收敛到更多操作菜单
#### Scenario: 滚动时保持页头操作区可见 #### Scenario: 滚动时保持页头操作区可见
- **WHEN** 已登录用户在新增或编辑等独立页面向下滚动表单内容 - **WHEN** 已登录用户在新增、编辑、配置等独立页面向下滚动表单内容
- **THEN** 独立页面页头操作区保持在内容滚动容器顶部可见 - **THEN** 独立页面页头操作区保持在内容滚动容器顶部可见
- **AND** `返回` 和 `保存` 入口保持可点击 - **AND** `返回` 和 `保存` 等页面级操作入口保持可点击
- **AND** 滚动内容不得覆盖页头操作区 - **AND** 滚动内容不得覆盖页头操作区
- **AND** 页头右侧操作区不得被页面标题或说明挤压到不可见
...@@ -78,42 +78,35 @@ TBD - created by archiving change global-search-filter-component. Update Purpose ...@@ -78,42 +78,35 @@ TBD - created by archiving change global-search-filter-component. Update Purpose
- **WHEN** 组件渲染 `range: true` 的日期字段 - **WHEN** 组件渲染 `range: true` 的日期字段
- **THEN** 范围日期字段占据两个普通搜索项的横向空间 - **THEN** 范围日期字段占据两个普通搜索项的横向空间
### Requirement: 操作按钮固定在右下角
系统 SHALL 在搜索区域右下角固定展示搜索与重置按钮,并 SHALL 保证搜索与重置按钮不被折叠隐藏。
#### Scenario: 折叠状态展示操作按钮
- **WHEN** 搜索字段数量超过默认展示区域且组件处于折叠状态
- **THEN** 搜索与重置按钮仍展示在搜索区域右下角
#### Scenario: 展开状态展示操作按钮
- **WHEN** 用户展开搜索区域
- **THEN** 搜索与重置按钮仍展示在搜索区域右下角
#### Scenario: 触发搜索和重置回调
- **WHEN** 用户点击搜索或重置按钮
- **THEN** 组件分别调用传入的搜索或重置回调
### Requirement: 最多两行默认展示 ### Requirement: 最多两行默认展示
系统 SHALL 默认最多展示两行搜索区域内容,且 SHALL 将操作按钮所在区域计入两行展示高度。 系统 SHALL 默认最多展示两行搜索区域内容,且 SHALL 将操作按钮所在区域计入两行展示高度。
#### Scenario: 字段未超过两行 #### Scenario: 字段在一行内完整展示
- **WHEN** 字段数量在默认两行内可完整展示 - **WHEN** 搜索字段与操作按钮在一行内可完整展示
- **THEN** 组件不展示展开/收起按钮 - **THEN** 组件展示一行内容
- **AND** 组件不展示展开/收起按钮
#### Scenario: 字段在两行内完整展示
- **WHEN** 搜索字段与操作按钮在两行内可完整展示
- **THEN** 组件展示两行内容
- **AND** 组件不展示展开/收起按钮
#### Scenario: 字段超过两行 #### Scenario: 字段超过两行
- **WHEN** 字段数量超过默认两行可展示范围 - **WHEN** 搜索字段与操作按钮超过默认两行可展示范围
- **THEN** 组件折叠状态仅展示前两行范围内内容,并展示展开按钮 - **THEN** 组件折叠状态仅展示前两行范围内内容
- **AND** 组件展示展开按钮
### Requirement: 展开收起交互 ### Requirement: 展开收起交互
系统 SHALL 在字段超过默认展示区域时提供展开/收起文字按钮,按钮 SHALL 位于搜索与重置按钮左侧,并 SHALL 使用文字与箭头表达当前操作。 系统 SHALL 在搜索字段与操作按钮超过默认两行展示区域时提供展开/收起文字按钮,按钮 SHALL 位于查询与重置按钮之后,并 SHALL 使用文字与箭头表达当前操作。
#### Scenario: 折叠状态展示展开按钮 #### Scenario: 折叠状态展示展开按钮
- **WHEN** 组件处于折叠状态且存在溢出字段 - **WHEN** 组件处于折叠状态且存在第三行及后续被隐藏内容
- **THEN** 操作区在搜索与重置按钮左侧展示“展开”文字按钮和向下箭头 - **THEN** 操作按钮组在查询与重置按钮之后展示“展开”文字按钮和向下箭头
#### Scenario: 展开状态展示收起按钮 #### Scenario: 展开状态展示收起按钮
- **WHEN** 用户点击展开按钮后 - **WHEN** 用户点击展开按钮后
- **THEN** 组件展示全部搜索字段,并在搜索与重置按钮左侧展示“收起”文字按钮和向上箭头 - **THEN** 组件展示全部搜索字段
- **AND** 操作按钮组在查询与重置按钮之后展示“收起”文字按钮和向上箭头
#### Scenario: 展开收起具有动画 #### Scenario: 展开收起具有动画
- **WHEN** 用户切换展开或收起状态 - **WHEN** 用户切换展开或收起状态
...@@ -170,3 +163,49 @@ TBD - created by archiving change global-search-filter-component. Update Purpose ...@@ -170,3 +163,49 @@ TBD - created by archiving change global-search-filter-component. Update Purpose
- **WHEN** 用户在迁移后的任一列表页点击重置 - **WHEN** 用户在迁移后的任一列表页点击重置
- **THEN** 页面清空对应筛选条件并按原查询参数语义刷新列表 - **THEN** 页面清空对应筛选条件并按原查询参数语义刷新列表
### Requirement: 操作按钮跟随搜索条件
系统 SHALL 将 `SearchFilter` 的查询、重置和展开/收起按钮作为搜索条件布局的一部分展示,并 SHALL 让操作按钮跟随在当前可见查询条件之后。
#### Scenario: 默认态展示操作按钮
- **WHEN** 搜索字段内容超过默认两行展示区域且组件处于默认折叠状态
- **THEN** 组件在默认可见区域内展示查询、重置和展开按钮
- **AND** 查询按钮位于最后一个可见查询条件之后
#### Scenario: 展开态展示操作按钮
- **WHEN** 用户展开搜索区域
- **THEN** 组件展示全部搜索字段
- **AND** 查询、重置和收起按钮跟随在最后一个搜索条件之后
#### Scenario: 触发查询和重置回调
- **WHEN** 用户点击查询或重置按钮
- **THEN** 组件分别调用传入的搜索或重置回调
### Requirement: 操作按钮顺序
系统 SHALL 按“查询、重置、展开/收起”的顺序展示 `SearchFilter` 操作按钮。
#### Scenario: 展示查询和重置按钮
- **WHEN** 组件渲染搜索区域
- **THEN** 操作按钮组先展示“查询”按钮
- **AND** 随后展示“重置”按钮
#### Scenario: 展示展开按钮
- **WHEN** 组件处于默认折叠状态且存在第三行及后续被隐藏内容
- **THEN** “展开”按钮展示在“查询”和“重置”按钮之后
#### Scenario: 展示收起按钮
- **WHEN** 用户展开搜索区域
- **THEN** “收起”按钮展示在“查询”和“重置”按钮之后
### Requirement: 响应式自然换行
系统 SHALL 在 `SearchFilter` 容器宽度变化时重新布局搜索条件与操作按钮,并 MUST 通过自然换行适配窄容器,且 MUST NOT 出现横向滚动条。
#### Scenario: 容器变窄
- **WHEN** `SearchFilter` 容器宽度不足以在一行展示原有数量的搜索条件
- **THEN** 搜索条件和操作按钮按容器宽度自然换行
- **AND** 搜索区不出现横向滚动条
#### Scenario: 容器宽度变化后重新判断折叠
- **WHEN** `SearchFilter` 容器宽度变化导致内容行数变化
- **THEN** 组件重新判断是否存在第三行及后续内容
- **AND** 组件按新的布局结果展示或隐藏展开/收起按钮
...@@ -91,20 +91,6 @@ ...@@ -91,20 +91,6 @@
- **THEN** 系统 SHALL 将其作为该步骤的展示图标资源保存到配置数据 - **THEN** 系统 SHALL 将其作为该步骤的展示图标资源保存到配置数据
- **AND** 系统 SHALL NOT 将上传进度、上传中、重试等临时状态保存为步骤图标数据 - **AND** 系统 SHALL NOT 将上传进度、上传中、重试等临时状态保存为步骤图标数据
#### Scenario: 步骤图标上传辅助提示
- **WHEN** 用户查看方法论步骤的步骤图标上传区域
- **THEN** 系统 SHALL 展示步骤图标格式与大小限制提示
- **AND** 系统 SHALL 使用与 `BusinessForm` 帮助文案一致的普通 tips 样式展示该提示
- **AND** 即使步骤配置区使用页面自定义布局,系统 SHALL 按表单字段提示规范在步骤图标字段附近展示该提示
- **AND** 当步骤图标出现必填、格式、大小或上传错误时,系统 SHALL 在字段附近使用与 `BusinessForm` 错误文案一致的红色错误文字展示错误提示
#### Scenario: 步骤名称长度限制
- **WHEN** 用户在步骤名称输入框输入或粘贴超过 20 字内容
- **THEN** 系统 SHALL 将步骤名称字段值立即限制在 20 字以内
- **AND** 系统 SHALL NOT 在字段值超过 20 字后等待提交时才展示超长错误
- **AND** 系统 SHALL 继续展示步骤名称字数计数
- **AND** 系统 SHALL 保持步骤名称必填保存校验不变
### Requirement: 内容图上传校验 ### Requirement: 内容图上传校验
系统 SHALL 对每个步骤的内容图执行前端 mock 上传和校验。 系统 SHALL 对每个步骤的内容图执行前端 mock 上传和校验。
...@@ -128,13 +114,6 @@ ...@@ -128,13 +114,6 @@
- **THEN** 系统 SHALL 展示图片上传失败状态 - **THEN** 系统 SHALL 展示图片上传失败状态
- **AND** 系统 SHALL 允许用户重新选择或重试 - **AND** 系统 SHALL 允许用户重新选择或重试
#### Scenario: 内容图上传辅助提示
- **WHEN** 用户查看方法论步骤的内容图上传区域
- **THEN** 系统 SHALL 展示内容图格式与大小限制提示
- **AND** 系统 SHALL 使用与 `BusinessForm` 帮助文案一致的普通 tips 样式展示该提示
- **AND** 即使步骤配置区使用页面自定义布局,系统 SHALL 按表单字段提示规范在内容图字段附近展示该提示
- **AND** 当内容图出现必填、格式、大小或上传错误时,系统 SHALL 在字段附近使用与 `BusinessForm` 错误文案一致的红色错误文字展示错误提示
### Requirement: 页面状态与保存行为 ### Requirement: 页面状态与保存行为
系统 SHALL 覆盖方法论展示配置页的加载、保存和错误状态。 系统 SHALL 覆盖方法论展示配置页的加载、保存和错误状态。
...@@ -184,14 +163,3 @@ ...@@ -184,14 +163,3 @@
- **WHEN** 测试读取方法论配置 mock fixture - **WHEN** 测试读取方法论配置 mock fixture
- **THEN** fixture SHALL 覆盖正常配置、关闭展示、步骤为空、图片上传失败、图片格式错误、图片过大、保存失败和加载失败 - **THEN** fixture SHALL 覆盖正常配置、关闭展示、步骤为空、图片上传失败、图片格式错误、图片过大、保存失败和加载失败
### Requirement: 页面滚动布局
系统 SHALL 在方法论展示配置页内保持 header 区域固定,并允许下方配置区域独立滚动。
#### Scenario: Header 固定且内容区滚动
- **WHEN** 用户打开 `/official-site/methodology` 方法论展示配置页
- **THEN** 系统 SHALL 将页面标题、说明和保存操作放置在固定 header 区域
- **AND** 系统 SHALL 将加载态、错误态、空态和步骤配置内容放置在 header 下方的独立滚动区域
- **AND** 当配置内容超过可视区域高度时,系统 SHALL 仅滚动 header 下方内容区域
- **AND** 系统 SHALL 保持保存操作在内容滚动过程中可见并可点击
- **AND** 系统 SHALL NOT 改变后台全局导航、侧边栏或其他页面的滚动布局
import { fireEvent, render, screen, waitFor } from '@testing-library/react'; import { fireEvent, render, screen, waitFor, within } from '@testing-library/react';
import { describe, expect, it, vi } from 'vitest'; import { afterEach, describe, expect, it, vi } from 'vitest';
import { MediaWall, SearchFilter, StatePlaceholder } from '@gl/business-components'; import { MediaWall, SearchFilter, StatePlaceholder } from '@gl/business-components';
const searchFields = [
{ key: 'keyword', label: '关键词', type: 'input' as const, defaultValue: '项目' },
{ key: 'count', label: '数量', type: 'numberInput' as const },
{ key: 'status', label: '状态', type: 'select' as const, options: [{ label: '启用', value: 'enabled' }] },
];
function mockSearchFilterLayout({ containerWidth, fieldWidth = 284, actionsWidth = 220 }: {
containerWidth: number;
fieldWidth?: number;
actionsWidth?: number;
}) {
const originalClientWidth = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'clientWidth');
const originalOffsetWidth = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'offsetWidth');
const originalScrollHeight = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'scrollHeight');
const originalGetComputedStyle = window.getComputedStyle;
Object.defineProperty(HTMLElement.prototype, 'clientWidth', {
configurable: true,
get() {
if ((this as HTMLElement).dataset.searchFilterFlow === 'true') return containerWidth;
return originalClientWidth?.get?.call(this) ?? 0;
},
});
Object.defineProperty(HTMLElement.prototype, 'offsetWidth', {
configurable: true,
get() {
const element = this as HTMLElement;
if (element.dataset.searchFilterActions === 'true') return actionsWidth;
if (element.dataset.fieldKey) return fieldWidth;
return originalOffsetWidth?.get?.call(this) ?? 0;
},
});
Object.defineProperty(HTMLElement.prototype, 'scrollHeight', {
configurable: true,
get() {
return 96;
},
});
window.getComputedStyle = ((element: Element) => {
const style = originalGetComputedStyle(element);
if ((element as HTMLElement).dataset.searchFilterFlow === 'true') {
return new Proxy(style, {
get(target, property, receiver) {
if (property === 'columnGap') return '16px';
if (property === 'rowGap') return '12px';
return Reflect.get(target, property, receiver);
},
});
}
return style;
}) as typeof window.getComputedStyle;
return () => {
if (originalClientWidth) Object.defineProperty(HTMLElement.prototype, 'clientWidth', originalClientWidth);
if (originalOffsetWidth) Object.defineProperty(HTMLElement.prototype, 'offsetWidth', originalOffsetWidth);
if (originalScrollHeight) Object.defineProperty(HTMLElement.prototype, 'scrollHeight', originalScrollHeight);
window.getComputedStyle = originalGetComputedStyle;
};
}
describe('global business components', () => { describe('global business components', () => {
afterEach(() => {
vi.restoreAllMocks();
});
it('keeps SearchFilter draft values until search and restores defaults on reset', () => { it('keeps SearchFilter draft values until search and restores defaults on reset', () => {
const onReset = vi.fn(); const onReset = vi.fn();
const onSearch = vi.fn(); const onSearch = vi.fn();
render( render(
<SearchFilter <SearchFilter
fields={[ fields={searchFields}
{ key: 'keyword', label: '关键词', type: 'input', defaultValue: '项目' },
{ key: 'count', label: '数量', type: 'numberInput' },
{ key: 'status', label: '状态', type: 'select', options: [{ label: '启用', value: 'enabled' }] },
]}
onReset={onReset} onReset={onReset}
onSearch={onSearch} onSearch={onSearch}
/>, />,
); );
fireEvent.change(screen.getByLabelText('数量'), { target: { value: '12a3' } }); fireEvent.change(screen.getByLabelText('数量'), { target: { value: '12a3' } });
fireEvent.click(screen.getByRole('button', { name: '搜索' })); fireEvent.click(screen.getByRole('button', { name: '查询' }));
expect(screen.getByLabelText('数量')).toHaveValue('123'); expect(screen.getByLabelText('数量')).toHaveValue('123');
expect(onSearch).toHaveBeenCalledWith({ keyword: '项目', count: '123', status: '' }); expect(onSearch).toHaveBeenCalledWith({ keyword: '项目', count: '123', status: '' });
...@@ -33,6 +96,67 @@ describe('global business components', () => { ...@@ -33,6 +96,67 @@ describe('global business components', () => {
expect(onReset).toHaveBeenCalledTimes(1); expect(onReset).toHaveBeenCalledTimes(1);
}); });
it('renders SearchFilter actions after fields in query, reset, expand order', async () => {
const restoreLayout = mockSearchFilterLayout({ containerWidth: 640, fieldWidth: 200, actionsWidth: 260 });
render(
<SearchFilter
fields={[
...searchFields,
{ key: 'owner', label: '负责人', type: 'input' },
{ key: 'department', label: '部门', type: 'input' },
]}
/>,
);
await waitFor(() => expect(screen.getByRole('button', { name: '展开' })).toBeInTheDocument());
const root = screen.getByLabelText('搜索过滤条件');
const controls = within(root).getAllByRole('button').map((button) => button.textContent?.trim());
expect(controls).toEqual(['查询', '重置', '展开']);
restoreLayout();
});
it('does not show expand or collapse when fields and actions fit in two rows', async () => {
const restoreLayout = mockSearchFilterLayout({ containerWidth: 920, fieldWidth: 200, actionsWidth: 220 });
render(
<SearchFilter
fields={[
...searchFields,
{ key: 'owner', label: '负责人', type: 'input' },
{ key: 'department', label: '部门', type: 'input' },
]}
/>,
);
await waitFor(() => expect(screen.queryByRole('button', { name: '展开' })).not.toBeInTheDocument());
expect(screen.queryByRole('button', { name: '收起' })).not.toBeInTheDocument();
restoreLayout();
});
it('only folds when the responsive layout needs more than two rows', async () => {
const restoreLayout = mockSearchFilterLayout({ containerWidth: 640, fieldWidth: 200, actionsWidth: 260 });
render(
<SearchFilter
fields={[
...searchFields,
{ key: 'owner', label: '负责人', type: 'input' },
{ key: 'department', label: '部门', type: 'input' },
]}
/>,
);
await waitFor(() => expect(screen.getByRole('button', { name: '展开' })).toBeInTheDocument());
fireEvent.click(screen.getByRole('button', { name: '展开' }));
expect(screen.getByRole('button', { name: '收起' })).toBeInTheDocument();
restoreLayout();
});
it('renders an empty range date field without TDesign value warnings', () => { it('renders an empty range date field without TDesign value warnings', () => {
const consoleError = vi.spyOn(console, 'error').mockImplementation(() => undefined); const consoleError = vi.spyOn(console, 'error').mockImplementation(() => undefined);
......
...@@ -163,17 +163,17 @@ export function AgentTagEditorPage({ mode }: { mode: 'create' | 'edit' }) { ...@@ -163,17 +163,17 @@ export function AgentTagEditorPage({ mode }: { mode: 'create' | 'edit' }) {
return ( return (
<section className="grid gap-6"> <section className="grid gap-6">
<header className="sticky top-0 z-10 flex items-center justify-between gap-6 rounded-[var(--gl-radius-md)] border border-[var(--gl-color-border-secondary)] bg-[var(--gl-color-bg-container)] px-8 py-6"> <header className="sticky top-0 z-10 flex items-start justify-between gap-6 rounded-[var(--gl-radius-md)] border border-[var(--gl-color-border-secondary)] bg-[var(--gl-color-bg-container)] px-8 py-6">
<div className="flex items-center gap-4"> <div aria-label="页面标题" className="min-w-0 flex-1">
<Button variant="outline" onClick={goBackToList}>返回</Button>
<div>
<h2 className="m-0 text-2xl leading-[var(--gl-line-height-xl)]">{mode === 'create' ? '新建岗位标签' : '编辑岗位标签'}</h2> <h2 className="m-0 text-2xl leading-[var(--gl-line-height-xl)]">{mode === 'create' ? '新建岗位标签' : '编辑岗位标签'}</h2>
<p className="m-0 mt-1 text-sm text-[var(--gl-color-text-secondary)]"> <p className="m-0 mt-1 text-sm text-[var(--gl-color-text-secondary)]">
{mode === 'create' ? '创建新的岗位标签' : '编辑已有岗位标签信息'} {mode === 'create' ? '创建新的岗位标签' : '编辑已有岗位标签信息'}
</p> </p>
</div> </div>
</div> <div aria-label="页面操作" className="flex shrink-0 items-center gap-2">
<Button variant="outline" onClick={goBackToList}>返回</Button>
<Button theme="primary" loading={saving} onClick={handleSave}>保存</Button> <Button theme="primary" loading={saving} onClick={handleSave}>保存</Button>
</div>
</header> </header>
{notice ? ( {notice ? (
......
...@@ -166,7 +166,7 @@ describe('Agent tag routes and list page', () => { ...@@ -166,7 +166,7 @@ describe('Agent tag routes and list page', () => {
expect(screen.getAllByText('标签名称').length).toBeGreaterThan(0); expect(screen.getAllByText('标签名称').length).toBeGreaterThan(0);
expect(screen.getByLabelText('标签名称')).toBeInTheDocument(); expect(screen.getByLabelText('标签名称')).toBeInTheDocument();
expect(screen.getByPlaceholderText('搜索标签名称')).toBeInTheDocument(); expect(screen.getByPlaceholderText('搜索标签名称')).toBeInTheDocument();
expect(screen.getByRole('button', { name: '搜索' })).toBeInTheDocument(); expect(screen.getByRole('button', { name: '查询' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '重置' })).toBeInTheDocument(); expect(screen.getByRole('button', { name: '重置' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '新建岗位标签' })).toBeInTheDocument(); expect(screen.getByRole('button', { name: '新建岗位标签' })).toBeInTheDocument();
expect(screen.getAllByText('标签名称').length).toBeGreaterThan(0); expect(screen.getAllByText('标签名称').length).toBeGreaterThan(0);
...@@ -184,7 +184,7 @@ describe('Agent tag routes and list page', () => { ...@@ -184,7 +184,7 @@ describe('Agent tag routes and list page', () => {
await screen.findByText('店销顾问'); await screen.findByText('店销顾问');
fireEvent.change(screen.getByLabelText('标签名称'), { target: { value: '售后' } }); fireEvent.change(screen.getByLabelText('标签名称'), { target: { value: '售后' } });
fireEvent.click(screen.getByRole('button', { name: '搜索' })); fireEvent.click(screen.getByRole('button', { name: '查询' }));
await waitFor(() => { await waitFor(() => {
expect(getPositionTagList).toHaveBeenLastCalledWith(expect.objectContaining({ keyword: '售后' })); expect(getPositionTagList).toHaveBeenLastCalledWith(expect.objectContaining({ keyword: '售后' }));
...@@ -280,9 +280,11 @@ describe('Agent tag create and edit pages', () => { ...@@ -280,9 +280,11 @@ describe('Agent tag create and edit pages', () => {
await screen.findByRole('heading', { name: '新建岗位标签' }); await screen.findByRole('heading', { name: '新建岗位标签' });
const pageHeader = screen.getByRole('heading', { name: '新建岗位标签' }).closest('header') as HTMLElement; const pageHeader = screen.getByRole('heading', { name: '新建岗位标签' }).closest('header') as HTMLElement;
expect(pageHeader).toHaveClass('sticky', 'top-0', 'z-10'); expect(pageHeader).toHaveClass('sticky', 'top-0', 'z-10');
expect(within(pageHeader).getByRole('button', { name: '返回' })).toBeInTheDocument(); expect(within(screen.getByLabelText('页面标题')).queryByRole('button')).not.toBeInTheDocument();
const pageActions = screen.getByLabelText('页面操作');
expect(within(pageActions).getByRole('button', { name: '返回' })).toBeInTheDocument();
expect(within(pageActions).getByRole('button', { name: '保存' })).toBeInTheDocument();
expect(within(pageHeader).queryByRole('button', { name: '取消' })).not.toBeInTheDocument(); expect(within(pageHeader).queryByRole('button', { name: '取消' })).not.toBeInTheDocument();
expect(within(pageHeader).getByRole('button', { name: '保存' })).toBeInTheDocument();
// Validate that only name is required (code is auto-generated by backend) // Validate that only name is required (code is auto-generated by backend)
fireEvent.click(screen.getByRole('button', { name: '保存' })); fireEvent.click(screen.getByRole('button', { name: '保存' }));
......
...@@ -178,11 +178,13 @@ describe('Agent editor routes and detail drawer', () => { ...@@ -178,11 +178,13 @@ describe('Agent editor routes and detail drawer', () => {
const pageHeader = screen.getByRole('heading', { name: '新建Agent' }).closest('header') as HTMLElement; const pageHeader = screen.getByRole('heading', { name: '新建Agent' }).closest('header') as HTMLElement;
expect(within(screen.getByLabelText('左侧导航')).getByText('Agent列表').closest('li')).toHaveClass('t-is-active'); expect(within(screen.getByLabelText('左侧导航')).getByText('Agent列表').closest('li')).toHaveClass('t-is-active');
expect(pageHeader).toHaveClass('sticky', 'top-0', 'z-10'); expect(pageHeader).toHaveClass('sticky', 'top-0', 'z-10');
expect(within(pageHeader).getByRole('button', { name: '返回' })).toBeInTheDocument(); expect(within(screen.getByLabelText('页面标题')).queryByRole('button')).not.toBeInTheDocument();
const pageActions = screen.getByLabelText('页面操作');
expect(within(pageActions).getByRole('button', { name: '返回' })).toBeInTheDocument();
expect(within(pageActions).getByRole('button', { name: '保存' })).toBeInTheDocument();
expect(within(pageHeader).queryByRole('button', { name: '取消' })).not.toBeInTheDocument(); expect(within(pageHeader).queryByRole('button', { name: '取消' })).not.toBeInTheDocument();
expect(within(pageHeader).getByRole('button', { name: '保存' })).toBeInTheDocument();
fireEvent.click(within(pageHeader).getByRole('button', { name: '返回' })); fireEvent.click(within(pageActions).getByRole('button', { name: '返回' }));
await waitFor(() => { await waitFor(() => {
expect(screen.getByRole('heading', { name: 'Agent管理' })).toBeInTheDocument(); expect(screen.getByRole('heading', { name: 'Agent管理' })).toBeInTheDocument();
......
...@@ -577,17 +577,17 @@ export function AgentEditorPage({ mode }: { mode: 'create' | 'edit' }) { ...@@ -577,17 +577,17 @@ export function AgentEditorPage({ mode }: { mode: 'create' | 'edit' }) {
return ( return (
<section className="grid gap-6"> <section className="grid gap-6">
<header className="sticky top-0 z-10 flex items-center justify-between gap-6 rounded-[var(--gl-radius-md)] border border-[var(--gl-color-border-secondary)] bg-[var(--gl-color-bg-container)] px-8 py-6"> <header className="sticky top-0 z-10 flex items-start justify-between gap-6 rounded-[var(--gl-radius-md)] border border-[var(--gl-color-border-secondary)] bg-[var(--gl-color-bg-container)] px-8 py-6">
<div className="flex items-center gap-4"> <div aria-label="页面标题" className="min-w-0 flex-1">
<Button variant="outline" onClick={() => goBackToList(Boolean(routeState.detail && mode === 'edit'))}>返回</Button>
<div>
<h2 className="m-0 text-2xl leading-[var(--gl-line-height-xl)]">{title}</h2> <h2 className="m-0 text-2xl leading-[var(--gl-line-height-xl)]">{title}</h2>
<p className="m-0 mt-1 text-sm text-[var(--gl-color-text-secondary)]"> <p className="m-0 mt-1 text-sm text-[var(--gl-color-text-secondary)]">
{mode === 'create' ? '创建新的岗位 Agent 配置' : '编辑已存在的 Agent 配置'} {mode === 'create' ? '创建新的岗位 Agent 配置' : '编辑已存在的 Agent 配置'}
</p> </p>
</div> </div>
</div> <div aria-label="页面操作" className="flex shrink-0 items-center gap-2">
<Button variant="outline" onClick={() => goBackToList(Boolean(routeState.detail && mode === 'edit'))}>返回</Button>
<Button theme="primary" loading={saveLoading} onClick={handleSave}>保存</Button> <Button theme="primary" loading={saveLoading} onClick={handleSave}>保存</Button>
</div>
</header> </header>
{saveError ? ( {saveError ? (
......
...@@ -120,7 +120,7 @@ describe('AgentListPage', () => { ...@@ -120,7 +120,7 @@ describe('AgentListPage', () => {
expect(screen.getByPlaceholderText('搜索Agent名称')).toBeInTheDocument(); expect(screen.getByPlaceholderText('搜索Agent名称')).toBeInTheDocument();
expect(screen.getByLabelText('所属岗位')).toBeInTheDocument(); expect(screen.getByLabelText('所属岗位')).toBeInTheDocument();
expect(screen.getByLabelText('状态')).toBeInTheDocument(); expect(screen.getByLabelText('状态')).toBeInTheDocument();
expect(screen.getByRole('button', { name: '搜索' })).toBeInTheDocument(); expect(screen.getByRole('button', { name: '查询' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '重置' })).toBeInTheDocument(); expect(screen.getByRole('button', { name: '重置' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '新建Agent' })).toBeInTheDocument(); expect(screen.getByRole('button', { name: '新建Agent' })).toBeInTheDocument();
...@@ -164,7 +164,7 @@ describe('AgentListPage', () => { ...@@ -164,7 +164,7 @@ describe('AgentListPage', () => {
expect(within(toolbar).getAllByText('Agent名称').length).toBeGreaterThan(0); expect(within(toolbar).getAllByText('Agent名称').length).toBeGreaterThan(0);
expect(within(toolbar).getAllByText('所属岗位').length).toBeGreaterThan(0); expect(within(toolbar).getAllByText('所属岗位').length).toBeGreaterThan(0);
expect(within(toolbar).getAllByText('状态').length).toBeGreaterThan(0); expect(within(toolbar).getAllByText('状态').length).toBeGreaterThan(0);
expect(within(toolbar).getByRole('button', { name: '搜索' })).toBeInTheDocument(); expect(within(toolbar).getByRole('button', { name: '查询' })).toBeInTheDocument();
expect(within(toolbar).getByRole('button', { name: '重置' })).toBeInTheDocument(); expect(within(toolbar).getByRole('button', { name: '重置' })).toBeInTheDocument();
}); });
...@@ -188,7 +188,7 @@ describe('AgentListPage', () => { ...@@ -188,7 +188,7 @@ describe('AgentListPage', () => {
expect(screen.getByText('复盘Agent')).toBeInTheDocument(); expect(screen.getByText('复盘Agent')).toBeInTheDocument();
}); });
fireEvent.click(screen.getByRole('button', { name: '搜索' })); fireEvent.click(screen.getByRole('button', { name: '查询' }));
// 搜索提交后,URL 参数更新,需要等待 API 返回新数据 // 搜索提交后,URL 参数更新,需要等待 API 返回新数据
await waitFor(() => { await waitFor(() => {
...@@ -225,7 +225,7 @@ describe('AgentListPage', () => { ...@@ -225,7 +225,7 @@ describe('AgentListPage', () => {
fireEvent.click(screen.getByLabelText('所属岗位')); fireEvent.click(screen.getByLabelText('所属岗位'));
expect(getSelectOption('全部')).toBeInTheDocument(); expect(getSelectOption('全部')).toBeInTheDocument();
fireEvent.click(getSelectOption('客服岗')); fireEvent.click(getSelectOption('客服岗'));
fireEvent.click(screen.getByRole('button', { name: '搜索' })); fireEvent.click(screen.getByRole('button', { name: '查询' }));
await waitFor(() => { await waitFor(() => {
expect(screen.queryByRole('button', { name: '清空所属岗位' })).not.toBeInTheDocument(); expect(screen.queryByRole('button', { name: '清空所属岗位' })).not.toBeInTheDocument();
...@@ -648,7 +648,7 @@ describe('AgentListPage', () => { ...@@ -648,7 +648,7 @@ describe('AgentListPage', () => {
fireEvent.change(screen.getByLabelText('Agent名称'), { target: { value: '复盘' } }); fireEvent.change(screen.getByLabelText('Agent名称'), { target: { value: '复盘' } });
vi.clearAllMocks(); vi.clearAllMocks();
fireEvent.click(screen.getByRole('button', { name: '搜索' })); fireEvent.click(screen.getByRole('button', { name: '查询' }));
await waitFor(() => { await waitFor(() => {
expect(reportAnalyticsEvents).toHaveBeenCalledWith([ expect(reportAnalyticsEvents).toHaveBeenCalledWith([
...@@ -668,7 +668,7 @@ describe('AgentListPage', () => { ...@@ -668,7 +668,7 @@ describe('AgentListPage', () => {
fireEvent.click(getSelectOption('客服岗')); fireEvent.click(getSelectOption('客服岗'));
vi.clearAllMocks(); vi.clearAllMocks();
fireEvent.click(screen.getByRole('button', { name: '搜索' })); fireEvent.click(screen.getByRole('button', { name: '查询' }));
await waitFor(() => { await waitFor(() => {
expect(reportAnalyticsEvents).toHaveBeenCalledWith([ expect(reportAnalyticsEvents).toHaveBeenCalledWith([
......
...@@ -225,9 +225,11 @@ describe('Channel code create page', () => { ...@@ -225,9 +225,11 @@ describe('Channel code create page', () => {
}); });
const pageHeader = screen.getByRole('heading', { name: '新增员工渠道活码' }).closest('header') as HTMLElement; const pageHeader = screen.getByRole('heading', { name: '新增员工渠道活码' }).closest('header') as HTMLElement;
expect(pageHeader).toHaveClass('sticky', 'top-0', 'z-10'); expect(pageHeader).toHaveClass('sticky', 'top-0', 'z-10');
expect(within(pageHeader).getByRole('button', { name: '返回' })).toBeInTheDocument(); expect(within(screen.getByLabelText('页面标题')).queryByRole('button')).not.toBeInTheDocument();
const pageActions = screen.getByLabelText('页面操作');
expect(within(pageActions).getByRole('button', { name: '返回' })).toBeInTheDocument();
expect(within(pageActions).getByRole('button', { name: '保存' })).toBeInTheDocument();
expect(within(pageHeader).queryByRole('button', { name: '取消' })).not.toBeInTheDocument(); expect(within(pageHeader).queryByRole('button', { name: '取消' })).not.toBeInTheDocument();
expect(within(pageHeader).getByRole('button', { name: '保存' })).toBeInTheDocument();
}); });
// Legacy test: status switch no longer rendered (updated to not check status) // Legacy test: status switch no longer rendered (updated to not check status)
......
...@@ -414,10 +414,8 @@ export function ChannelCodeEditorPage({ mode }: { mode: 'create' | 'edit' }) { ...@@ -414,10 +414,8 @@ export function ChannelCodeEditorPage({ mode }: { mode: 'create' | 'edit' }) {
return ( return (
<section className="grid gap-6"> <section className="grid gap-6">
<header className="sticky top-0 z-10 flex items-center justify-between gap-6 rounded-[var(--gl-radius-md)] border border-[var(--gl-color-border-secondary)] bg-[var(--gl-color-bg-container)] px-8 py-6"> <header className="sticky top-0 z-10 flex items-start justify-between gap-6 rounded-[var(--gl-radius-md)] border border-[var(--gl-color-border-secondary)] bg-[var(--gl-color-bg-container)] px-8 py-6">
<div className="flex items-center gap-4"> <div aria-label="页面标题" className="min-w-0 flex-1">
<Button variant="outline" onClick={goBackToList}>返回</Button>
<div>
<h2 className="m-0 text-2xl leading-[var(--gl-line-height-xl)]"> <h2 className="m-0 text-2xl leading-[var(--gl-line-height-xl)]">
{mode === 'create' ? '新增员工渠道活码' : '编辑员工渠道活码'} {mode === 'create' ? '新增员工渠道活码' : '编辑员工渠道活码'}
</h2> </h2>
...@@ -425,8 +423,10 @@ export function ChannelCodeEditorPage({ mode }: { mode: 'create' | 'edit' }) { ...@@ -425,8 +423,10 @@ export function ChannelCodeEditorPage({ mode }: { mode: 'create' | 'edit' }) {
{mode === 'create' ? '创建新的员工渠道活码' : '编辑已有员工渠道活码信息'} {mode === 'create' ? '创建新的员工渠道活码' : '编辑已有员工渠道活码信息'}
</p> </p>
</div> </div>
</div> <div aria-label="页面操作" className="flex shrink-0 items-center gap-2">
<Button variant="outline" onClick={goBackToList}>返回</Button>
<Button theme="primary" loading={saving} onClick={handleSave}>保存</Button> <Button theme="primary" loading={saving} onClick={handleSave}>保存</Button>
</div>
</header> </header>
{notice ? ( {notice ? (
......
...@@ -132,7 +132,7 @@ describe('Channel code list page', () => { ...@@ -132,7 +132,7 @@ describe('Channel code list page', () => {
expect(screen.getByLabelText('活码名称')).toBeInTheDocument(); expect(screen.getByLabelText('活码名称')).toBeInTheDocument();
expect(screen.getAllByText('状态').length).toBeGreaterThan(0); expect(screen.getAllByText('状态').length).toBeGreaterThan(0);
expect(screen.getByLabelText('状态')).toBeInTheDocument(); expect(screen.getByLabelText('状态')).toBeInTheDocument();
expect(screen.getByRole('button', { name: '搜索' })).toBeInTheDocument(); expect(screen.getByRole('button', { name: '查询' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '重置' })).toBeInTheDocument(); expect(screen.getByRole('button', { name: '重置' })).toBeInTheDocument();
expect(screen.getByPlaceholderText('搜索活码名称')).toBeInTheDocument(); expect(screen.getByPlaceholderText('搜索活码名称')).toBeInTheDocument();
}); });
...@@ -185,7 +185,7 @@ describe('Channel code list page', () => { ...@@ -185,7 +185,7 @@ describe('Channel code list page', () => {
page: 1, page: 1,
page_size: 10, page_size: 10,
}); });
fireEvent.click(screen.getByRole('button', { name: '搜索' })); fireEvent.click(screen.getByRole('button', { name: '查询' }));
await waitFor(() => { await waitFor(() => {
expect(screen.getByText('售后客服渠道活码')).toBeInTheDocument(); expect(screen.getByText('售后客服渠道活码')).toBeInTheDocument();
...@@ -227,7 +227,7 @@ describe('Channel code list page', () => { ...@@ -227,7 +227,7 @@ describe('Channel code list page', () => {
page: 1, page: 1,
page_size: 10, page_size: 10,
}); });
fireEvent.click(screen.getByRole('button', { name: '搜索' })); fireEvent.click(screen.getByRole('button', { name: '查询' }));
await waitFor(() => { await waitFor(() => {
expect(getChannelQRCodeList).toHaveBeenLastCalledWith(expect.objectContaining({ status: 'disable' })); expect(getChannelQRCodeList).toHaveBeenLastCalledWith(expect.objectContaining({ status: 'disable' }));
......
...@@ -53,7 +53,7 @@ describe('ComponentsDemoPage', () => { ...@@ -53,7 +53,7 @@ describe('ComponentsDemoPage', () => {
fireEvent.click(scoped.getByRole('button', { name: '展开' })); fireEvent.click(scoped.getByRole('button', { name: '展开' }));
expect(scoped.getByRole('button', { name: '收起' })).toBeInTheDocument(); expect(scoped.getByRole('button', { name: '收起' })).toBeInTheDocument();
fireEvent.click(scoped.getByRole('button', { name: '搜索' })); fireEvent.click(scoped.getByRole('button', { name: '查询' }));
expect(scoped.getByText(/"keyword": "智能审批"/)).toBeInTheDocument(); expect(scoped.getByText(/"keyword": "智能审批"/)).toBeInTheDocument();
fireEvent.click(scoped.getByRole('button', { name: '重置' })); fireEvent.click(scoped.getByRole('button', { name: '重置' }));
......
...@@ -73,12 +73,12 @@ export function OfficialSiteAgentDisplayConfigPage() { ...@@ -73,12 +73,12 @@ export function OfficialSiteAgentDisplayConfigPage() {
if (loading) { if (loading) {
return ( return (
<section className="grid gap-6"> <section className="grid gap-6">
<header className="flex items-center justify-between gap-6 rounded-[var(--gl-radius-md)] border border-[var(--gl-color-border-secondary)] bg-[var(--gl-color-bg-container)] px-8 py-6"> <header className="sticky top-0 z-10 flex items-start justify-between gap-6 rounded-[var(--gl-radius-md)] border border-[var(--gl-color-border-secondary)] bg-[var(--gl-color-bg-container)] px-8 py-6">
<div className="flex items-center gap-4"> <div aria-label="页面标题" className="min-w-0 flex-1">
<Button variant="outline" onClick={goBackToList}>返回</Button>
<div>
<h2 className="m-0 text-2xl leading-[var(--gl-line-height-xl)]">Agent展示配置页</h2> <h2 className="m-0 text-2xl leading-[var(--gl-line-height-xl)]">Agent展示配置页</h2>
</div> </div>
<div aria-label="页面操作" className="flex shrink-0 items-center gap-2">
<Button variant="outline" onClick={goBackToList}>返回</Button>
</div> </div>
</header> </header>
<div className="grid gap-4 rounded-[var(--gl-radius-md)] border border-[var(--gl-color-border-secondary)] bg-[var(--gl-color-bg-container)] p-6"> <div className="grid gap-4 rounded-[var(--gl-radius-md)] border border-[var(--gl-color-border-secondary)] bg-[var(--gl-color-bg-container)] p-6">
...@@ -169,10 +169,8 @@ export function OfficialSiteAgentDisplayConfigPage() { ...@@ -169,10 +169,8 @@ export function OfficialSiteAgentDisplayConfigPage() {
return ( return (
<section className="grid gap-6"> <section className="grid gap-6">
<header className="flex items-center justify-between gap-6 rounded-[var(--gl-radius-md)] border border-[var(--gl-color-border-secondary)] bg-[var(--gl-color-bg-container)] px-8 py-6"> <header className="sticky top-0 z-10 flex items-start justify-between gap-6 rounded-[var(--gl-radius-md)] border border-[var(--gl-color-border-secondary)] bg-[var(--gl-color-bg-container)] px-8 py-6">
<div className="flex items-center gap-4"> <div aria-label="页面标题" className="min-w-0 flex-1">
<Button variant="outline" onClick={goBackToList}>返回</Button>
<div>
<h2 className="m-0 text-2xl leading-[var(--gl-line-height-xl)]"> <h2 className="m-0 text-2xl leading-[var(--gl-line-height-xl)]">
{tabDetail?.position_name ?? '-'} Agent展示配置页 {tabDetail?.position_name ?? '-'} Agent展示配置页
</h2> </h2>
...@@ -180,6 +178,8 @@ export function OfficialSiteAgentDisplayConfigPage() { ...@@ -180,6 +178,8 @@ export function OfficialSiteAgentDisplayConfigPage() {
配置该岗位下 Agent 在官网的展示素材和状态 配置该岗位下 Agent 在官网的展示素材和状态
</p> </p>
</div> </div>
<div aria-label="页面操作" className="flex shrink-0 items-center gap-2">
<Button variant="outline" onClick={goBackToList}>返回</Button>
</div> </div>
</header> </header>
......
...@@ -140,8 +140,13 @@ describe('official site agent display config routes and navigation', () => { ...@@ -140,8 +140,13 @@ describe('official site agent display config routes and navigation', () => {
it('shows return to list button', async () => { it('shows return to list button', async () => {
renderApp(); renderApp();
await waitFor(() => { await waitFor(() => {
expect(screen.getByRole('button', { name: '返回' })).toBeInTheDocument(); expect(screen.getByRole('heading', { name: '店销顾问 Agent展示配置页' })).toBeInTheDocument();
}); });
const pageHeader = screen.getByRole('heading', { name: '店销顾问 Agent展示配置页' }).closest('header') as HTMLElement;
expect(pageHeader).toHaveClass('sticky', 'top-0', 'z-10');
expect(within(screen.getByLabelText('页面标题')).queryByRole('button')).not.toBeInTheDocument();
const pageActions = screen.getByLabelText('页面操作');
expect(within(pageActions).getByRole('button', { name: '返回' })).toBeInTheDocument();
}); });
it('shows position name in page title', async () => { it('shows position name in page title', async () => {
...@@ -173,7 +178,7 @@ describe('official site agent display config routes and navigation', () => { ...@@ -173,7 +178,7 @@ describe('official site agent display config routes and navigation', () => {
await waitFor(() => { await waitFor(() => {
expect(screen.getByRole('heading', { name: '店销顾问 Agent展示配置页' })).toBeInTheDocument(); expect(screen.getByRole('heading', { name: '店销顾问 Agent展示配置页' })).toBeInTheDocument();
}); });
fireEvent.click(screen.getByRole('button', { name: '返回' })); fireEvent.click(within(screen.getByLabelText('页面操作')).getByRole('button', { name: '返回' }));
await waitFor(() => { await waitFor(() => {
expect(screen.getByRole('heading', { name: '岗位展示配置' })).toBeInTheDocument(); expect(screen.getByRole('heading', { name: '岗位展示配置' })).toBeInTheDocument();
}); });
......
...@@ -107,9 +107,11 @@ describe('OfficialSiteJobTabEditorPage', () => { ...@@ -107,9 +107,11 @@ describe('OfficialSiteJobTabEditorPage', () => {
expect(await screen.findByRole('heading', { name: '新建岗位展示' })).toBeInTheDocument(); expect(await screen.findByRole('heading', { name: '新建岗位展示' })).toBeInTheDocument();
const pageHeader = screen.getByRole('heading', { name: '新建岗位展示' }).closest('header') as HTMLElement; const pageHeader = screen.getByRole('heading', { name: '新建岗位展示' }).closest('header') as HTMLElement;
expect(pageHeader).toHaveClass('sticky', 'top-0', 'z-10'); expect(pageHeader).toHaveClass('sticky', 'top-0', 'z-10');
expect(within(pageHeader).getByRole('button', { name: '返回' })).toBeInTheDocument(); expect(within(screen.getByLabelText('页面标题')).queryByRole('button')).not.toBeInTheDocument();
const pageActions = screen.getByLabelText('页面操作');
expect(within(pageActions).getByRole('button', { name: '返回' })).toBeInTheDocument();
expect(within(pageActions).getByRole('button', { name: '保存' })).toBeInTheDocument();
expect(within(pageHeader).queryByRole('button', { name: '取消' })).not.toBeInTheDocument(); expect(within(pageHeader).queryByRole('button', { name: '取消' })).not.toBeInTheDocument();
expect(within(pageHeader).getByRole('button', { name: '保存' })).toBeInTheDocument();
}); });
it('renders required form fields', () => { it('renders required form fields', () => {
......
...@@ -380,10 +380,8 @@ export function OfficialSiteJobTabEditorPage({ mode }: { mode: 'create' | 'edit' ...@@ -380,10 +380,8 @@ export function OfficialSiteJobTabEditorPage({ mode }: { mode: 'create' | 'edit'
return ( return (
<section className="grid gap-6"> <section className="grid gap-6">
<header className="sticky top-0 z-10 flex items-center justify-between gap-6 rounded-[var(--gl-radius-md)] border border-[var(--gl-color-border-secondary)] bg-[var(--gl-color-bg-container)] px-8 py-6"> <header className="sticky top-0 z-10 flex items-start justify-between gap-6 rounded-[var(--gl-radius-md)] border border-[var(--gl-color-border-secondary)] bg-[var(--gl-color-bg-container)] px-8 py-6">
<div className="flex items-center gap-4"> <div aria-label="页面标题" className="min-w-0 flex-1">
<Button variant="outline" onClick={goBackToList}>返回</Button>
<div>
<h2 className="m-0 text-2xl leading-[var(--gl-line-height-xl)]"> <h2 className="m-0 text-2xl leading-[var(--gl-line-height-xl)]">
{mode === 'create' ? '新建岗位展示' : '编辑岗位展示'} {mode === 'create' ? '新建岗位展示' : '编辑岗位展示'}
</h2> </h2>
...@@ -391,8 +389,10 @@ export function OfficialSiteJobTabEditorPage({ mode }: { mode: 'create' | 'edit' ...@@ -391,8 +389,10 @@ export function OfficialSiteJobTabEditorPage({ mode }: { mode: 'create' | 'edit'
{mode === 'create' ? '创建新的官网岗位展示配置' : '编辑已有官网岗位展示配置'} {mode === 'create' ? '创建新的官网岗位展示配置' : '编辑已有官网岗位展示配置'}
</p> </p>
</div> </div>
</div> <div aria-label="页面操作" className="flex shrink-0 items-center gap-2">
<Button variant="outline" onClick={goBackToList}>返回</Button>
<Button theme="primary" loading={saving} onClick={handleSave}>保存</Button> <Button theme="primary" loading={saving} onClick={handleSave}>保存</Button>
</div>
</header> </header>
{notice ? ( {notice ? (
......
...@@ -197,7 +197,7 @@ describe('OfficialSiteJobTabListPage', () => { ...@@ -197,7 +197,7 @@ describe('OfficialSiteJobTabListPage', () => {
expect(screen.getByLabelText('关键词')).toBeInTheDocument(); expect(screen.getByLabelText('关键词')).toBeInTheDocument();
expect(screen.getByPlaceholderText('搜索岗位名称或渠道活码')).toBeInTheDocument(); expect(screen.getByPlaceholderText('搜索岗位名称或渠道活码')).toBeInTheDocument();
expect(screen.getByLabelText('展示状态')).toBeInTheDocument(); expect(screen.getByLabelText('展示状态')).toBeInTheDocument();
expect(screen.getByRole('button', { name: '搜索' })).toBeInTheDocument(); expect(screen.getByRole('button', { name: '查询' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '重置' })).toBeInTheDocument(); expect(screen.getByRole('button', { name: '重置' })).toBeInTheDocument();
}); });
...@@ -246,7 +246,7 @@ describe('OfficialSiteJobTabListPage', () => { ...@@ -246,7 +246,7 @@ describe('OfficialSiteJobTabListPage', () => {
renderApp(); renderApp();
const keywordInput = screen.getByLabelText('关键词'); const keywordInput = screen.getByLabelText('关键词');
fireEvent.change(keywordInput, { target: { value: '不存在的关键词' } }); fireEvent.change(keywordInput, { target: { value: '不存在的关键词' } });
fireEvent.click(screen.getByRole('button', { name: '搜索' })); fireEvent.click(screen.getByRole('button', { name: '查询' }));
await waitFor(() => { await waitFor(() => {
expect(screen.getByText('未找到匹配结果')).toBeInTheDocument(); expect(screen.getByText('未找到匹配结果')).toBeInTheDocument();
expect(screen.queryByText('暂无数据')).not.toBeInTheDocument(); expect(screen.queryByText('暂无数据')).not.toBeInTheDocument();
...@@ -289,7 +289,7 @@ describe('OfficialSiteJobTabListPage', () => { ...@@ -289,7 +289,7 @@ describe('OfficialSiteJobTabListPage', () => {
page: 1, page: 1,
page_size: 10, page_size: 10,
}); });
fireEvent.click(screen.getByRole('button', { name: '搜索' })); fireEvent.click(screen.getByRole('button', { name: '查询' }));
await waitFor(() => { await waitFor(() => {
expect(screen.getByText('店销顾问')).toBeInTheDocument(); expect(screen.getByText('店销顾问')).toBeInTheDocument();
}); });
...@@ -320,7 +320,7 @@ describe('OfficialSiteJobTabListPage', () => { ...@@ -320,7 +320,7 @@ describe('OfficialSiteJobTabListPage', () => {
page_size: 10, page_size: 10,
}); });
await act(async () => { await act(async () => {
fireEvent.click(screen.getByRole('button', { name: '搜索' })); fireEvent.click(screen.getByRole('button', { name: '查询' }));
}); });
await waitFor(() => { await waitFor(() => {
expect(screen.getByText('私域增长')).toBeInTheDocument(); expect(screen.getByText('私域增长')).toBeInTheDocument();
...@@ -334,7 +334,7 @@ describe('OfficialSiteJobTabListPage', () => { ...@@ -334,7 +334,7 @@ describe('OfficialSiteJobTabListPage', () => {
}); });
const keywordInput = screen.getByLabelText('关键词'); const keywordInput = screen.getByLabelText('关键词');
fireEvent.change(keywordInput, { target: { value: '店销' } }); fireEvent.change(keywordInput, { target: { value: '店销' } });
fireEvent.click(screen.getByRole('button', { name: '搜索' })); fireEvent.click(screen.getByRole('button', { name: '查询' }));
fireEvent.click(screen.getByRole('button', { name: '重置' })); fireEvent.click(screen.getByRole('button', { name: '重置' }));
await waitFor(() => { await waitFor(() => {
expect(keywordInput).toHaveValue(''); expect(keywordInput).toHaveValue('');
......
...@@ -24,6 +24,7 @@ const mockMethodologyConfig = { ...@@ -24,6 +24,7 @@ const mockMethodologyConfig = {
steps: [ steps: [
{ step_id: 's1', step_icon: 'https://cdn.example.com/icon1.png', step_name: '需求澄清', step_order: 1, step_image: 'https://cdn.example.com/image1.png' }, { step_id: 's1', step_icon: 'https://cdn.example.com/icon1.png', step_name: '需求澄清', step_order: 1, step_image: 'https://cdn.example.com/image1.png' },
{ step_id: 's2', step_icon: 'https://cdn.example.com/icon2.png', step_name: '方案设计', step_order: 2, step_image: 'https://cdn.example.com/image2.png' }, { step_id: 's2', step_icon: 'https://cdn.example.com/icon2.png', step_name: '方案设计', step_order: 2, step_image: 'https://cdn.example.com/image2.png' },
{ step_id: 's3', step_icon: 'https://cdn.example.com/icon3.png', step_name: '上线复盘', step_order: 3, step_image: 'https://cdn.example.com/image3.png' },
], ],
updated_at: '2026-05-16T10:00:00Z', updated_at: '2026-05-16T10:00:00Z',
}; };
...@@ -59,9 +60,10 @@ describe('OfficialSiteMethodologyPage form and steps', () => { ...@@ -59,9 +60,10 @@ describe('OfficialSiteMethodologyPage form and steps', () => {
expect(screen.getByLabelText('副标题')).toHaveValue('从目标澄清到上线复盘,帮助团队沉淀一套稳定可复制的方法论。'); expect(screen.getByLabelText('副标题')).toHaveValue('从目标澄清到上线复盘,帮助团队沉淀一套稳定可复制的方法论。');
const cards = screen.getAllByTestId('methodology-step-card'); const cards = screen.getAllByTestId('methodology-step-card');
expect(cards).toHaveLength(2); expect(cards).toHaveLength(3);
expect(within(cards[0]).getByLabelText('步骤1名称')).toHaveValue('需求澄清'); expect(within(cards[0]).getByLabelText('步骤3名称')).toHaveValue('上线复盘');
expect(within(cards[1]).getByLabelText('步骤2名称')).toHaveValue('方案设计'); expect(within(cards[1]).getByLabelText('步骤2名称')).toHaveValue('方案设计');
expect(within(cards[2]).getByLabelText('步骤1名称')).toHaveValue('需求澄清');
}); });
it('supports disabled display status and empty-step fixtures', async () => { it('supports disabled display status and empty-step fixtures', async () => {
...@@ -101,6 +103,7 @@ describe('OfficialSiteMethodologyPage form and steps', () => { ...@@ -101,6 +103,7 @@ describe('OfficialSiteMethodologyPage form and steps', () => {
fireEvent.change(screen.getByLabelText('副标题'), { target: { value: '' } }); fireEvent.change(screen.getByLabelText('副标题'), { target: { value: '' } });
fireEvent.click(screen.getByRole('button', { name: '删除步骤 1' })); fireEvent.click(screen.getByRole('button', { name: '删除步骤 1' }));
fireEvent.click(screen.getByRole('button', { name: '删除步骤 1' })); fireEvent.click(screen.getByRole('button', { name: '删除步骤 1' }));
fireEvent.click(screen.getByRole('button', { name: '删除步骤 1' }));
fireEvent.click(screen.getByRole('button', { name: '保存配置' })); fireEvent.click(screen.getByRole('button', { name: '保存配置' }));
expect(screen.getByText('请输入主标题')).toBeInTheDocument(); expect(screen.getByText('请输入主标题')).toBeInTheDocument();
...@@ -112,27 +115,46 @@ describe('OfficialSiteMethodologyPage form and steps', () => { ...@@ -112,27 +115,46 @@ describe('OfficialSiteMethodologyPage form and steps', () => {
renderMethodology(); renderMethodology();
await waitFor(() => { await waitFor(() => {
expect(screen.getAllByTestId('methodology-step-card')).toHaveLength(2); expect(screen.getAllByTestId('methodology-step-card')).toHaveLength(3);
}); });
fireEvent.click(screen.getByRole('button', { name: '添加步骤' })); fireEvent.click(screen.getByRole('button', { name: '添加步骤' }));
let cards = screen.getAllByTestId('methodology-step-card'); let cards = screen.getAllByTestId('methodology-step-card');
expect(cards).toHaveLength(3); expect(cards).toHaveLength(4);
expect(within(cards[0]).getByLabelText('步骤4名称')).toHaveValue('');
expect(within(cards[1]).getByLabelText('步骤3名称')).toHaveValue('上线复盘');
fireEvent.click(within(cards[1]).getByRole('button', { name: '下移步骤 3' }));
cards = screen.getAllByTestId('methodology-step-card');
expect(within(cards[1]).getByLabelText('步骤3名称')).toHaveValue('方案设计');
expect(within(cards[2]).getByLabelText('步骤2名称')).toHaveValue('上线复盘');
fireEvent.change(within(cards[2]).getByLabelText('步骤3名称'), { target: { value: '上线复盘' } }); fireEvent.click(within(cards[2]).getByRole('button', { name: '上移步骤 2' }));
fireEvent.click(within(cards[2]).getByRole('button', { name: '上移步骤 3' }));
fireEvent.click(within(screen.getAllByTestId('methodology-step-card')[1]).getByRole('button', { name: '上移步骤 2' }));
cards = screen.getAllByTestId('methodology-step-card'); cards = screen.getAllByTestId('methodology-step-card');
expect(within(cards[0]).getByLabelText('步骤1名称')).toHaveValue('上线复盘'); expect(within(cards[1]).getByLabelText('步骤3名称')).toHaveValue('上线复盘');
expect(within(cards[1]).getByLabelText('步骤2名称')).toHaveValue('需求澄清'); expect(within(cards[2]).getByLabelText('步骤2名称')).toHaveValue('方案设计');
fireEvent.click(within(cards[1]).getByRole('button', { name: '删除步骤 2' })); fireEvent.click(within(cards[0]).getByRole('button', { name: '删除步骤 4' }));
cards = screen.getAllByTestId('methodology-step-card'); cards = screen.getAllByTestId('methodology-step-card');
expect(cards).toHaveLength(2); expect(cards).toHaveLength(3);
expect(within(cards[0]).getByLabelText('步骤3名称')).toHaveValue('上线复盘');
expect(within(cards[1]).getByLabelText('步骤2名称')).toHaveValue('方案设计'); expect(within(cards[1]).getByLabelText('步骤2名称')).toHaveValue('方案设计');
fireEvent.click(screen.getByRole('button', { name: '保存配置' }));
await waitFor(() => {
expect(saveMethodologyConfig).toHaveBeenCalled();
});
expect(vi.mocked(saveMethodologyConfig).mock.calls[0][0].steps.map((step) => step.step_name)).toEqual([
'需求澄清',
'方案设计',
'上线复盘',
]);
expect(vi.mocked(saveMethodologyConfig).mock.calls[0][0].steps.map((step) => step.step_order)).toEqual([1, 2, 3]);
}); });
describe('analytics tracking', () => { describe('analytics tracking', () => {
......
...@@ -296,6 +296,10 @@ export function OfficialSiteMethodologyPage() { ...@@ -296,6 +296,10 @@ export function OfficialSiteMethodologyPage() {
); );
} }
const visibleSteps = form.steps
.map((step, index) => ({ step, index }))
.reverse();
return ( return (
<> <>
{notice ? ( {notice ? (
...@@ -369,29 +373,29 @@ export function OfficialSiteMethodologyPage() { ...@@ -369,29 +373,29 @@ export function OfficialSiteMethodologyPage() {
</div> </div>
) : ( ) : (
<div className="mt-6 grid gap-4"> <div className="mt-6 grid gap-4">
{form.steps.map((step, index) => ( {visibleSteps.map(({ step, index }, visibleIndex) => (
<section <section
key={step.step_id} key={step.step_id}
aria-label={`方法论步骤 ${index + 1}`} aria-label={`方法论步骤 ${step.step_order}`}
className="grid gap-5 rounded-[8px] border border-[var(--gl-color-border-secondary)] bg-[var(--gl-color-bg-page)] p-5" className="grid gap-5 rounded-[8px] border border-[var(--gl-color-border-secondary)] bg-[var(--gl-color-bg-page)] p-5"
data-testid="methodology-step-card" data-testid="methodology-step-card"
> >
<div className="flex flex-wrap items-center justify-between gap-3"> <div className="flex flex-wrap items-center justify-between gap-3">
<div className="grid gap-1"> <div className="grid gap-1">
<strong>步骤 {index + 1}</strong> <strong>步骤 {step.step_order}</strong>
{/* <span className="text-sm text-[var(--gl-color-text-secondary)]">{`sort_order = ${step.step_order}`}</span> */} {/* <span className="text-sm text-[var(--gl-color-text-secondary)]">{`sort_order = ${step.step_order}`}</span> */}
</div> </div>
<div className="flex flex-wrap items-center gap-2"> <div className="flex flex-wrap items-center gap-2">
<Button <Button
size="small" size="small"
variant="outline" variant="outline"
disabled={index === 0} disabled={visibleIndex === 0}
aria-label={`上移步骤 ${index + 1}`} aria-label={`上移步骤 ${step.step_order}`}
onClick={() => { onClick={() => {
if (index === 0) return; if (visibleIndex === 0) return;
updateForm((current) => { updateForm((current) => {
const nextSteps = [...current.steps]; const nextSteps = [...current.steps];
[nextSteps[index - 1], nextSteps[index]] = [nextSteps[index], nextSteps[index - 1]]; [nextSteps[index], nextSteps[index + 1]] = [nextSteps[index + 1], nextSteps[index]];
return { ...current, steps: normalizeSteps(nextSteps) }; return { ...current, steps: normalizeSteps(nextSteps) };
}); });
}} }}
...@@ -401,13 +405,13 @@ export function OfficialSiteMethodologyPage() { ...@@ -401,13 +405,13 @@ export function OfficialSiteMethodologyPage() {
<Button <Button
size="small" size="small"
variant="outline" variant="outline"
disabled={index === form.steps.length - 1} disabled={visibleIndex === visibleSteps.length - 1}
aria-label={`下移步骤 ${index + 1}`} aria-label={`下移步骤 ${step.step_order}`}
onClick={() => { onClick={() => {
if (index === form.steps.length - 1) return; if (visibleIndex === visibleSteps.length - 1) return;
updateForm((current) => { updateForm((current) => {
const nextSteps = [...current.steps]; const nextSteps = [...current.steps];
[nextSteps[index], nextSteps[index + 1]] = [nextSteps[index + 1], nextSteps[index]]; [nextSteps[index - 1], nextSteps[index]] = [nextSteps[index], nextSteps[index - 1]];
return { ...current, steps: normalizeSteps(nextSteps) }; return { ...current, steps: normalizeSteps(nextSteps) };
}); });
}} }}
...@@ -417,7 +421,7 @@ export function OfficialSiteMethodologyPage() { ...@@ -417,7 +421,7 @@ export function OfficialSiteMethodologyPage() {
<Button <Button
size="small" size="small"
theme="danger" theme="danger"
aria-label={`删除步骤 ${index + 1}`} aria-label={`删除步骤 ${step.step_order}`}
onClick={() => { onClick={() => {
updateForm((current) => ({ updateForm((current) => ({
...current, ...current,
...@@ -496,7 +500,7 @@ export function OfficialSiteMethodologyPage() { ...@@ -496,7 +500,7 @@ export function OfficialSiteMethodologyPage() {
<Button <Button
size="small" size="small"
variant="outline" variant="outline"
aria-label={`使用默认图标 步骤 ${index + 1}`} aria-label={`使用默认图标 步骤 ${step.step_order}`}
disabled={defaultIconUploading.has(step.step_id)} disabled={defaultIconUploading.has(step.step_id)}
onClick={async () => { onClick={async () => {
const stepId = step.step_id; const stepId = step.step_id;
...@@ -567,7 +571,7 @@ export function OfficialSiteMethodologyPage() { ...@@ -567,7 +571,7 @@ export function OfficialSiteMethodologyPage() {
<FormItem label="步骤名称" requiredMark status={step.nameError ? 'error' : undefined} tips={step.nameError}> <FormItem label="步骤名称" requiredMark status={step.nameError ? 'error' : undefined} tips={step.nameError}>
<Input <Input
aria-label={`步骤${index + 1}名称`} aria-label={`步骤${step.step_order}名称`}
className="w-full max-w-[360px]" className="w-full max-w-[360px]"
maxlength={20} maxlength={20}
allowInputOverMax allowInputOverMax
......
...@@ -368,8 +368,8 @@ describe('OfficialSiteMethodologyPage upload, save, and state handling', () => { ...@@ -368,8 +368,8 @@ describe('OfficialSiteMethodologyPage upload, save, and state handling', () => {
await waitFor(() => { await waitFor(() => {
expect(saveMethodologyConfig).toHaveBeenCalled(); expect(saveMethodologyConfig).toHaveBeenCalled();
const savePayload = vi.mocked(saveMethodologyConfig).mock.calls[0][0]; const savePayload = vi.mocked(saveMethodologyConfig).mock.calls[0][0];
// 第一个步骤的 step_icon 应该是新的 file_url // 第一张可见卡是倒序展示的步骤 2,保存 payload 仍按正序提交
expect(savePayload.steps[0].step_icon).toBe('https://cdn.example.com/new-icon.png'); expect(savePayload.steps[1].step_icon).toBe('https://cdn.example.com/new-icon.png');
}); });
}); });
}); });
...@@ -427,8 +427,8 @@ describe('OfficialSiteMethodologyPage upload, save, and state handling', () => { ...@@ -427,8 +427,8 @@ describe('OfficialSiteMethodologyPage upload, save, and state handling', () => {
await waitFor(() => { await waitFor(() => {
expect(saveMethodologyConfig).toHaveBeenCalled(); expect(saveMethodologyConfig).toHaveBeenCalled();
const savePayload = vi.mocked(saveMethodologyConfig).mock.calls[0][0]; const savePayload = vi.mocked(saveMethodologyConfig).mock.calls[0][0];
// 第一个步骤的 step_image 应该是新的 file_url // 第一张可见卡是倒序展示的步骤 2,保存 payload 仍按正序提交
expect(savePayload.steps[0].step_image).toBe('https://cdn.example.com/new-content.png'); expect(savePayload.steps[1].step_image).toBe('https://cdn.example.com/new-content.png');
}); });
}); });
}); });
...@@ -457,7 +457,7 @@ describe('OfficialSiteMethodologyPage upload, save, and state handling', () => { ...@@ -457,7 +457,7 @@ describe('OfficialSiteMethodologyPage upload, save, and state handling', () => {
}); });
// 点击「使用默认图标」按钮 // 点击「使用默认图标」按钮
const defaultIconButton = within(firstCard).getByRole('button', { name: '使用默认图标 步骤 1' }); const defaultIconButton = within(firstCard).getByRole('button', { name: '使用默认图标 步骤 2' });
fireEvent.click(defaultIconButton); fireEvent.click(defaultIconButton);
await waitFor(() => { await waitFor(() => {
...@@ -483,9 +483,9 @@ describe('OfficialSiteMethodologyPage upload, save, and state handling', () => { ...@@ -483,9 +483,9 @@ describe('OfficialSiteMethodologyPage upload, save, and state handling', () => {
await waitFor(() => { await waitFor(() => {
expect(saveMethodologyConfig).toHaveBeenCalled(); expect(saveMethodologyConfig).toHaveBeenCalled();
const savePayload = vi.mocked(saveMethodologyConfig).mock.calls[0][0]; const savePayload = vi.mocked(saveMethodologyConfig).mock.calls[0][0];
expect(savePayload.steps[0].step_icon).toBe('https://cdn.example.com/default-icon-1.png'); expect(savePayload.steps[1].step_icon).toBe('https://cdn.example.com/default-icon-1.png');
// 不应为 data: URL // 不应为 data: URL
expect(savePayload.steps[0].step_icon).not.toMatch(/^data:/); expect(savePayload.steps[1].step_icon).not.toMatch(/^data:/);
}); });
}); });
...@@ -506,7 +506,7 @@ describe('OfficialSiteMethodologyPage upload, save, and state handling', () => { ...@@ -506,7 +506,7 @@ describe('OfficialSiteMethodologyPage upload, save, and state handling', () => {
clickDeleteIcon(uploadContainers[0] as HTMLElement); clickDeleteIcon(uploadContainers[0] as HTMLElement);
} }
const defaultIconButton = within(firstCard).getByRole('button', { name: '使用默认图标 步骤 1' }); const defaultIconButton = within(firstCard).getByRole('button', { name: '使用默认图标 步骤 2' });
fireEvent.click(defaultIconButton); fireEvent.click(defaultIconButton);
// 等待上传失败 // 等待上传失败
...@@ -543,7 +543,7 @@ describe('OfficialSiteMethodologyPage upload, save, and state handling', () => { ...@@ -543,7 +543,7 @@ describe('OfficialSiteMethodologyPage upload, save, and state handling', () => {
// 模拟上传失败 // 模拟上传失败
vi.mocked(uploadMethodologyAsset).mockRejectedValueOnce(new Error('Upload failed')); vi.mocked(uploadMethodologyAsset).mockRejectedValueOnce(new Error('Upload failed'));
const defaultIconButton = within(firstCard).getByRole('button', { name: '使用默认图标 步骤 1' }); const defaultIconButton = within(firstCard).getByRole('button', { name: '使用默认图标 步骤 2' });
fireEvent.click(defaultIconButton); fireEvent.click(defaultIconButton);
await waitFor(() => { await waitFor(() => {
...@@ -559,7 +559,7 @@ describe('OfficialSiteMethodologyPage upload, save, and state handling', () => { ...@@ -559,7 +559,7 @@ describe('OfficialSiteMethodologyPage upload, save, and state handling', () => {
}); });
// 再次点击「使用默认图标」重试 // 再次点击「使用默认图标」重试
fireEvent.click(within(firstCard).getByRole('button', { name: '使用默认图标 步骤 1' })); fireEvent.click(within(firstCard).getByRole('button', { name: '使用默认图标 步骤 2' }));
await waitFor(() => { await waitFor(() => {
const images = within(firstCard).getAllByRole('img'); const images = within(firstCard).getAllByRole('img');
...@@ -594,7 +594,7 @@ describe('OfficialSiteMethodologyPage upload, save, and state handling', () => { ...@@ -594,7 +594,7 @@ describe('OfficialSiteMethodologyPage upload, save, and state handling', () => {
file_size: 5000, file_size: 5000,
}), 1000))); }), 1000)));
const defaultIconButton = within(firstCard).getByRole('button', { name: '使用默认图标 步骤 1' }); const defaultIconButton = within(firstCard).getByRole('button', { name: '使用默认图标 步骤 2' });
fireEvent.click(defaultIconButton); fireEvent.click(defaultIconButton);
// 等待上传开始 // 等待上传开始
...@@ -603,7 +603,7 @@ describe('OfficialSiteMethodologyPage upload, save, and state handling', () => { ...@@ -603,7 +603,7 @@ describe('OfficialSiteMethodologyPage upload, save, and state handling', () => {
}); });
// 上传中按钮应禁用 // 上传中按钮应禁用
expect(within(getFirstCard()).getByLabelText('使用默认图标 步骤 1')).toHaveAttribute('disabled'); expect(within(getFirstCard()).getByLabelText('使用默认图标 步骤 2')).toHaveAttribute('disabled');
// 等待上传完成(需要额外 timeout 以覆盖 mock 延迟) // 等待上传完成(需要额外 timeout 以覆盖 mock 延迟)
await waitFor(() => { await waitFor(() => {
...@@ -613,7 +613,7 @@ describe('OfficialSiteMethodologyPage upload, save, and state handling', () => { ...@@ -613,7 +613,7 @@ describe('OfficialSiteMethodologyPage upload, save, and state handling', () => {
}, { timeout: 2000 }); }, { timeout: 2000 });
// 上传完成后按钮恢复可用 // 上传完成后按钮恢复可用
expect(within(getFirstCard()).getByRole('button', { name: '使用默认图标 步骤 1' })).not.toBeDisabled(); expect(within(getFirstCard()).getByRole('button', { name: '使用默认图标 步骤 2' })).not.toBeDisabled();
}); });
}); });
}); });
...@@ -76,7 +76,7 @@ describe('SkillListPage', () => { ...@@ -76,7 +76,7 @@ describe('SkillListPage', () => {
expect(screen.getAllByText('关键词').length).toBeGreaterThan(0); expect(screen.getAllByText('关键词').length).toBeGreaterThan(0);
expect(screen.getByLabelText('关键词')).toBeInTheDocument(); expect(screen.getByLabelText('关键词')).toBeInTheDocument();
expect(screen.getByPlaceholderText('搜索Skill名称或编码')).toBeInTheDocument(); expect(screen.getByPlaceholderText('搜索Skill名称或编码')).toBeInTheDocument();
expect(screen.getByRole('button', { name: '搜索' })).toBeInTheDocument(); expect(screen.getByRole('button', { name: '查询' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '重置' })).toBeInTheDocument(); expect(screen.getByRole('button', { name: '重置' })).toBeInTheDocument();
expect(screen.getByRole('columnheader', { name: 'Skill编码' })).toBeInTheDocument(); expect(screen.getByRole('columnheader', { name: 'Skill编码' })).toBeInTheDocument();
expect(screen.getByRole('columnheader', { name: 'Skill名称' })).toBeInTheDocument(); expect(screen.getByRole('columnheader', { name: 'Skill名称' })).toBeInTheDocument();
...@@ -100,7 +100,7 @@ describe('SkillListPage', () => { ...@@ -100,7 +100,7 @@ describe('SkillListPage', () => {
expect(screen.getByLabelText('关键词')).toBeInTheDocument(); expect(screen.getByLabelText('关键词')).toBeInTheDocument();
}); });
expect(screen.getByPlaceholderText('搜索Skill名称或编码')).toBeInTheDocument(); expect(screen.getByPlaceholderText('搜索Skill名称或编码')).toBeInTheDocument();
expect(screen.getByRole('button', { name: '搜索' })).toBeInTheDocument(); expect(screen.getByRole('button', { name: '查询' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '重置' })).toBeInTheDocument(); expect(screen.getByRole('button', { name: '重置' })).toBeInTheDocument();
}); });
...@@ -119,7 +119,7 @@ describe('SkillListPage', () => { ...@@ -119,7 +119,7 @@ describe('SkillListPage', () => {
vi.mocked(getSkillList).mockResolvedValueOnce({ vi.mocked(getSkillList).mockResolvedValueOnce({
list: [mockSkills[1]], list: [mockSkills[1]],
}); });
fireEvent.click(screen.getByRole('button', { name: '搜索' })); fireEvent.click(screen.getByRole('button', { name: '查询' }));
await waitFor(() => { await waitFor(() => {
expect(getSkillList).toHaveBeenLastCalledWith('markdown'); expect(getSkillList).toHaveBeenLastCalledWith('markdown');
...@@ -148,7 +148,7 @@ describe('SkillListPage', () => { ...@@ -148,7 +148,7 @@ describe('SkillListPage', () => {
vi.mocked(getSkillList).mockResolvedValueOnce({ vi.mocked(getSkillList).mockResolvedValueOnce({
list: [mockSkills[0]], list: [mockSkills[0]],
}); });
fireEvent.click(screen.getByRole('button', { name: '搜索' })); fireEvent.click(screen.getByRole('button', { name: '查询' }));
await waitFor(() => { await waitFor(() => {
expect(getSkillList).toHaveBeenLastCalledWith('browser'); expect(getSkillList).toHaveBeenLastCalledWith('browser');
}); });
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!