-
Notifications
You must be signed in to change notification settings - Fork 16
Add tests for <map-span> #560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
|
|
||
| path.fclass { stroke: blue; } | ||
|
|
||
| g[data-fid="fclass.73"] > path { stroke: blue; fill: #DDA0DD;} | ||
|
|
||
|
|
||
| /* Those parts which are wrapped in a span also inherit the class | ||
| values of the span element, which in this case are taken to be noline and | ||
| aren"t therefore drawn at all (they are there only to represent tile boundaries)*/ | ||
| path.noline { display: none} | ||
|
|
||
| *, ::before, ::after { | ||
| box-sizing: border-box; | ||
| } | ||
|
|
||
| html, | ||
| body { | ||
| height: 100%; | ||
| } | ||
|
|
||
| body { | ||
| font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji'; | ||
| margin: 0; | ||
| line-height: 1.5; | ||
| } | ||
|
|
||
|
|
||
| /* | ||
| * map viewers | ||
| */ | ||
| mapml-viewer:defined, | ||
| [is="web-map"]:defined { | ||
| height: 100%; | ||
| max-width: 100%; | ||
| width: 100%; | ||
| vertical-align: middle; | ||
| } | ||
|
|
||
| /* Pre-style to avoid FOUC of inline layer- and fallback content. */ | ||
| mapml-viewer:not(:defined) > * { | ||
| display: none; | ||
| } | ||
| [is="web-map"]:not(:defined) + img[usemap], | ||
| [is="web-map"]:not(:defined) > :not(area):not(.mapml-web-map) { | ||
| display: none; | ||
| } | ||
| /* Ensure inline layer content is hidden if custom/built-in elements isn't | ||
| supported, or if javascript is disabled. This needs to be defined separately | ||
| from the above, because the `:not(:defined)` selector invalidates the entire | ||
| declaration in browsers that do not support it. */ | ||
| layer- { | ||
| display: none; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" content="width=device-width,initial-scale=1"> | ||
| <title>MapML Vector Tiles</title> | ||
| <script type="module" src="mapml-viewer.js"></script> | ||
| <link rel="stylesheet" href="mapSpan.css"> | ||
| <style> | ||
| mapml-viewer:defined { | ||
| height: 50%; | ||
| border: 0; | ||
| vertical-align: middle; | ||
| } | ||
|
|
||
| mapml-viewer:defined ~ mapml-viewer:defined { | ||
| border-top: 1px inset; | ||
| } | ||
| </style> | ||
| </head> | ||
| <body> | ||
| <mapml-viewer projection="WGS84" zoom="0" lat="0" lon="0" controls> | ||
| <layer- label="Countries - WorldCRS84Quad" checked> | ||
| <map-link rel="stylesheet" href="mapSpan.css" > | ||
| <map-extent units="WGS84"> | ||
| <map-input name="zoomLevel" type="zoom" min="0" max="2" value="0"></map-input> | ||
|
|
||
| <map-input name="row" type="location" axis="row" units="tilematrix" min="0" max="5"></map-input> | ||
| <map-input name="col" type="location" axis="column" units="tilematrix" min="0" max="5"></map-input> | ||
|
|
||
| <map-link rel='tile' type='text/mapml' title='Tiles for ne_10m_admin_0_countries (as MapML)' tref='data/wgs84/{zoomLevel}/r{row}_c{col}.mapml'/> | ||
| </map-extent> | ||
| </layer-> | ||
| </mapml-viewer> | ||
|
|
||
| <mapml-viewer projection="OSMTILE" zoom="2" lat="0" lon="0" controls> | ||
| <layer- label="Countries - WebMercatorQuad" checked> | ||
| <map-link rel="stylesheet" href="mapSpan.css" > | ||
| <map-extent units="OSMTILE"> | ||
| <map-input name="zoomLevel" type="zoom" min="0" max="2" value="0"></map-input> | ||
| <map-input name="row" type="location" axis="row" units="tilematrix" min="0" max="1"></map-input> | ||
| <map-input name="col" type="location" axis="column" units="tilematrix" min="0" max="1"></map-input> | ||
| <map-link rel='tile' type='text/mapml' tref='data/osmtile/{zoomLevel}/{row}_{col}.mapml' ></map-link> | ||
| </map-extent> | ||
| </layer-> | ||
| </mapml-viewer> | ||
|
|
||
| </body> | ||
| </html> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| const playwright = require("playwright"); | ||
| jest.setTimeout(50000); | ||
| (async () => { | ||
| for (const browserType of BROWSER) { | ||
| describe( | ||
| "<map-span> test " + browserType, | ||
| ()=> { | ||
| beforeAll(async () => { | ||
| browser = await playwright[browserType].launch({ | ||
| headless: ISHEADLESS, | ||
| slowMo: 100, | ||
| }); | ||
| context = await browser.newContext(); | ||
| page = await context.newPage(); | ||
| if (browserType === "firefox") { | ||
| await page.waitForNavigation(); | ||
| } | ||
| await page.goto(PATH + "mapSpan.html"); | ||
| }); | ||
| afterAll(async function () { | ||
| await browser.close(); | ||
| }); | ||
|
|
||
| test("[" + browserType + "]" + " <map-span> hides tile boundaries", async ()=>{ | ||
| const total = await page.$eval( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is the variable named "total" ? What is it the total of? |
||
| 'body > mapml-viewer:nth-child(1) div > div.leaflet-pane.leaflet-map-pane > div.leaflet-pane.leaflet-overlay-pane > div > div.leaflet-layer.mapml-templatedlayer-container > div > div > div:nth-child(1) > svg > g > g:nth-child(1) > path:nth-child(2)', | ||
| (path) => path.getAttribute("style") | ||
| ); | ||
|
|
||
| const featureOutline = await page.$( | ||
| 'body > mapml-viewer:nth-child(1) div > div.leaflet-pane.leaflet-map-pane > div.leaflet-pane.leaflet-overlay-pane > div > div.leaflet-layer.mapml-templatedlayer-container > div > div > div:nth-child(1) > svg > g > g:nth-child(1) > path.fclass._2.mapml-feature-outline' | ||
| ); | ||
|
|
||
| const hidden = await page.$eval( | ||
| 'body > mapml-viewer:nth-child(1) div > div.leaflet-pane.leaflet-map-pane > div.leaflet-pane.leaflet-overlay-pane > div > div.leaflet-layer.mapml-templatedlayer-container > div > div > div:nth-child(1) > svg > g > g:nth-child(1) > path.noline.fclass._2', | ||
| (path) => path.getAttribute("d") | ||
| ); | ||
| expect(featureOutline).not.toBe(null); | ||
|
|
||
| const d = await featureOutline.getAttribute("d"); | ||
| const spliced = await hidden.slice(3, hidden.length); | ||
| //Makes sure that the part that should be hidden is not part of the feature outline | ||
| let index = d.indexOf(spliced); | ||
|
|
||
| expect(total).toEqual("stroke: none;"); | ||
| expect(index).toEqual(-1); | ||
| }); | ||
|
|
||
| //https://github.com/Maps4HTML/Web-Map-Custom-Element/issues/559#issuecomment-959805896 | ||
| test("[" + browserType + "]" + " White space parsing for map-coordinates", async ()=>{ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Title of the test could be easier to understand, e.g. "Ensure white space in map-coordinates is ignored" or something like that. |
||
| await page.waitForTimeout(1000); | ||
| const feature = await page.$eval( | ||
| 'body > mapml-viewer:nth-child(2) div > div.leaflet-pane.leaflet-map-pane > div.leaflet-pane.leaflet-overlay-pane > div > div.leaflet-layer.mapml-templatedlayer-container > div > div > div:nth-child(1) > svg > g > g > path.fclass.mapml-feature-outline', | ||
| (path) => path.getAttribute("d") | ||
| ); | ||
|
|
||
| expect(feature).toEqual("M0 217L0 217L0 217L2 217L4 218L6 218L6 218L6 216L2 214L0 216L0 216"); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| }); | ||
| } | ||
| ); | ||
| } | ||
| })(); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| <mapml- xmlns="http://www.w3.org/1999/xhtml"> | ||
| <map-head> | ||
| <map-title>ne_10m_admin_0_countries</map-title> | ||
| <map-meta charset="utf-8"/> | ||
| <map-meta content="text/mapml" http-equiv="Content-Type"/> | ||
| <map-meta name="projection" content="OSMTILE"></map-meta> | ||
| <map-meta name="cs" content="pcrs"></map-meta> | ||
| </map-head> | ||
| <map-body> | ||
| <map-feature id="fclass.73" class="fclass"> | ||
| <map-geometry> | ||
| <map-polygon> | ||
| <map-coordinates> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could put an xml comment here that says e.g. |
||
| -10019154.93269 1538354.08306 -10018754.17139 1538179.92761 -9953778.73157 1518203.74208 -9871068.81875 1482220.46653 -9790805.04014 1478766.01397 -9768484.06551 1498870.65375 -9796003.07532 1547622.63538 -9951944.13091 1647924.2825 -10018754.17139 1569038.46245 | ||
| <map-span class="noline">-10019154.93269 1569012.97177 -10019154.93269 1538354.08306</map-span> | ||
| </map-coordinates> | ||
| </map-polygon> | ||
| </map-geometry> | ||
| </map-feature> | ||
| </map-body> | ||
| </mapml-> | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need to loop through all to childNodes or could you get away with checking just the first and last? I'm not 100% sure how whitespace and textNodes work so you may have to loop through all of them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that I only need to check the last one