|
|
@@ -1048,11 +1048,14 @@ export class OrderManagementPage {
|
|
|
* 上传附件
|
|
|
*
|
|
|
* 实际的 UI 流程:
|
|
|
- * 1. 点击人员行中对应文件类型的"上传文件"按钮
|
|
|
- * 2. 打开 FileSelector 对话框(第三个对话框)
|
|
|
- * 3. 在 FileSelector 对话框中使用 uploadFileToField 上传文件
|
|
|
- * 4. 点击上传后的文件进行选择
|
|
|
- * 5. 点击"确认选择"按钮
|
|
|
+ * 1. 在资源上传对话框中,点击人员行中对应文件类型的"上传文件"按钮
|
|
|
+ * 2. 打开上传弹窗(第三个对话框)- 选择文件类型
|
|
|
+ * 3. 在上传弹窗中,点击 FileSelector 的触发按钮
|
|
|
+ * 4. 打开 FileSelector 对话框(第四个对话框)
|
|
|
+ * 5. 在 FileSelector 对话框中使用 uploadFileToField 上传文件
|
|
|
+ * 6. 点击上传后的文件进行选择
|
|
|
+ * 7. 点击"确认选择"按钮
|
|
|
+ * 8. 在上传弹窗中点击"提交"按钮
|
|
|
*
|
|
|
* @param personIdentifier 人员标识(可以是 ID 或姓名,方法会自动匹配)
|
|
|
* @param fileName 文件名(相对于 web/tests/fixtures 目录)
|
|
|
@@ -1128,15 +1131,47 @@ export class OrderManagementPage {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- // 点击对应的上传文件按钮,这会打开 FileSelector 对话框
|
|
|
+ // 点击对应的上传文件按钮,这会打开上传弹窗(第三个对话框)
|
|
|
const targetButton = uploadButton.nth(buttonIndex);
|
|
|
+
|
|
|
+ // 调试信息:检查按钮是否可见
|
|
|
+ const isVisible = await targetButton.isVisible().catch(() => false);
|
|
|
+ console.debug(`目标上传文件按钮可见性: ${isVisible}`);
|
|
|
+
|
|
|
+ if (!isVisible) {
|
|
|
+ console.debug(`上传文件按钮不可见,尝试滚动到视图`);
|
|
|
+ await personRow.scrollIntoViewIfNeeded();
|
|
|
+ await this.page.waitForTimeout(TIMEOUTS.SHORT);
|
|
|
+ }
|
|
|
+
|
|
|
await targetButton.click();
|
|
|
+ console.debug(`已点击第 ${buttonIndex} 个上传文件按钮`);
|
|
|
+
|
|
|
+ // 等待上传弹窗打开(第三个对话框)
|
|
|
+ await this.page.waitForTimeout(TIMEOUTS.MEDIUM);
|
|
|
+
|
|
|
+ // 在上传弹窗中点击 FileSelector 的触发按钮
|
|
|
+ // FileSelector 组件的触发按钮文本是"选择或上传文件"
|
|
|
+ const fileSelectorTrigger = this.page.getByRole('button', { name: /选择或上传文件/ }).or(
|
|
|
+ this.page.getByText('选择或上传文件')
|
|
|
+ );
|
|
|
+
|
|
|
+ const triggerCount = await fileSelectorTrigger.count();
|
|
|
+ console.debug(`找到 ${triggerCount} 个 FileSelector 触发按钮`);
|
|
|
+
|
|
|
+ if (triggerCount === 0) {
|
|
|
+ console.debug('未找到 FileSelector 触发按钮');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 点击最新的 FileSelector 触发按钮(如果有多于一个的话)
|
|
|
+ await fileSelectorTrigger.nth(triggerCount - 1).click();
|
|
|
+ console.debug('已点击 FileSelector 触发按钮');
|
|
|
|
|
|
// FileSelector 对话框的 data-testid 是 "file-selector-dialog"
|
|
|
const fileSelectorDialog = this.page.getByTestId('file-selector-dialog');
|
|
|
|
|
|
- // 等待 FileSelector 对话框打开(第三个对话框)
|
|
|
- // 使用 expect().toBeVisible() 主动等待,而不是被动超时
|
|
|
+ // 等待 FileSelector 对话框打开(第四个对话框)
|
|
|
try {
|
|
|
await fileSelectorDialog.waitFor({ state: 'visible', timeout: TIMEOUTS.DIALOG });
|
|
|
console.debug('FileSelector 对话框已打开');
|
|
|
@@ -1161,8 +1196,8 @@ export class OrderManagementPage {
|
|
|
}
|
|
|
);
|
|
|
console.debug(`文件 ${fileName} 上传操作已完成`);
|
|
|
- } catch (_error) {
|
|
|
- console.debug('文件上传失败:', error);
|
|
|
+ } catch (uploadError) {
|
|
|
+ console.debug('文件上传失败:', uploadError);
|
|
|
// 即使上传失败,也尝试关闭对话框
|
|
|
await fileSelectorDialog.getByRole('button', { name: '取消' }).click().catch(() => {});
|
|
|
return;
|
|
|
@@ -1207,9 +1242,22 @@ export class OrderManagementPage {
|
|
|
console.debug('未找到"确认选择"按钮');
|
|
|
}
|
|
|
|
|
|
- // 等待对话框关闭
|
|
|
+ // 等待 FileSelector 对话框关闭(回到上传弹窗)
|
|
|
await this.page.waitForTimeout(TIMEOUTS.MEDIUM);
|
|
|
|
|
|
+ // 在上传弹窗中点击"提交"按钮
|
|
|
+ const submitButton = this.page.getByRole('button', { name: /^提交$/ });
|
|
|
+ const submitButtonCount = await submitButton.count();
|
|
|
+
|
|
|
+ if (submitButtonCount > 0) {
|
|
|
+ await submitButton.click();
|
|
|
+ console.debug('已点击提交按钮');
|
|
|
+ // 等待提交完成(上传弹窗关闭)
|
|
|
+ await this.page.waitForTimeout(TIMEOUTS.LONG);
|
|
|
+ } else {
|
|
|
+ console.debug('未找到提交按钮');
|
|
|
+ }
|
|
|
+
|
|
|
console.debug(`附件上传流程完成: ${fileName}`);
|
|
|
}
|
|
|
|