|
|
@@ -40,10 +40,15 @@ test.describe.serial('区域列表查看测试', () => {
|
|
|
// 验证树形容器可见
|
|
|
await expect(regionManagementPage.treeContainer).toBeVisible();
|
|
|
|
|
|
- // 验证树结构中包含一些区域(至少要有省份存在)
|
|
|
- // 这里不验证具体的省份名称,因为测试数据可能不同
|
|
|
- const treeContent = regionManagementPage.treeContainer;
|
|
|
- await expect(treeContent).toBeVisible();
|
|
|
+ // 验证树结构中包含至少一个省份
|
|
|
+ const provinces = regionManagementPage.treeContainer.getByText(/^[\u4e00-\u9fa5]+省$/);
|
|
|
+ const count = await provinces.count();
|
|
|
+ expect(count).toBeGreaterThan(0);
|
|
|
+
|
|
|
+ // 验证第一个省份名称存在
|
|
|
+ const firstProvince = await provinces.first().textContent();
|
|
|
+ expect(firstProvince).toBeTruthy();
|
|
|
+ expect(firstProvince!.trim()).toMatch(/^[\u4e00-\u9fa5]+省$/);
|
|
|
});
|
|
|
|
|
|
test('应该能获取区域状态', async ({ regionManagementPage, page }) => {
|
|
|
@@ -163,4 +168,83 @@ test.describe.serial('区域列表查看测试', () => {
|
|
|
await expect(regionManagementPage.treeContainer).toBeVisible();
|
|
|
});
|
|
|
});
|
|
|
+
|
|
|
+ test.describe('区域层级标识验证', () => {
|
|
|
+ test('应该能验证省份层级标识', async ({ regionManagementPage }) => {
|
|
|
+ await regionManagementPage.waitForTreeLoaded();
|
|
|
+
|
|
|
+ // 验证省份存在(以"省"结尾)
|
|
|
+ const provinces = regionManagementPage.treeContainer.getByText(/^[\u4e00-\u9fa5]+省$/);
|
|
|
+ const count = await provinces.count();
|
|
|
+ expect(count).toBeGreaterThan(0);
|
|
|
+ console.debug(`找到 ${count} 个省份`);
|
|
|
+ });
|
|
|
+
|
|
|
+ test('应该能展开省份并验证市级子节点', async ({ regionManagementPage }) => {
|
|
|
+ await regionManagementPage.waitForTreeLoaded();
|
|
|
+
|
|
|
+ // 查找第一个省份
|
|
|
+ const province = regionManagementPage.treeContainer.getByText(/^[\u4e00-\u9fa5]+省$/).first();
|
|
|
+ const provinceCount = await province.count();
|
|
|
+
|
|
|
+ if (provinceCount > 0) {
|
|
|
+ const provinceName = await province.textContent();
|
|
|
+ if (provinceName) {
|
|
|
+ // 展开省份
|
|
|
+ await regionManagementPage.expandNode(provinceName.trim());
|
|
|
+ await regionManagementPage.page.waitForTimeout(500);
|
|
|
+
|
|
|
+ // 验证市级子节点存在(以"市"结尾)
|
|
|
+ const cities = regionManagementPage.treeContainer.getByText(/^[\u4e00-\u9fa5]+市$/);
|
|
|
+ const cityCount = await cities.count();
|
|
|
+ console.debug(`展开 ${provinceName.trim()} 后找到 ${cityCount} 个市`);
|
|
|
+
|
|
|
+ // 验证至少有一个市(如果省份有子节点)
|
|
|
+ if (cityCount > 0) {
|
|
|
+ const firstCity = await cities.first().textContent();
|
|
|
+ expect(firstCity).toBeTruthy();
|
|
|
+ expect(firstCity!.trim()).toMatch(/^[\u4e00-\u9fa5]+市$/);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ test('应该能展开市并验证区级子节点', async ({ regionManagementPage }) => {
|
|
|
+ await regionManagementPage.waitForTreeLoaded();
|
|
|
+
|
|
|
+ // 查找第一个省份并展开
|
|
|
+ const province = regionManagementPage.treeContainer.getByText(/^[\u4e00-\u9fa5]+省$/).first();
|
|
|
+ const provinceCount = await province.count();
|
|
|
+
|
|
|
+ if (provinceCount > 0) {
|
|
|
+ const provinceName = await province.textContent();
|
|
|
+ if (provinceName) {
|
|
|
+ await regionManagementPage.expandNode(provinceName.trim());
|
|
|
+ await regionManagementPage.page.waitForTimeout(500);
|
|
|
+
|
|
|
+ // 查找第一个市并展开
|
|
|
+ const city = regionManagementPage.treeContainer.getByText(/^[\u4e00-\u9fa5]+市$/).first();
|
|
|
+ const cityCount = await city.count();
|
|
|
+
|
|
|
+ if (cityCount > 0) {
|
|
|
+ const cityName = await city.textContent();
|
|
|
+ if (cityName) {
|
|
|
+ await regionManagementPage.expandNode(cityName.trim());
|
|
|
+ await regionManagementPage.page.waitForTimeout(500);
|
|
|
+
|
|
|
+ // 验证区级子节点存在(以"区"或"县"结尾)
|
|
|
+ const districts = regionManagementPage.treeContainer.getByText(/^[\u4e00-\u9fa5]+(区|县)$/);
|
|
|
+ const districtCount = await districts.count();
|
|
|
+ console.debug(`展开 ${cityName.trim()} 后找到 ${districtCount} 个区/县`);
|
|
|
+
|
|
|
+ if (districtCount > 0) {
|
|
|
+ const firstDistrict = await districts.first().textContent();
|
|
|
+ expect(firstDistrict).toBeTruthy();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
});
|