12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- /// <reference types="cypress" />
- // ***********************************************
- // 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<void>
- // drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
- // dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
- // visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
- // }
- // }
- // }
- Cypress.Commands.add("networkStub", () => {
- cy.intercept("POST", "/login", "true");
- cy.intercept("POST", "/mark/clear", "true");
- cy.intercept("POST", "/mark/updateSetting", "true");
- cy.intercept("GET", "/mark/subject-select", "true");
- cy.intercept("POST", "/mark/subject-select", "true");
- cy.intercept(
- "POST",
- "/mark/subject/query",
- `[
- {
- "id": 426,
- "subjectCode": "431",
- "subjectName": "金融学综合"
- }
- ]`
- );
- cy.intercept("POST", "/mark/getSetting", {
- fixture: "settings-1.json",
- });
- cy.intercept("POST", "/mark/getStatus", {
- fixture: "status-1.json",
- });
- cy.intercept("POST", "/mark/getGroup", {
- fixture: "groups-1.json",
- });
- cy.intercept("POST", "/mark/getTask", {
- fixture: "task-1.json",
- });
- cy.intercept("GET", "/slice/**", (req) => {
- function getFixtureFilenameForUrl(url: string) {
- return "assets/" + url.split("/").pop() + ",null";
- }
- const fixtureFilename = getFixtureFilenameForUrl(req.url);
- req.reply({ fixture: fixtureFilename });
- });
- });
|