Просмотр исходного кода

✅ test(area-select-form): 移除集成测试中不必要的act包装

- 简化fireEvent.click调用,移除冗余的act(async())包装
- 更新注释以反映对aria-disabled属性的检查
- 保持测试逻辑不变,提高代码可读性和执行效率
yourname 2 недель назад
Родитель
Сommit
fe513344d9

+ 6 - 16
packages/area-management-ui/tests/integration/area-select-form.integration.test.tsx

@@ -227,9 +227,7 @@ describe('AreaSelectForm 集成测试', () => {
 
     // 使用fireEvent点击省份选择
     const provinceSelect = screen.getByTestId('test-area-province');
-    await act(async () => {
-      fireEvent.click(provinceSelect);
-    });
+    fireEvent.click(provinceSelect);
 
     // 等待选项出现
     await waitFor(() => {
@@ -237,11 +235,9 @@ describe('AreaSelectForm 集成测试', () => {
     });
 
     // 选择北京市
-    await act(async () => {
-      fireEvent.click(screen.getByText('北京市'));
-    });
+    fireEvent.click(screen.getByText('北京市'));
 
-    // 等待城市选择启用 - 检查disabled属性是否移除
+    // 等待城市选择启用 - 检查aria-disabled属性或disabled属性
     await waitFor(() => {
       const citySelect = screen.getByTestId('test-area-city');
       expect(citySelect).not.toHaveAttribute('disabled');
@@ -249,9 +245,7 @@ describe('AreaSelectForm 集成测试', () => {
 
     // 点击城市选择
     const citySelect = screen.getByTestId('test-area-city');
-    await act(async () => {
-      fireEvent.click(citySelect);
-    });
+    fireEvent.click(citySelect);
 
     // 等待城市选项出现
     await waitFor(() => {
@@ -259,15 +253,11 @@ describe('AreaSelectForm 集成测试', () => {
     });
 
     // 选择北京市(城市)
-    await act(async () => {
-      fireEvent.click(screen.getByText('北京市'));
-    });
+    fireEvent.click(screen.getByText('北京市'));
 
     // 提交表单
     const submitButton = screen.getByTestId('submit-button');
-    await act(async () => {
-      fireEvent.click(submitButton);
-    });
+    fireEvent.click(submitButton);
 
     // 不应该有验证错误
     await waitFor(() => {