jsketcher/test/cypress/support/commands.js
2020-05-20 00:07:33 -07:00

49 lines
1.2 KiB
JavaScript

import modellerUISubject from "../../coreTests/subjects/modellerTPI";
Cypress.Commands.add("openModeller", () => {
return cy.visit("http://localhost:3000?test&LOG.PICK=true");
});
Cypress.Commands.add("getActionButton", (actionId) => {
return cy.get(`[data-action-id='${actionId}']`);
});
Cypress.Commands.add("getMenu", (menuId) => {
return cy.get(`[data-menu-id='${menuId}']`);
});
Cypress.Commands.add("getActiveWizardField", (fieldName) => {
return cy.get(`.wizard [data-field-name='${fieldName}']`);
});
Cypress.Commands.add("selectRaycasting", (from, to) => {
return cy.window().then(win => {
win.__CAD_APP.services.pickControl.simulatePickFromRay(from, to);
win.__DEBUG__.AddSegment3(from, to);
});
});
Cypress.Commands.add("simulateClickByRayCast", (from, to) => {
cy.getModellerTPI().then(tpi => {
tpi.simulateClickByRayCast(from, to);
tpi.__DEBUG__.AddSegment3(from, to);
});
});
Cypress.Commands.add("openSketcher", () => {
return cy.getModellerTPI().then(tpi => tpi.openSketcher());
});
Cypress.Commands.add("commitSketch", () => {
return cy.getModellerTPI().then(tpi => tpi.commitSketch());
});
Cypress.Commands.add("getModellerTPI", () => {
return cy.window().then(win => modellerUISubject(win.__CAD_APP));
});