Prechádzať zdrojové kódy

test: 增加重置后查询所有字段是否为空的检测

xyh 2 rokov pred
rodič
commit
66da483d3a

+ 2 - 2
cypress.config.ts

@@ -6,7 +6,7 @@ const address = ip.address();
 export default defineConfig({
   e2e: {
     baseUrl: `http://${address}:3001`,
-    viewportHeight: 980,
-    viewportWidth: 1600,
+    viewportHeight: 2000,
+    viewportWidth: 1920,
   },
 });

+ 1 - 1
cypress/e2e/matter.cy.ts

@@ -77,7 +77,7 @@ describe('库位绑定管理', function () {
     validateExport(TABLE_NAME);
   });
 
-  it.only('operation', function () {
+  it('operation', function () {
     const {validateAdd, validateEdit} = validatePut(
       'matter_modal',
       TABLE_NAME,

+ 1 - 1
cypress/e2e/menu.cy.ts

@@ -87,7 +87,7 @@ describe('菜单管理', function () {
     });
   });
 
-  it.only('子菜单操作', function () {
+  it('子菜单操作', function () {
     tableBtnClick(TABLE_NAME, 1);
 
     const {validateAdd, validateEdit} = validatePut(

+ 1 - 1
cypress/e2e/productionRequisition.cy.ts

@@ -167,7 +167,7 @@ describe('生产领料明细', function () {
 
   it('table', () => validateTable());
 
-  it.only('non-standard table', function () {
+  it('non-standard table', function () {
     selectClick('filter_type', 1);
     cy.getTestId('search_btn').click();
 

+ 10 - 1
cypress/e2e/purchase.cy.ts

@@ -72,7 +72,16 @@ describe('采购单列表', function () {
 
     validateTableSearch(
       'purchase_order_table',
-      ['orderCode', {id: 'type', type: 'select', value: 'timeout', eq: 1}],
+      [
+        'orderCode',
+        {
+          id: 'type',
+          type: 'select',
+          value: 'timeout',
+          eq: 1,
+          defaultValue: '全部',
+        },
+      ],
       {
         toolId: 'purchase_filter',
         url: '/receiveGoods/getPurchase',

+ 1 - 0
cypress/e2e/utils/setup.ts

@@ -101,6 +101,7 @@ export function exportIntercept(urls: string | string[]) {
 }
 
 export function beforeSetup(autoLogin = true) {
+  indexedDB.deleteDatabase('filterGroup');
   loginIntercept();
   menuIntercept();
   dictionaryIntercept();

+ 61 - 20
cypress/e2e/utils/utils.ts

@@ -5,7 +5,7 @@ export function selectClick(testid: string, eq = 0) {
   cy.getTestId(testid).click();
   cy.getTestId(testid)
     .find('.rc-virtual-list-holder-inner')
-    .children()
+    .children('.ant-select-item')
     .eq(eq)
     .click();
 }
@@ -85,7 +85,13 @@ export function clickDatePicker(id: string) {
 export function validateTableSearch(
   tableName: string,
   keys: (
-    | {id: string; type: 'select'; value: string; eq?: number}
+    | {
+        id: string;
+        type: 'select';
+        value: string;
+        eq?: number;
+        defaultValue?: string;
+      }
     | {id: string; type: 'date'}
     | string
   )[],
@@ -151,32 +157,69 @@ export function validateTableSearch(
       .should('not.have.class', 'ant-btn-loading');
   }
 
-  keys.forEach(function (key, idx) {
-    if (idx > 0) {
-      clear(keys[idx - 1]);
-    }
+  function eachAllField(skipValidate = false) {
+    keys.forEach(function (key, idx) {
+      if (idx > 0 && !skipValidate) {
+        clear(keys[idx - 1]);
+      }
+      let validateText: string;
+
+      if (typeof key === 'string') {
+        cy.getTestId(toolId).find(`[data-testid="filter_${key}"]`).type(key);
+        validateText = key;
+      } else {
+        const {id, type} = key;
+        switch (type) {
+          case 'select':
+            selectClick(`filter_${id}`, key?.eq ?? 0);
+            validateText = key.value;
+            break;
+          case 'date':
+            clickDatePicker(`filter_${id}`);
+            validateText = 'searchTime';
+            break;
+        }
+      }
+      !skipValidate && validate(validateText);
+    });
+  }
+
+  eachAllField();
 
+  // 校验重置功能
+  eachAllField(true);
+  cy.getTestId(toolId).find('[data-testid="reset_btn"]').click();
+  keys.forEach(function (key) {
     if (typeof key === 'string') {
-      cy.getTestId(toolId).find(`[data-testid="filter_${key}"]`).type(key);
-      validate(key);
+      cy.getTestId(`filter_${key}`).invoke('val').should('be.empty');
     } else {
-      const {id, type} = key;
-
-      switch (type) {
+      switch (key.type) {
         case 'select':
-          selectClick(`filter_${id}`, key?.eq ?? 0);
-          validate(key.value);
+          if (key.defaultValue) {
+            validateSelect(`filter_${key.id}`, key.defaultValue);
+            break;
+          }
+          cy.getTestId(`filter_${key.id}`)
+            .find('.ant-select-selection-placeholder')
+            .should('exist');
           break;
         case 'date':
-          clickDatePicker(`filter_${id}`);
-          validate('searchTime');
+          cy.getTestId(`filter_${key.id}`)
+            .children('.ant-picker-input')
+            .first()
+            .find('input')
+            .invoke('val')
+            .should('be.empty');
+          cy.getTestId(`filter_${key.id}`)
+            .children('.ant-picker-input')
+            .last()
+            .find('input')
+            .invoke('val')
+            .should('be.empty');
           break;
       }
     }
   });
-
-  // 校验重置功能
-  cy.getTestId(toolId).find('[data-testid="reset_btn"]').click();
   validate('page-1', true);
 
   // 校验刷新功能
@@ -395,8 +438,6 @@ export function closeModal() {
 
 /** 选择所有的筛选框 */
 export function selectAllFilters(toolId: string, count: number) {
-  indexedDB.deleteDatabase('filterGroup');
-
   cy.getTestId(toolId).getTestId('filter_btn').click();
   cy.get('.ant-transfer')
     .find('.ant-transfer-list')

BIN
packages/app/src/assets/images/logo.png