UNPKG

@geogebra/web-test-harness

Version:

Commands for Geogebra UI tests

48 lines (37 loc) 1.59 kB
const {addMatchImageSnapshotCommand} = require('@simonsmith/cypress-image-snapshot/command'); const {selectors} = require('./selectors'); exports.addGeoGebraCommands = () => { addMatchImageSnapshotCommand(); Cypress.Commands.add('writeInAVInput', {}, (text) => { selectors.algebraInput.get().focus().type(text, {force: true}); }); Cypress.Commands.add('expectGgbValue', {}, (key, value) => { cy.window().then((win) => expect(win.ggbApplet.getValue(key)).to.equal(value)); }); Cypress.Commands.add('expectGgbString', {}, (key, value) => { cy.window().then((win) => expect(win.ggbApplet.getValueString(key)).to.equal(value)); }); Cypress.Commands.add('setBase64', {}, (data) => { cy.window().then((win) => win.ggbApplet.setBase64(data)); }); Cypress.Commands.add('mouseEvent', {prevSubject: true}, (subject, event, x, y) => { const options = { force: true, pointerType: 'mouse', }; if (typeof x !== 'undefined' && typeof y !== 'undefined') { options.offsetX = x; options.offsetY = y; } return cy.wrap(subject).trigger('pointer' + event, options).wait(100); }); Cypress.Commands.add('setSaved', {}, () => { cy.window().then((win) => { const setSaved = (win.mainApplet || win.ggbApplet || {}).setSaved; setSaved && setSaved(); }); }); Cypress.Commands.add('skipDialog', {}, () => { cy.setCookie('RecentChangesRecentChangesInfo.GraphingShown', 'true'); }); };