seitime-frappe/frappe/tests/ui/test_control_geolocation.js
Revant Nandgaonkar ebf3554754 Geolocation control (#4327)
* added static map field

* leaflet draw plugin added to map control

* Editable layer working no icons

* Save and load data in form field

* images and icons working

* Locate plugin added, and loads on geolocation

* organized map control code

* loads layer as per form

* new form clears editableLayers

* update: leaflet 1.2.0 and leaflet-draw 0.4.2

* changed to ERPNext colors

* Multiple map fields and fixes

* fixes codacy suggestions

* loaded geojson data editable

* Map layers editable

* add only one layer on draw:create

* code organized with helper functions

* Replaced Leaflet Draw with Leaflet Editable

* read values from database

* layers saved in db

* Using Patched Leaflet Draw (mobile-friendly)

* Working Map field with multiple forms open

* Leaflet Draw css image path fix

* Leaflet Draw

Fixes Leaflet draw css image paths
Fixes Circle marker and Circle

* locate to geolocation or set featurecollection as center

* [fix] leaflet fitBounds padding 50,50

* [Fix] Leaflet (auto) locate

* Map field basic test

* added refresh button on map

* Mute map geojson in print format

* renamed Map field to Geolocation

* Suggested changes and fixes

* eslint disable

* csslint allow important
2017-10-25 18:30:25 +05:30

39 lines
947 B
JavaScript

QUnit.module('controls');
QUnit.test("Test ControlGeolocation", function(assert) {
assert.expect(1);
const random_name = frappe.utils.get_random(3).toLowerCase();
let done = assert.async();
// geolocation alert dialog suppressed (only secure origins or localhost allowed)
window.alert = function() {
console.log.apply(console, arguments); //eslint-disable-line
};
frappe.run_serially([
() => {
return frappe.tests.make('Custom Field', [
{dt: 'ToDo'},
{fieldtype: 'Geolocation'},
{label: random_name},
]);
},
() => frappe.set_route('List', 'ToDo'),
() => frappe.new_doc('ToDo'),
() => {
if (frappe.quick_entry)
{
frappe.quick_entry.dialog.$wrapper.find('.edit-full').click();
return frappe.timeout(1);
}
},
() => {
const control = $(`.frappe-control[data-fieldname="${random_name}"]`);
return assert.ok(control.data('fieldtype') === 'Geolocation');
},
() => done()
]);
});