Skip to content
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

GSLUX-686: Profil component #169

Merged
merged 18 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ VITE_MODE_LIB=true
VITE_MYMAPS_URL="/mymaps"
VITE_ARROW_MODEL_URL="/static-ngeo/models/arrow5.glb"
VITE_ELEVATION_URL="/raster"
VITE_PROFILE_URL="/profile.json"

# Auth
VITE_CREDENTIALS_ORIGIN="same-origin"
Expand Down
3 changes: 2 additions & 1 deletion .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ VITE_MODE_LIB=false
VITE_MYMAPS_URL="https://migration.geoportail.lu/mymaps"
VITE_ARROW_MODEL_URL="https://migration.geoportail.lu/static-ngeo/models/arrow5.glb"
VITE_ELEVATION_URL="https://migration.geoportail.lu/raster"
VITE_PROFILE_URL="https://migration.geoportail.lu/profile.json"

# Auth
VITE_CREDENTIALS_ORIGIN="include"
VITE_CREDENTIALS_ORIGIN="same-origin" # values: "same-origin" or "include", WARNING: don't use `"include"` value in production
VITE_LOGIN_URL="http://localhost:8080/login"
VITE_LOGOUT_URL="http://localhost:8080/logout"
VITE_USERINFO_URL="http://localhost:8080/getuserinfo"
Expand Down
1 change: 1 addition & 0 deletions .env.e2e
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ VITE_MODE_LIB=false
VITE_MYMAPS_URL="https://migration.geoportail.lu/mymaps"
VITE_ARROW_MODEL_URL="https://migration.geoportail.lu/static-ngeo/models/arrow5.glb"
VITE_ELEVATION_URL="https://migration.geoportail.lu/raster"
VITE_PROFILE_URL="https://migration.geoportail.lu/profile.json"

# Auth
VITE_CREDENTIALS_ORIGIN="same-origin"
Expand Down
1 change: 1 addition & 0 deletions .env.staging
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ VITE_MODE_LIB=true
VITE_MYMAPS_URL="https://migration.geoportail.lu/mymaps"
VITE_ARROW_MODEL_URL="https://migration.geoportail.lu/static-ngeo/models/arrow5.glb"
VITE_ELEVATION_URL="https://migration.geoportail.lu/raster"
VITE_PROFILE_URL="https://migration.geoportail.lu/profile.json"

# Auth
VITE_CREDENTIALS_ORIGIN="same-origin"
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
## testing
/coverage/
/.nyc_output/
/cypress/downloads/

## temp folders
/.tmp/
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/draw/draw-feat-circle.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ describe('Draw "Circle"', () => {
cy.get('*[data-cy="featItemLength"]').should('contain.text', '693.17 km')
// testing just integer part due to precision issues between local tests and CI
cy.get('*[data-cy="featItemArea"]')
.should('contain.text', 'Surface: 38235.')
.and('contain.text', ' km²')
.should('include.text', 'Surface:\u00A038235')
.and('include.text', ' km²')
})

it('updates length and area measurements when editing radius in panel', () => {
Expand Down
78 changes: 65 additions & 13 deletions cypress/e2e/draw/draw-feat-line.cy.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,88 @@
import { testFeatItem, testFeatItemDocking } from './draw-feat.utils'

function testFeatItemMeasurements() {
cy.get('*[data-cy="featItemLength"]').should('exist')
cy.get('*[data-cy="featItemArea"]').should('not.exist')
cy.get('*[data-cy="featItemRadius"]').should('not.exist')
cy.get('*[data-cy="featItemElevation"]').should('not.exist')
cy.get('*[data-cy="featItemProfile"]').should('exist')
cy.get('*[data-cy="featItemProfileCSV"]').should('exist')
cy.get('[data-cy="featItemLength"]').should('exist')
cy.get('[data-cy="featItemArea"]').should('not.exist')
cy.get('[data-cy="featItemRadius"]').should('not.exist')
cy.get('[data-cy="featItemElevation"]').should('not.exist')
cy.get('[data-cy="featItemProfile"]').should('exist')
cy.get('[data-cy="featItemProfileCSV"]').should('exist')
}

describe('Draw "Line"', () => {
beforeEach(() => {
cy.visit('/')
cy.get('button[data-cy="drawButton"]').click()
cy.get('button[data-cy="drawLineButton"]').click()
cy.get('div.ol-viewport').click(100, 100, { force: true })
cy.get('div.ol-viewport').dblclick(200, 200, { force: true })
cy.get('div.ol-viewport').click(320, 223, { force: true })
cy.get('div.ol-viewport').dblclick(389, 305, { force: true })
})

describe('When clicking button to draw Line', () => {
describe('When drawing a line', () => {
it('displays a new feature item in the draw panel', () => {
cy.get('*[data-cy="featItemName"]').should('exist')
cy.get('[data-cy="featItemName"]')
.should('exist')
.should('contain.text', 'Ligne 1')
})

it('displays measurements for Line', () => {
testFeatItemMeasurements()
})

it('displays the elevation profile for Line', () => {
cy.get('[data-cy="featItemProfileCumul"]').should(
'contain.text',
'Δ+964 m Δ-1105 m Δ-141 m'
)
cy.get('[data-cy="featItemProfile"] svg').should('exist')
cy.get('[data-cy="featItemProfile"] svg g.grid-y > g.tick').should(
'have.length',
7
)
cy.get('[data-cy="featItemProfile"] svg g.x.axis > g.tick').should(
'have.length',
9
)
cy.get('[data-cy="featItemProfile"] svg g.y.axis > g.tick')
.eq(6)
.find('text')
.should('have.text', '500')
})

describe('When editing the line', () => {
it('refreshes the elevation profile for Line', () => {
cy.dragVertexOnMap(320, 223, 305, 305)

cy.get('[data-cy="featItemProfileCumul"]').should(
'contain.text',
'Δ+429 m Δ-489 m Δ-61 m'
)

cy.get('[data-cy="featItemProfile"] svg g.y.axis > g.tick')
.eq(6)
.find('text')
.should('have.text', '380')
})
})

it('downloads the profile elevation', () => {
cy.get('[data-cy="featItemProfileCSV"]').click()

const downloadPath = 'cypress/downloads/Ligne_1.csv'
cy.readFile(downloadPath).should('exist')

cy.readFile(downloadPath).then(content => {
expect(content).to.contain(
'dist,MNT,y,x,lon,lat\n0,425.3,60019.883345295,105204.558805771,5.89013672441823,49.88086129777006\n423.7,446.6,60292.742941114775,104880.43553517274,5.893949526308415,49.87795628443879\n847.4,480.9,60565.60253693456,104556.31226457447,5.897761870512693,49.875051143511975\n'
)
// NB. This is the first lines of the file, not the full content
})
})

it('updates length measurement when editing geometry', () => {
cy.get('*[data-cy="featItemLength"]').should('contain.text', '55.36 km')
cy.dragVertexOnMap(200, 200, 300, 300)
cy.get('*[data-cy="featItemLength"]').should('contain.text', '111.14 km')
cy.get('[data-cy="featItemLength"]').should('contain.text', '42.31 km')
cy.dragVertexOnMap(320, 223, 305, 305)
cy.get('[data-cy="featItemLength"]').should('contain.text', '33.26 km')
})

it('displays the possible actions for the feature', () => {
Expand Down
1 change: 0 additions & 1 deletion cypress/e2e/draw/draw-feat-point.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ describe('Draw "Point"', () => {

it('displays the symbol edition tab', () => {
cy.get('[data-cy="featStyleColor"]').should('exist')
// starting with featStyleSymbol_
cy.get('[data-cy^="featStyleSymbol_"]').should('have.length', 4)
})

Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/draw/draw-feat-polygon.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('Draw "Polygon"', () => {
// - chrome and chromium browsers give different decimals in measurements
// - therefore only the int part of the surface is checked
cy.get('*[data-cy="featItemArea"]')
.should('contain.text', 'Surface: 1532.')
.should('contain.text', 'Surface:\u00A01532.')
.and('contain.text', ' km²')
})

Expand Down
7 changes: 6 additions & 1 deletion cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,12 @@ declare global {
interface Chainable {
getDrawInteractions(): Chainable<Array<Interaction>>
getModifyInteraction(): Chainable<Interaction>
dragVertexOnMap(): Chainable<void>
dragVertexOnMap(
originX: number,
originY: number,
x: number,
y: number
): Chainable<void>
// login(email: string, password: string): Chainable<void>
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
Expand Down
Loading
Loading