chore: move browser tests to playwright
This commit is contained in:
parent
e44e0df69a
commit
2271669e80
3 changed files with 46 additions and 90 deletions
|
@ -18,67 +18,6 @@ describe('L.U.Controls', () => {
|
|||
resetMap()
|
||||
})
|
||||
|
||||
describe('#databrowser()', () => {
|
||||
let poly, marker, line
|
||||
before(() => {
|
||||
datalayer.eachLayer(function (layer) {
|
||||
if (!poly && layer instanceof L.Polygon) {
|
||||
poly = layer
|
||||
} else if (!line && layer instanceof L.Polyline) {
|
||||
line = layer
|
||||
} else if (!marker && layer instanceof L.Marker) {
|
||||
marker = layer
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('should be opened at datalayer button click', () => {
|
||||
var button = qs('.umap-browse-actions .umap-browse-link')
|
||||
assert.ok(button)
|
||||
happen.click(button)
|
||||
assert.ok(qs('#umap-ui-container .umap-browse-data'))
|
||||
})
|
||||
|
||||
it('should contain datalayer section', () => {
|
||||
assert.ok(qs('#browse_data_datalayer_62'))
|
||||
})
|
||||
|
||||
it("should contain datalayer's features list", () => {
|
||||
assert.equal(qsa('#browse_data_datalayer_62 ul li').length, 3)
|
||||
})
|
||||
|
||||
it('should sort feature in natural order', () => {
|
||||
poly.properties.name = '9. a poly'
|
||||
marker.properties.name = '1. a marker'
|
||||
line.properties.name = '100. a line'
|
||||
datalayer.reindex()
|
||||
map.openBrowser()
|
||||
const els = qsa('.umap-browse-features li')
|
||||
assert.equal(els.length, 3)
|
||||
assert.equal(els[0].textContent, '1. a marker')
|
||||
assert.equal(els[1].textContent, '9. a poly')
|
||||
assert.equal(els[2].textContent, '100. a line')
|
||||
})
|
||||
|
||||
it("should redraw datalayer's features list at feature delete", () => {
|
||||
var oldConfirm = window.confirm
|
||||
window.confirm = () => {
|
||||
return true
|
||||
}
|
||||
enableEdit()
|
||||
happen.once(qs('path[fill="DarkBlue"]'), { type: 'contextmenu' })
|
||||
happen.click(qs('.leaflet-contextmenu .umap-delete'))
|
||||
assert.equal(qsa('#browse_data_datalayer_62 ul li').length, 2)
|
||||
window.confirm = oldConfirm
|
||||
})
|
||||
|
||||
it("should redraw datalayer's features list on edit cancel", () => {
|
||||
clickCancel()
|
||||
happen.click(qs('.umap-browse-actions .umap-browse-link'))
|
||||
assert.equal(qsa('#browse_data_datalayer_62 ul li').length, 3)
|
||||
})
|
||||
})
|
||||
|
||||
describe('#exportPanel()', () => {
|
||||
it('should be opened at datalayer button click', () => {
|
||||
let button = qs('.leaflet-control-embed button')
|
||||
|
|
|
@ -333,35 +333,6 @@ describe('L.U.FeatureMixin', function () {
|
|||
})
|
||||
})
|
||||
|
||||
describe('#quick-delete()', function () {
|
||||
let poly, _confirm
|
||||
before(function () {
|
||||
_confirm = window.confirm
|
||||
window.confirm = function (text) {
|
||||
return true
|
||||
}
|
||||
|
||||
datalayer.eachLayer(function (layer) {
|
||||
if (!poly && layer instanceof L.Polygon) {
|
||||
poly = layer
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
after(function () {
|
||||
window.confirm = _confirm
|
||||
})
|
||||
|
||||
it('should allow to delete from data browser', function () {
|
||||
enableEdit()
|
||||
assert.ok(qs('path[fill="DarkBlue"]'))
|
||||
map.openBrowser()
|
||||
happen.click(qs('.feature-delete'))
|
||||
assert.notOk(qs('path[fill="DarkBlue"]'))
|
||||
clickCancel()
|
||||
})
|
||||
})
|
||||
|
||||
describe('#changeDataLayer()', function () {
|
||||
it('should change style on datalayer select change', function () {
|
||||
enableEdit()
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
from copy import deepcopy
|
||||
from time import sleep
|
||||
|
||||
import pytest
|
||||
from playwright.sync_api import expect
|
||||
|
||||
from umap.models import Map
|
||||
|
||||
from ..base import DataLayerFactory
|
||||
|
||||
pytestmark = pytest.mark.django_db
|
||||
|
@ -170,3 +173,46 @@ def test_data_browser_with_variable_in_name(live_server, page, bootstrap, map):
|
|||
expect(page.get_by_text("one point in france (point)")).to_be_visible()
|
||||
expect(page.get_by_text("one line in new zeland (line)")).to_be_visible()
|
||||
expect(page.get_by_text("one polygon in greenland (polygon)")).to_be_visible()
|
||||
|
||||
|
||||
def test_can_open_databrowser_from_layers_list(live_server, map, page, bootstrap):
|
||||
page.goto(f"{live_server.url}{map.get_absolute_url()}")
|
||||
page.get_by_title("See data layers").click()
|
||||
page.get_by_role("button", name="Browse data").click()
|
||||
browser = page.locator(".umap-browse-data")
|
||||
expect(browser).to_be_visible()
|
||||
expect(browser.get_by_text("test datalayer")).to_be_visible()
|
||||
expect(browser.get_by_text("one point in france")).to_be_visible()
|
||||
expect(browser.get_by_text("one line in new zeland")).to_be_visible()
|
||||
expect(browser.get_by_text("one polygon in greenland")).to_be_visible()
|
||||
|
||||
|
||||
def test_should_sort_features_in_natural_order(live_server, map, page):
|
||||
map.settings["properties"]["onLoadPanel"] = "databrowser"
|
||||
map.save()
|
||||
datalayer_data = deepcopy(DATALAYER_DATA)
|
||||
datalayer_data["features"][0]["properties"]["name"] = "9. a marker"
|
||||
datalayer_data["features"][1]["properties"]["name"] = "1. a poly"
|
||||
datalayer_data["features"][2]["properties"]["name"] = "100. a line"
|
||||
DataLayerFactory(map=map, data=datalayer_data)
|
||||
page.goto(f"{live_server.url}{map.get_absolute_url()}")
|
||||
features = page.locator(".umap-browse-data li")
|
||||
expect(features).to_have_count(3)
|
||||
expect(features.nth(0)).to_have_text("1. a poly")
|
||||
expect(features.nth(1)).to_have_text("9. a marker")
|
||||
expect(features.nth(2)).to_have_text("100. a line")
|
||||
|
||||
|
||||
def test_should_redraw_list_on_feature_delete(live_server, map, page, bootstrap):
|
||||
map.edit_status = Map.ANONYMOUS
|
||||
map.save()
|
||||
page.goto(f"{live_server.url}{map.get_absolute_url()}")
|
||||
# Enable edit
|
||||
page.get_by_role("button", name="Edit").click()
|
||||
buttons = page.locator(".umap-browse-data li .feature-delete")
|
||||
expect(buttons).to_have_count(3)
|
||||
page.on("dialog", lambda dialog: dialog.accept())
|
||||
buttons.nth(0).click()
|
||||
expect(buttons).to_have_count(2)
|
||||
page.get_by_role("button", name="Cancel edits").click()
|
||||
expect(buttons).to_have_count(3)
|
||||
|
|
Loading…
Reference in a new issue