|
|
@@ -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')
|