|
@@ -22,28 +22,45 @@ export function validateTableList(tableName: string, firstPageNumber = 3, second
|
|
|
cy.getTestId(tableName).find('table').find('.ant-table-tbody')
|
|
cy.getTestId(tableName).find('table').find('.ant-table-tbody')
|
|
|
.children('.ant-table-row').should('have.length', firstPageNumber);
|
|
.children('.ant-table-row').should('have.length', firstPageNumber);
|
|
|
|
|
|
|
|
- cy.get('.ant-pagination').find('li[title="2"]').click();
|
|
|
|
|
|
|
+ cy.getTestId(tableName).siblings('.ant-pagination').find('li[title="2"]').click();
|
|
|
|
|
|
|
|
cy.getTestId(tableName).find('table').find('.ant-table-tbody')
|
|
cy.getTestId(tableName).find('table').find('.ant-table-tbody')
|
|
|
.children('.ant-table-row').should('have.length', secondPageNumber);
|
|
.children('.ant-table-row').should('have.length', secondPageNumber);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-export function validateTableSearch(tableName: string, value?: string) {
|
|
|
|
|
- cy.get('.ant-pagination').find('li[title="2"]').click();
|
|
|
|
|
|
|
+export function validateTableSearch(
|
|
|
|
|
+ tableName: string,
|
|
|
|
|
+ value?: string,
|
|
|
|
|
+ options?: {btnTestId?: string},
|
|
|
|
|
+) {
|
|
|
|
|
+ cy.getTestId(tableName).siblings('.ant-pagination').find('li[title="2"]').click();
|
|
|
|
|
+ const {btnTestId} = options ?? {};
|
|
|
|
|
|
|
|
return function(text?: string) {
|
|
return function(text?: string) {
|
|
|
- cy.getTestId('search_btn').click();
|
|
|
|
|
|
|
+ cy.getTestId(btnTestId ?? 'search_btn').click();
|
|
|
|
|
|
|
|
cy.getTestId(tableName).find('table').find('.ant-table-tbody')
|
|
cy.getTestId(tableName).find('table').find('.ant-table-tbody')
|
|
|
.children('.ant-table-row').first().find('td').first()
|
|
.children('.ant-table-row').first().find('td').first()
|
|
|
.should('include.text', text ?? value);
|
|
.should('include.text', text ?? value);
|
|
|
|
|
|
|
|
- cy.get('.ant-pagination').find('li[title="1"]')
|
|
|
|
|
|
|
+ cy.getTestId(tableName).siblings('.ant-pagination').find('li[title="1"]')
|
|
|
.should('have.class', 'ant-pagination-item-active');
|
|
.should('have.class', 'ant-pagination-item-active');
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-export function validatePut(modalName: string, label: string) {
|
|
|
|
|
|
|
+export function tableBtnClick(tableName: string, index: number) {
|
|
|
|
|
+ cy.getTestId(tableName).find('table').find('.ant-table-tbody')
|
|
|
|
|
+ .children('.ant-table-row').first().find('td').last().children().eq(index)
|
|
|
|
|
+ .click();
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+export function validatePut(
|
|
|
|
|
+ modalName: string,
|
|
|
|
|
+ label: string,
|
|
|
|
|
+ options?: {addBtnTestId?: string},
|
|
|
|
|
+) {
|
|
|
|
|
+ const {addBtnTestId} = options ?? {};
|
|
|
|
|
+
|
|
|
function validateBtnGroup() {
|
|
function validateBtnGroup() {
|
|
|
cy.getTestId('modal_btn_group').find('.ant-btn').first()
|
|
cy.getTestId('modal_btn_group').find('.ant-btn').first()
|
|
|
.should('have.class', 'ant-btn-loading');
|
|
.should('have.class', 'ant-btn-loading');
|
|
@@ -52,7 +69,7 @@ export function validatePut(modalName: string, label: string) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function validateAdd(fn: () => void) {
|
|
function validateAdd(fn: () => void) {
|
|
|
- cy.getTestId('add_btn').click();
|
|
|
|
|
|
|
+ cy.getTestId(addBtnTestId ?? 'add_btn').click();
|
|
|
|
|
|
|
|
cy.getTestId(modalName).should('exist').and('be.visible');
|
|
cy.getTestId(modalName).should('exist').and('be.visible');
|
|
|
cy.getTestId(modalName).find('h3')
|
|
cy.getTestId(modalName).find('h3')
|
|
@@ -69,9 +86,7 @@ export function validatePut(modalName: string, label: string) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function validateEdit(tableName: string, validateFn: () => void) {
|
|
function validateEdit(tableName: string, validateFn: () => void) {
|
|
|
- cy.getTestId(tableName).find('table').find('.ant-table-tbody')
|
|
|
|
|
- .children('.ant-table-row').first().find('td').last().find('.ant-btn')
|
|
|
|
|
- .first().click();
|
|
|
|
|
|
|
+ tableBtnClick(tableName, 0);
|
|
|
|
|
|
|
|
cy.getTestId(modalName).should('exist').and('be.visible');
|
|
cy.getTestId(modalName).should('exist').and('be.visible');
|
|
|
cy.getTestId(modalName).find('h3').should('include.text', `修改${label}`);
|
|
cy.getTestId(modalName).find('h3').should('include.text', `修改${label}`);
|
|
@@ -89,12 +104,20 @@ export function validatePut(modalName: string, label: string) {
|
|
|
return {validateAdd, validateEdit};
|
|
return {validateAdd, validateEdit};
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-export function validateDelete(tableName: string) {
|
|
|
|
|
- cy.getTestId(tableName).find('table').find('.ant-table-tbody')
|
|
|
|
|
- .children('.ant-table-row').first().find('td').last().children().eq(1)
|
|
|
|
|
- .click();
|
|
|
|
|
|
|
+export function validateDelete(
|
|
|
|
|
+ tableName: string,
|
|
|
|
|
+ label: string,
|
|
|
|
|
+) {
|
|
|
|
|
+ tableBtnClick(tableName, 1);
|
|
|
|
|
|
|
|
cy.get('.ant-modal-content').should('be.visible');
|
|
cy.get('.ant-modal-content').should('be.visible');
|
|
|
|
|
+
|
|
|
|
|
+ cy.get('.ant-modal-confirm-title').should('include.text', `删除${label}`);
|
|
|
|
|
+ cy.get('.ant-modal-confirm-content').should(
|
|
|
|
|
+ 'include.text',
|
|
|
|
|
+ `你确定要删除当前${label}吗?`,
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
cy.get('.ant-modal-confirm-btns').children().last().trigger('click');
|
|
cy.get('.ant-modal-confirm-btns').children().last().trigger('click');
|
|
|
|
|
|
|
|
cy.getTestId(tableName).find('table').find('.ant-table-tbody')
|
|
cy.getTestId(tableName).find('table').find('.ant-table-tbody')
|