-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
118 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
module.exports = { | ||
loadSinon: function (onLoad) { | ||
return ` | ||
var importScript = (function (oHead) { | ||
function loadError (oError) { | ||
throw new URIError("The script " + oError.target.src + " is not accessible."); | ||
} | ||
return function (sSrc, fOnload) { | ||
var oScript = document.createElement("script"); | ||
oScript.type = "text/javascript"; | ||
oScript.onerror = loadError; | ||
if (fOnload) { oScript.onload = fOnload; } | ||
oHead.appendChild(oScript); | ||
oScript.src = sSrc; | ||
} | ||
})(document.head || document.getElementsByTagName("head")[0]); | ||
function sinonOnLoad() { | ||
${onLoad} | ||
} | ||
importScript('https://cdnjs.cloudflare.com/ajax/libs/sinon.js/1.15.4/sinon.js', sinonOnLoad); | ||
` | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
let helper = require('../helper') | ||
|
||
module.exports = { | ||
'click on map updates altitude': function (browser) { | ||
const devServer = browser.globals.devServerURL | ||
|
||
browser | ||
.resizeWindow(1280, 800) // Fix size to be sure that clicks occurs always at the same place | ||
.url(devServer) | ||
.waitForElementVisible('.vue-map-container .gm-style', 8000) | ||
.execute(helper.loadSinon(` | ||
let stubedFetch = sinon.stub(window, 'fetch', function() { | ||
return Promise.resolve({status: 200, json: function() { return {alt: 234} }}) | ||
}); | ||
let sinonLoaded = document.createElement('div') | ||
sinonLoaded.style.visibility = 'hidden' | ||
sinonLoaded.id = 'sinonLoaded' | ||
document.head.appendChild(sinonLoaded) | ||
`)) | ||
.execute(() => { | ||
// https://stackoverflow.com/questions/43280070/how-can-i-click-on-a-pin-in-a-google-map-embedded-from-javascript | ||
// Get middle of the map and store it in a div to be used later | ||
let rect = document.querySelector('.vue-map').getBoundingClientRect() | ||
let centerY = rect.bottom - rect.top | ||
let centerX = rect.right - rect.left | ||
|
||
let divX = document.createElement('div') | ||
divX.style.visibility = 'hidden' | ||
divX.id = 'offsetX' | ||
divX.innerHTML = centerX.toString() | ||
let divY = document.createElement('div') | ||
divY.style.visibility = 'hidden' | ||
divY.innerHTML = centerY.toString() | ||
divY.id = 'offsetY' | ||
document.head.appendChild(divX) | ||
document.head.appendChild(divY) | ||
}) | ||
|
||
browser | ||
.waitForElementPresent('#offsetX', 3000) | ||
.waitForElementPresent('#offsetY', 3000) | ||
.waitForElementPresent('#sinonLoaded', 3000) | ||
|
||
let relX = browser.getValue('#offsetX') | ||
let relY = browser.getValue('#offsetY') | ||
|
||
browser | ||
.moveToElement('.vue-map', relX, relY) | ||
.mouseButtonClick() | ||
|
||
browser | ||
.execute(` | ||
server.respond() | ||
`) | ||
|
||
browser | ||
.waitForElementPresent('.card .card-item:nth-child(1) strong', 3000) | ||
.waitForElementPresent('.card .card-item:nth-child(2) strong', 3000) | ||
.waitForElementPresent('.card .card-item:nth-child(3) strong', 3000) | ||
.waitForElementPresent('.card .card-item:nth-child(4) strong', 3000) | ||
|
||
browser | ||
.assert.containsText('.card .card-item:nth-child(1) strong', '48.86031047029195') | ||
.assert.containsText('.card .card-item:nth-child(2) strong', '2.3455810546875') | ||
.assert.containsText('.card .card-item:nth-child(3) strong', '36 Rue des Bourdonnais, 75001 Paris, France') | ||
.assert.containsText('.card .card-item:nth-child(4) strong', '234 m') | ||
.end() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters