diff --git a/umap/static/umap/test/Controls.js b/umap/static/umap/test/Controls.js deleted file mode 100644 index a3227480..00000000 --- a/umap/static/umap/test/Controls.js +++ /dev/null @@ -1,43 +0,0 @@ -describe('L.U.Controls', () => { - let map, datalayer - before(async () => { - await fetchMock.mock( - /\/datalayer\/62\/\?.*/, - JSON.stringify(RESPONSES.datalayer62_GET) - ) - this.options = { - umap_id: 99, - } - MAP = map = initMap({ umap_id: 99 }) - const datalayer_options = defaultDatalayerData() - await map.initDataLayers([datalayer_options]) - datalayer = map.getDataLayerByUmapId(62) - }) - after(() => { - fetchMock.restore() - resetMap() - }) - - describe('#exportPanel()', () => { - it('should be opened at datalayer button click', () => { - let button = qs('.leaflet-control-embed button') - assert.ok(button) - happen.click(button) - assert.ok(qs('#umap-ui-container .umap-share')) - }) - it('should update iframe link', () => { - let textarea = qs('.umap-share-iframe') - assert.ok(textarea) - console.log(textarea.textContent) - assert.include(textarea.textContent, 'src="') - assert.include(textarea.textContent, 'href="') - // We should ave both, once for iframe link, once for full screen - assert.include(textarea.textContent, 'scrollWheelZoom=true') - assert.include(textarea.textContent, 'scrollWheelZoom=false') - assert.notInclude(textarea.textContent, 'datalayers=62') - let switcher = qs('label[title="Keep current visible layers"]') - happen.click(switcher) - assert.include(textarea.textContent, 'datalayers=62') - }) - }) -}) diff --git a/umap/static/umap/test/index.html b/umap/static/umap/test/index.html index 5b2b06c6..728d98ba 100644 --- a/umap/static/umap/test/index.html +++ b/umap/static/umap/test/index.html @@ -98,7 +98,6 @@ - diff --git a/umap/tests/integration/test_share.py b/umap/tests/integration/test_share.py new file mode 100644 index 00000000..4b8e6079 --- /dev/null +++ b/umap/tests/integration/test_share.py @@ -0,0 +1,22 @@ +import re + +import pytest +from playwright.sync_api import expect + +pytestmark = pytest.mark.django_db + + +def test_iframe_code(map, live_server, datalayer, page): + page.goto(f"{live_server.url}{map.get_absolute_url()}?share") + textarea = page.locator(".umap-share-iframe") + expect(textarea).to_be_visible() + expect(textarea).to_have_text(re.compile('src="')) + expect(textarea).to_have_text(re.compile('href="')) + # We should ave both, once for iframe link, once for full screen + expect(textarea).to_have_text(re.compile('scrollWheelZoom=true')) + expect(textarea).to_have_text(re.compile('scrollWheelZoom=false')) + expect(textarea).not_to_have_text(re.compile(f'datalayers={datalayer.pk}')) + # Open options + page.get_by_text("Embed and link options").click() + page.get_by_title("Keep current visible layers").click() + expect(textarea).to_have_text(re.compile(f'datalayers={datalayer.pk}'))