Skip to content

Commit

Permalink
tune assertions to fix timing in order to make location info tests re…
Browse files Browse the repository at this point in the history
…liable
  • Loading branch information
mki-c2c committed Dec 13, 2024
1 parent e5ec30d commit d5c8ad1
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 39 deletions.
80 changes: 43 additions & 37 deletions cypress/e2e/location-info.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,47 @@ describe('Location Info', () => {
}).as('shortUrl')

cy.intercept(
'GET',
'https://migration.geoportail.lu/geocode/reverse?easting=67886.66280635976&northing=85024.54757489248',
{
statusCode: 200,
body: {
count: 1,
results: [
{
id_caclr_locality: '37',
id_caclr_street: '1147',
id_caclr_bat: '213956',
street: 'Bergstr',
number: '18',
locality: 'Roodt/Eisch/Test',
commune: 'Habscht',
postal_code: '8398',
country: 'Luxembourg',
country_code: 'lu',
distance: 1967.871691858786,
contributor: 'ACT',
geom: {
type: 'Point',
coordinates: [67900.5221, 84743.219699999],
},
geomlonlat: {
type: 'Point',
coordinates: [6.00041535, 49.697110053],
method: 'GET',
pathname: '/geocode/reverse',
},
req => {
const dist = Math.sqrt(
(parseFloat(req.query.easting.toString()) - 67887) ** 2 +
(parseFloat(req.query.northing.toString()) - 85410) ** 2
)
const categorizedDist =
dist > 5 ? (dist > 100 ? 1972.1284 : 394.2305) : 20.98493
req.reply({
statusCode: 200,
body: {
count: 1,
results: [
{
id_caclr_locality: '37',
id_caclr_street: '1147',
id_caclr_bat: '213956',
street: 'Bergstr',
number: '18',
locality: 'Roodt/Eisch/Test',
commune: 'Habscht',
postal_code: '8398',
country: 'Luxembourg',
country_code: 'lu',
distance: categorizedDist,
contributor: 'ACT',
geom: {
type: 'Point',
coordinates: [req.query.easting, req.query.northing],
},
geomlonlat: {
type: 'Point',
coordinates: [6.00041535, 49.697110053],
},
},
},
],
},
],
},
})
}
)
})
Expand Down Expand Up @@ -65,8 +75,6 @@ describe('Location Info', () => {
cy.get('div.ol-viewport').rightclick(350, 300, { force: true })
cy.get('[data-cy="locationInfo"]').should('be.visible')
cy.get('[data-cy="locationInfo"]').find('input').should('exist')
//cy.log(JSON.stringify(cy.get('[data-cy="locationInfo"]')
// .find('input').invoke('val')))
cy.get('[data-cy="locationInfo"]')
.find('input')
.invoke('val')
Expand Down Expand Up @@ -127,30 +135,28 @@ describe('Location Info', () => {
})
cy.get('div.ol-viewport').rightclick(350, 50, { force: true })
cy.get('[data-cy="streetviewNoData"]').should('not.be.visible')
// The waiting animation has been added to allow synchronisation
// in the test once the streetview is fully loaded.
cy.get('[data-cy="streetviewLoading"]').should('not.be.visible')
cy.window()
.its('olMap')
.then(function (olMap) {
.should(function (olMap) {
const featureLayers = olMap
.getLayers()
.getArray()
.filter((l: any) => l.get('cyLayerType') === 'svFeatureLayer')
const features = featureLayers
.map((l: any) => l.getSource().getFeatures())
.flat()
cy.wrap(features.length).should('equal', 3)
expect(features.length).to.equal(3)
})
cy.get('[data-cy="locationInfo"] > div > table > tbody > tr')
.last()
.find('td')
.should('contain.text', '669.87 m')
.should('contain.text', '20.98 m')
cy.get('div.ol-viewport').click(382, 82, { force: true })
cy.get('[data-cy="locationInfo"] > div > table > tbody > tr')
.last()
.find('td')
.should('contain.text', '662.47 m')
.should(el => expect(el).to.contain.text('394.23 m'))
})
})
})
Expand Down
2 changes: 1 addition & 1 deletion src/assets/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@
.lux-loader {
@apply border-[20px] border-solid border-white rounded-full;
@apply border-t-[20px] border-t-[color:var(--color-primary)];
@apply m-auto w-[200px] h-[200px];
@apply z-10 m-auto w-[200px] h-[200px];
animation: lux-loader 4s linear infinite;
}

Expand Down
1 change: 0 additions & 1 deletion src/composables/map/street-view.composable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ export default function useStreeView(streetViewDiv: Ref<HTMLElement | null>) {

function handlePanoramaPositionChange(updateLocation: boolean) {
panoPositionChanging.value = true
streetViewLoading.value = true
const position = panorama!.getPosition()
if (position) {
const panoLonLat = [position.lng(), position.lat()]
Expand Down

0 comments on commit d5c8ad1

Please sign in to comment.