123456789101112131415161718192021222324252627282930313233343536 |
- // User-related mock handlers
- // 封装登录成功的 mock
- export function mockLoginSuccess() {
- cy.intercept('POST', '/dr/api/v1/pub/login', (req) => {
- req.reply({
- statusCode: 200,
- body: {
- code: "0x000000",
- description: "Success",
- solution: "",
- data: {
- token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
- expire: 1751277588,
- uid: 1,
- name: "admin",
- avatar: ""
- }
- }
- });
- }).as('loginSuccess');
- }
- // 封装登录失败的 mock
- export function mockLoginFail() {
- cy.intercept('POST', '/dr/api/v1/pub/login', (req) => {
- req.reply({
- statusCode: 200, // 一般还是200,通过 code 区分失败
- body: {
- code: "0x000001",
- description: "Invalid username or password",
- solution: "Please check your credentials",
- data: {}
- }
- });
- }).as('loginFail');
- }
|