Skip to content

Commit

Permalink
fix: getLayerCategoryId call
Browse files Browse the repository at this point in the history
  • Loading branch information
cnouguier committed Nov 18, 2021
1 parent fbb32f4 commit 383888e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
4 changes: 2 additions & 2 deletions capture.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async function clickSelector (page, selector, wait = 250) {
}
}

export async function getLayerCategoryId (page, layerId) {
async function getLayerCategoryId (page, layerId) {
const xpath = `//div[contains(@class, "q-expansion-item q-item-type") and .//div[@id="${layerId}"]]`
const elements = await page.$x(xpath)
if (elements.length > 0) return (await elements[0].getProperty('id')).jsonValue()
Expand Down Expand Up @@ -103,7 +103,7 @@ export async function getLayerCategoryId (page, layerId) {
await page.waitForTimeout(250)
for (let i = 0; i < parameters.layers.length; ++i) {
const layerId = parameters.layers[i]
const categoryId = getLayerCategoryId(layerId)
const categoryId = getLayerCategoryId(page, layerId)
if (!openedCategories.includes(categoryId)) {
await clickSelector(page, categoryId)
openedCategories.push(categoryId)
Expand Down
18 changes: 4 additions & 14 deletions test/capture.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,7 @@ describe(`suite:${suite}`, () => {

it('capture multiple zoomed layers', async () => {
const body = {
layers: {
'BASE_LAYERS': ['IMAGERY'],
'CAPTURED_LAYERS': ['MAPILLARY'],
'METEO_LAYERS': ['WIND_TILED']
},
layers: ['layers-imagery', 'layers-mapillary', 'layers-wind-tiled'],
bbox: [ 1.62, 43.11, 1.63, 43.12 ]
}
const res = await capture(body, 'layers')
Expand All @@ -104,9 +100,7 @@ describe(`suite:${suite}`, () => {

it('capture gradient geoson file', async () => {
const body = {
layers: {
'BASE_LAYERS': ['OSM_DARK']
},
layers: ['layers-osm-dark'],
features: JSON.parse(fs.readFileSync(path.join(dataDir, 'flight.geojson'))).features,
size: { width: 800, height: 600 }
}
Expand All @@ -117,9 +111,7 @@ describe(`suite:${suite}`, () => {

it('capture geojson with defined bbox', async () => {
const body = {
layers: {
'BASE_LAYERS': ['OSM_DARK']
},
layers: ['layers-osm-dark'],
features: JSON.parse(fs.readFileSync(path.join(dataDir, 'flight.geojson'))).features,
bbox: [ 4, 51.5, 5, 52.5 ],
size: { width: 800, height: 600 }
Expand All @@ -131,9 +123,7 @@ describe(`suite:${suite}`, () => {

it('capture mask geoson file', async () => {
const body = {
layers: {
'BASE_LAYERS': ['HYBRID']
},
layers: ['layers-hybrid'],
features: [ JSON.parse(fs.readFileSync(path.join(dataDir, 'occitanie.geojson'))) ],
size: { width: 1200, height: 900 }
}
Expand Down

0 comments on commit 383888e

Please sign in to comment.