chore: move iframe options test to playwright

This commit is contained in:
Yohan Boniface 2024-01-30 18:24:43 +01:00
parent 2271669e80
commit 0b65d0dd9d
3 changed files with 22 additions and 44 deletions

View file

@ -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')
})
})
})

View file

@ -98,7 +98,6 @@
<script src="./Polyline.js" defer></script>
<script src="./Polygon.js" defer></script>
<script src="./Util.js" defer></script>
<script src="./Controls.js" defer></script>
<script src="./Permissions.js" defer></script>
<script src="./Choropleth.js" defer></script>
<script type="module" src="./URLs.js" defer></script>

View file

@ -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}'))