123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- /**
- * Auth Mock Handlers
- * 认证相关的 mock 处理器
- */
- /**
- * 修改密码 - 成功场景
- *
- * @description 修改当前用户自己的密码
- * @method POST
- * @url /api/v1/auth/settings/password
- * @access 需要认证
- *
- * @param {Object} requestBody - 请求体
- * @param {string} requestBody.old_password - 旧密码
- * @param {string} requestBody.new_password - 新密码
- * @param {string} requestBody.confirm_new_password - 确认密码
- *
- * @returns {Object} 成功响应
- *
- * @example
- * mockChangePasswordSuccess();
- * cy.get('[name="old_password"]').type('123456');
- * cy.get('[name="new_password"]').type('newPassword123');
- * cy.get('[name="confirm_new_password"]').type('newPassword123');
- * cy.get('[type="submit"]').click();
- * cy.wait('@changePasswordSuccess');
- *
- * @see docs/DR.md - 章节8
- */
- export function mockChangePasswordSuccess() {
- cy.intercept('POST', '/api/v1/auth/settings/password', {
- statusCode: 200,
- body: {
- code: "0x000000",
- description: "Success",
- solution: "",
- data: {}
- }
- }).as('changePasswordSuccess');
- }
- /**
- * 修改密码 - 旧密码错误
- *
- * @description 修改密码失败,旧密码不正确
- * @method POST
- * @url /api/v1/auth/settings/password
- * @access 需要认证
- *
- * @returns {Object} 错误响应
- * @returns {string} code - 错误码
- * @returns {string} description - 错误描述
- *
- * @example
- * mockChangePasswordWrongOldPassword();
- * cy.wait('@changePasswordWrongOldPassword');
- *
- * @see docs/DR.md - 章节8
- */
- export function mockChangePasswordWrongOldPassword() {
- cy.intercept('POST', '/api/v1/auth/settings/password', {
- statusCode: 200,
- body: {
- code: "0x000002",
- description: "Old password is incorrect",
- solution: "Please check your old password",
- data: {}
- }
- }).as('changePasswordWrongOldPassword');
- }
- /**
- * 修改密码 - 新密码不匹配
- *
- * @description 修改密码失败,新密码和确认密码不匹配
- * @method POST
- * @url /api/v1/auth/settings/password
- * @access 需要认证
- *
- * @returns {Object} 错误响应
- * @returns {string} code - 错误码
- * @returns {string} description - 错误描述
- *
- * @example
- * mockChangePasswordNotMatch();
- * cy.wait('@changePasswordNotMatch');
- *
- * @see docs/DR.md - 章节8
- */
- export function mockChangePasswordNotMatch() {
- cy.intercept('POST', '/api/v1/auth/settings/password', {
- statusCode: 200,
- body: {
- code: "0x000003",
- description: "New password and confirmation do not match",
- solution: "Please ensure both passwords are the same",
- data: {}
- }
- }).as('changePasswordNotMatch');
- }
|