Skip to content

Commit

Permalink
fix regex in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mki-c2c committed Nov 27, 2024
1 parent 3532ef4 commit faacee2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
5 changes: 3 additions & 2 deletions cypress/e2e/background-selection.cy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { noMapLayerRegex } from './layers.utils'
import type { AUTWindowOlMap } from '../types'

describe('Background selector', () => {
Expand All @@ -22,7 +23,7 @@ describe('Background selector', () => {
const layers = (<AUTWindowOlMap>window).olMap
.getLayers()
.getArray()
.filter((l: any) => !/feature(Edit)?Layer/.exec(l.get('cyLayerType')))
.filter((l: any) => !noMapLayerRegex.exec(l.get('cyLayerType')))
expect(layers[0].get('id')).to.eq(556)
})

Expand Down Expand Up @@ -52,7 +53,7 @@ describe('Background selector', () => {
const layers = (<AUTWindowOlMap>window).olMap
.getLayers()
.getArray()
.filter((l: any) => !/feature(Edit)?Layer/.exec(l.get('cyLayerType')))
.filter((l: any) => !noMapLayerRegex.exec(l.get('cyLayerType')))
expect(layers[0].get('id')).to.eq(502)
})
})
Expand Down
13 changes: 11 additions & 2 deletions cypress/e2e/layers-selection/layers-selection-catalog.cy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { noMapLayerRegex } from '../layers.utils'
import type { AUTWindowOlMap } from '../../types'

describe('Catalogue', () => {
Expand Down Expand Up @@ -67,7 +68,11 @@ describe('Catalogue', () => {
const layers = (<AUTWindowOlMap>window).olMap
.getLayers()
.getArray()
.filter((l: any) => !/feature(Edit)?Layer/.exec(l.get('cyLayerType')))
.filter(
(l: any) =>
// regex match
!noMapLayerRegex.exec(l.get('cyLayerType'))
)
expect(layers[0].get('id')).to.eq(556)
})
cy.get('[data-cy="catalog"]')
Expand All @@ -81,7 +86,11 @@ describe('Catalogue', () => {
const layers = (<AUTWindowOlMap>window).olMap
.getLayers()
.getArray()
.filter((l: any) => !/feature(Edit)?Layer/.exec(l.get('cyLayerType')))
.filter(
(l: any) =>
// regex match
!noMapLayerRegex.exec(l.get('cyLayerType'))
)
expect(layers[0].get('id')).to.eq(359)
expect(layers[1].get('id')).to.eq(353)
})
Expand Down
1 change: 1 addition & 0 deletions cypress/e2e/layers.utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const noMapLayerRegex = /((info)|(sv))?[fF]eature(Edit)?Layer/
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class StatePersistorLocationInfo implements StatePersistorService {
// This represents the behaviour in V3, where restoring from permalink
// always displays the info of the map center
// This is not a very logical behaviour ??
if (location !== 'false') {
if (location && location !== 'false') {
locationInfo.value = map.getView().getCenter()
}
}
Expand Down

0 comments on commit faacee2

Please sign in to comment.