123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- import {
- beforeSetup,
- exportIntercept,
- generateNetworkResult,
- intercept,
- intoMenu,
- normalIntercept,
- selectAllFilters,
- successIntercept,
- tableBtnClick,
- validateDelete,
- validateDialog,
- validateExport,
- validateMessageContent,
- validateModalBtnGroup,
- validatePut,
- validateTableList,
- validateTableSearch,
- } from './utils';
- const basicData = {
- id: '83',
- code: 'YH000083',
- userName: 'admin2',
- password: 'F6BE46C2F900E518',
- newPassword: null,
- realName: '测试2',
- email: '1211@163.com',
- landline: null,
- phone: '1336131680',
- department: '采购中心(公共) ',
- role: 'test账户',
- roleId: '11',
- departmentId: '00029999',
- createTime: '2023-04-03 14:01:45',
- token: null,
- modifyUser: 'admin',
- modifyTime: '2023-04-03 14:18:21',
- page: 0,
- limit: 0,
- menu: '78,93,88,79,',
- menuBefore: '78,93,88,79,',
- };
- const TABLE_NAME = 'user_table',
- MODAL_NAME = 'user_add_modal',
- LABEL = '用户',
- TOOL_ID = 'user_filter';
- describe('首页', function() {
- beforeEach(function() {
- beforeSetup();
- intoMenu('系统设置', '用户管理');
- });
- beforeEach(function() {
- intercept('/user/getAllUser', function({search, reply}) {
- generateNetworkResult({search, reply, basicData, title: 'code'});
- });
- exportIntercept('/user/resetPassword');
- successIntercept([
- '/user/addUser',
- '/user/updateUser',
- '/user/delUser',
- '/user/resetPassword',
- ]);
- normalIntercept('/menu/getMenu', 'menu/all');
- });
- it('table', function() {
- selectAllFilters(TOOL_ID, 8);
- validateTableList(TABLE_NAME);
- validateTableSearch(
- TABLE_NAME,
- [
- 'userName',
- 'realName',
- 'code',
- {id: 'department', type: 'select', value: '00029999'},
- 'role',
- 'email',
- 'phone',
- 'modifyUser',
- ],
- {toolId: TOOL_ID, url: '/user/getAllUser'},
- );
- });
- it('operation', function() {
- validateExport(TABLE_NAME);
- const {validateAdd, validateEdit} = validatePut(MODAL_NAME, TABLE_NAME, {
- label: LABEL,
- });
- validateAdd([
- 'userName',
- 'userRealName',
- 'userPassword',
- {id: 'userDepartment', type: 'select'},
- {id: 'userRole', type: 'select'},
- 'userEmail',
- 'userPhone',
- ]);
- validateEdit([
- {id: 'userName', type: 'field', value: basicData.userName},
- {id: 'userRealName', type: 'field', value: basicData.realName},
- {id: 'userDepartment', type: 'select', value: basicData.department},
- {id: 'userRole', type: 'select', value: basicData.role},
- {id: 'userEmail', type: 'field', value: basicData.email},
- {id: 'userPhone', type: 'field', value: basicData.phone},
- ]);
- // 设置菜单权限
- tableBtnClick(TABLE_NAME, 1);
- cy.getTestId('user_tree_modal')
- .find('h3')
- .should('include.html', '菜单权限');
- cy.getTestId('user_tree_modal').should('exist').and('be.visible');
- cy.getTestId('user_tree')
- .find('.ant-tree-list-holder-inner')
- .find('.ant-tree-treenode')
- .each(function(res, idx) {
- idx <= 3
- ? expect(res.hasClass('ant-tree-treenode-checkbox-checked')).to.true
- : expect(res.hasClass('ant-tree-treenode-checkbox-checked')).to.false;
- })
- .should('have.length', 17);
- cy.getTestId('user_tree_modal').find('form').submit();
- validateModalBtnGroup('user_tree_modal');
- cy.get('.ant-message-notice-content').should('include.text', '设置成功');
- cy.getTestId('user_tree_modal').should('not.exist');
- // 重置密码
- const resetBtn = tableBtnClick(TABLE_NAME, 2);
- validateDialog('重置密码', '你确定要将测试2的密码重置为123456吗?');
- resetBtn().should('have.class', 'ant-btn-loading');
- validateMessageContent('重置成功');
- validateDelete(TABLE_NAME, LABEL, {eq: 3, title: 'admin2'});
- });
- });
|