mirror of
https://bitbucket.org/wisemapping/wisemapping-frontend.git
synced 2024-11-25 23:54:55 +01:00
cb2ca74a20
Core-js, web2d and mindplot working baseline * fix .eslintignore remove Raphael dependency * Fix to avoid crashes in _plotPrediction whitout Raphael * Fix minplot basic code inspections * Fix last inspections errors * Inital refactor copying files * Clean up. * Fix web2d cyclic dependencies remove only-warn eslint plugin set import/no-extraneous-dependencies to warn (incorrectly complaining about root package) * Fix web2d Point references (no need to assign it to core) Fix web2d imports in mindplot and update Point refs * Merge 'feature/mindplot_tests' into web2d-coreJS-solutions * mindplot fixes and add viewmode.html playground setup playground config to run the map-render examples fix mindplot components export mootools Static was not working so refactored it fix some references to _peer fix messages __bundle undefined add web2d missing export: Image downgrade cypress to avoid SIGSEGV error Approved-by: Paulo Veiga
144 lines
4.8 KiB
JavaScript
144 lines
4.8 KiB
JavaScript
TestCase('Mindplot test', {
|
|
setUp() {
|
|
/*: DOC += <div id="mindplot"></div> */
|
|
const mapId = '1';
|
|
const mapXml = '<map name="1" version="pela"><topic central="true" text="test" id="1"><topic position="103,-52" order="" id="2"/><topic position="-134,-75" order="" id="3"/><topic position="-126,5" order="" id="4"/><topic position="-115,53" order="" id="5"/><topic position="-136,-35" order="" id="6"/></topic></map>';
|
|
const editorProperties = { zoom: 0.7 };
|
|
const isTryMode = false;
|
|
|
|
afterMindpotLibraryLoading = function () {
|
|
buildMindmapDesigner();
|
|
|
|
// Register Events ...
|
|
// document.id(document).addEvent('keydown', designer.keyEventHandler.bindWithEvent(designer));
|
|
|
|
/* // Autosave ...
|
|
if (!isTryMode)
|
|
{
|
|
var autosave = function() {
|
|
|
|
if (designer.needsSave())
|
|
{
|
|
designer.save(function()
|
|
{
|
|
// var monitor = core.ToolbarNotifier.getInstance();
|
|
}, false);
|
|
}
|
|
};
|
|
autosave.periodical(30000);
|
|
|
|
// To prevent the user from leaving the page with changes ...
|
|
window.onbeforeunload = function confirmExit()
|
|
{
|
|
if (designer.needsSave())
|
|
{
|
|
designer.save(null, false)
|
|
}
|
|
}
|
|
} */
|
|
};
|
|
|
|
var buildMindmapDesigner = function () {
|
|
// Initialize message logger ...
|
|
const container = document.id('mindplot');
|
|
|
|
// Initialize Editor ...
|
|
|
|
const screenWidth = window.getWidth();
|
|
let screenHeight = window.getHeight();
|
|
|
|
// Positionate node ...
|
|
// header - footer
|
|
screenHeight = screenHeight - 90 - 61;
|
|
|
|
// body margin ...
|
|
editorProperties.width = screenWidth;
|
|
editorProperties.height = screenHeight;
|
|
|
|
designer = new mindplot.Designer(editorProperties, container);
|
|
designer.loadFromXML(mapId, mapXml);
|
|
|
|
/* // Save map on load ....
|
|
if (editorProperties.saveOnLoad)
|
|
{
|
|
var saveOnLoad = function() {
|
|
designer.save(function() {
|
|
}, false);
|
|
}.delay(1000)
|
|
} */
|
|
};
|
|
afterMindpotLibraryLoading();
|
|
},
|
|
testWorkspaceBuild() {
|
|
assertNotNull(document.id('workspace'));
|
|
},
|
|
testCentralTopicPresent() {
|
|
const centralTopic = designer.getCentralTopic();
|
|
assertNotNull(centralTopic);
|
|
const position = centralTopic.getPosition();
|
|
assertEquals(0, position.x);
|
|
assertEquals(0, position.y);
|
|
},
|
|
testMouseCreateMainTopic() {
|
|
const centralTopic = designer.getCentralTopic();
|
|
assertNotNull(centralTopic);
|
|
const target = designer.getWorkSpace().getScreenManager().getContainer();
|
|
const size = designer.getModel().getTopics().length;
|
|
fireNativeEvent('dblclick', target, new web2d.Point(50, 50));
|
|
assertEquals(size + 1, designer.getModel().getTopics().length);
|
|
},
|
|
});
|
|
|
|
var fireNativeEvent = function (type, target, position) {
|
|
let event;
|
|
if (Browser.ie) {
|
|
event = document.createEventObject();
|
|
event.screenX = position.x;
|
|
event.screenY = position.y;
|
|
target.dispatchEvent(event);
|
|
} else {
|
|
let eventFamily;
|
|
if (
|
|
type == 'click'
|
|
|| type == 'mousedown'
|
|
|| type == 'mousemove'
|
|
|| type == 'mouseout'
|
|
|| type == 'mouseover'
|
|
|| type == 'mouseup'
|
|
|| type == 'dblclick'
|
|
) { eventFamily = 'MouseEvents'; } else if (
|
|
type == 'keydown'
|
|
|| type == 'keypress'
|
|
|| type == 'keyup'
|
|
|| type == 'DOMActivate'
|
|
|| type == 'DOMFocusIn'
|
|
|| type == 'DOMFocusOut'
|
|
) { eventFamily = 'UIEvents'; } else if (
|
|
type == 'abort'
|
|
|| type == 'blur'
|
|
|| type == 'change'
|
|
|| type == 'error'
|
|
|| type == 'focus'
|
|
|| type == 'load'
|
|
|| type == 'reset'
|
|
|| type == 'resize'
|
|
|| type == 'scroll'
|
|
|| type == 'select'
|
|
|| type == 'submit'
|
|
|| type == 'unload'
|
|
) { eventFamily = 'HTMLEvents'; } else if (
|
|
type == 'DOMAttrModified'
|
|
|| type == 'DOMNodeInserted'
|
|
|| type == 'DOMNodeRemoved'
|
|
|| type == 'DOMCharacterDataModified'
|
|
|| type == 'DOMNodeInsertedIntoDocument'
|
|
|| type == 'DOMNodeRemovedFromDocument'
|
|
|| type == 'DOMSubtreeModified'
|
|
) { eventFamily = 'MutationEvents'; } else eventFamily = 'Events';
|
|
event = document.createEvent(eventFamily);
|
|
event.initEvent(type, true, false, target, 0, position.x, position.y);
|
|
target.fireEvent(type, event);
|
|
}
|
|
return event;
|
|
};
|