|
@@ -129,8 +129,15 @@ export function mockDeviceActionSuccess() {
|
|
* cy.wait('@resetDevice');
|
|
* cy.wait('@resetDevice');
|
|
*/
|
|
*/
|
|
export function mockResetDeviceSuccess() {
|
|
export function mockResetDeviceSuccess() {
|
|
- cy.intercept('POST', '*/auth/device/action', (req) => {
|
|
|
|
- if (req.body.reqName === 'RESET') {
|
|
|
|
|
|
+ cy.intercept('POST', '**/auth/device/action', (req) => {
|
|
|
|
+ console.log('[Mock] Intercepted device action:', {
|
|
|
|
+ url: req.url,
|
|
|
|
+ reqName: req.body?.reqName,
|
|
|
|
+ deviceUri: req.body?.deviceUri,
|
|
|
|
+ body: req.body
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ if (req.body?.reqName === 'RESET') {
|
|
req.reply({
|
|
req.reply({
|
|
statusCode: 200,
|
|
statusCode: 200,
|
|
body: {
|
|
body: {
|
|
@@ -139,6 +146,9 @@ export function mockResetDeviceSuccess() {
|
|
data: {}
|
|
data: {}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
+ } else {
|
|
|
|
+ // 非 RESET 请求,让它继续执行
|
|
|
|
+ req.continue();
|
|
}
|
|
}
|
|
}).as('resetDevice');
|
|
}).as('resetDevice');
|
|
}
|
|
}
|
|
@@ -164,12 +174,24 @@ export function mockResetDeviceFail(
|
|
errorCode: string = '0x010001',
|
|
errorCode: string = '0x010001',
|
|
description: string = '设备通信失败'
|
|
description: string = '设备通信失败'
|
|
) {
|
|
) {
|
|
- cy.intercept('POST', '/auth/device/action', {
|
|
|
|
- statusCode: 200,
|
|
|
|
- body: {
|
|
|
|
- code: errorCode,
|
|
|
|
- description: description,
|
|
|
|
- solution: '检查设备连接'
|
|
|
|
|
|
+ cy.intercept('POST', '**/auth/device/action', (req) => {
|
|
|
|
+ console.log('[Mock] Intercepted device action (fail):', {
|
|
|
|
+ url: req.url,
|
|
|
|
+ reqName: req.body?.reqName,
|
|
|
|
+ body: req.body
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ if (req.body?.reqName === 'RESET') {
|
|
|
|
+ req.reply({
|
|
|
|
+ statusCode: 200,
|
|
|
|
+ body: {
|
|
|
|
+ code: errorCode,
|
|
|
|
+ description: description,
|
|
|
|
+ solution: '检查设备连接'
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ req.continue();
|
|
}
|
|
}
|
|
}).as('resetDeviceFail');
|
|
}).as('resetDeviceFail');
|
|
}
|
|
}
|
|
@@ -189,9 +211,17 @@ export function mockResetDeviceFail(
|
|
* cy.wait('@resetDeviceNetworkError');
|
|
* cy.wait('@resetDeviceNetworkError');
|
|
*/
|
|
*/
|
|
export function mockResetDeviceNetworkError() {
|
|
export function mockResetDeviceNetworkError() {
|
|
- cy.intercept('POST', '/auth/device/action', (req) => {
|
|
|
|
- if (req.body.reqName === 'RESET') {
|
|
|
|
|
|
+ cy.intercept('POST', '**/auth/device/action', (req) => {
|
|
|
|
+ console.log('[Mock] Intercepted device action (network error):', {
|
|
|
|
+ url: req.url,
|
|
|
|
+ reqName: req.body?.reqName,
|
|
|
|
+ body: req.body
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ if (req.body?.reqName === 'RESET') {
|
|
req.reply({ forceNetworkError: true });
|
|
req.reply({ forceNetworkError: true });
|
|
|
|
+ } else {
|
|
|
|
+ req.continue();
|
|
}
|
|
}
|
|
}).as('resetDeviceNetworkError');
|
|
}).as('resetDeviceNetworkError');
|
|
}
|
|
}
|
|
@@ -213,8 +243,15 @@ export function mockResetDeviceNetworkError() {
|
|
* cy.wait('@resetDeviceDelay');
|
|
* cy.wait('@resetDeviceDelay');
|
|
*/
|
|
*/
|
|
export function mockResetDeviceDelay(delayMs: number) {
|
|
export function mockResetDeviceDelay(delayMs: number) {
|
|
- cy.intercept('POST', '/auth/device/action', (req) => {
|
|
|
|
- if (req.body.reqName === 'RESET') {
|
|
|
|
|
|
+ cy.intercept('POST', '**/auth/device/action', (req) => {
|
|
|
|
+ console.log('[Mock] Intercepted device action (delay):', {
|
|
|
|
+ url: req.url,
|
|
|
|
+ reqName: req.body?.reqName,
|
|
|
|
+ body: req.body,
|
|
|
|
+ delay: delayMs
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ if (req.body?.reqName === 'RESET') {
|
|
req.reply({
|
|
req.reply({
|
|
statusCode: 200,
|
|
statusCode: 200,
|
|
body: {
|
|
body: {
|
|
@@ -224,6 +261,8 @@ export function mockResetDeviceDelay(delayMs: number) {
|
|
},
|
|
},
|
|
delay: delayMs
|
|
delay: delayMs
|
|
});
|
|
});
|
|
|
|
+ } else {
|
|
|
|
+ req.continue();
|
|
}
|
|
}
|
|
}).as('resetDeviceDelay');
|
|
}).as('resetDeviceDelay');
|
|
}
|
|
}
|