///
// ***********************************************
// This example commands.ts shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
//
// declare global {
// namespace Cypress {
// interface Chainable {
// login(email: string, password: string): Chainable
// drag(subject: string, options?: Partial): Chainable
// dismiss(subject: string, options?: Partial): Chainable
// visit(originalFn: CommandOriginalFn, url: string, options: Partial): Chainable
// }
// }
// }
Cypress.Commands.add("networkStub", () => {
cy.intercept("POST", "/api/login", "true");
cy.intercept("POST", "/api/mark/clear", "true");
cy.intercept("POST", "/api/mark/updateSetting", "true");
cy.intercept("GET", "/api/mark/subject-select", "true");
cy.intercept("POST", "/api/mark/subject-select", "true");
cy.intercept(
"POST",
"/api/mark/subject/query",
`[
{
"id": 426,
"subjectCode": "431",
"subjectName": "金融学综合"
}
]`
);
cy.intercept("POST", "/api/mark/getSetting", {
fixture: "settings-1.json",
}).as("setting");
cy.intercept("POST", "/api/mark/getStatus", {
fixture: "status-1.json",
});
cy.intercept("POST", "/api/mark/getGroup", {
fixture: "groups-1.json",
});
cy.intercept("POST", "/api/mark/getTask", {
fixture: "task-1.json",
}).as("task");
cy.intercept("GET", "/api/slice/**", (req) => {
function getFixtureFilenameForUrl(url: string) {
return "assets/" + url.split("/").pop() + ",null";
}
const fixtureFilename = getFixtureFilenameForUrl(req.url);
req.reply({ fixture: fixtureFilename });
});
});