Skip to content

Commit

Permalink
Merge pull request #470 from geoadmin/develop-lv95
Browse files Browse the repository at this point in the history
Default projection to lv95
  • Loading branch information
pakb authored Nov 1, 2023
2 parents 74c5cf6 + 905ae66 commit 3c13ebc
Show file tree
Hide file tree
Showing 132 changed files with 4,223 additions and 2,566 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/add-testlink-to-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Create/update test link on DEV
if: ${{ github.base_ref == 'develop' }}
if: ${{ github.base_ref == 'develop' || startsWith(github.base_ref, 'develop-') }}
uses: tzkhan/pr-update-action@v2
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
Expand Down
2 changes: 1 addition & 1 deletion cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = defineConfig({
video: false,
defaultCommandTimeout: 5000,
requestTimeout: 5000,
numTestsKeptInMemory: 5,
numTestsKeptInMemory: 2,
retries: {
runMode: 1,
openMode: 0,
Expand Down
52 changes: 36 additions & 16 deletions src/api/__tests__/features.api.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,67 @@ import { EditableFeature, EditableFeatureTypes } from '@/api/features.api'
import { MEDIUM, RED } from '@/utils/featureStyleUtils'
import { expect } from 'chai'
import { describe, it } from 'vitest'
import Feature from 'ol/Feature.js'
import Polygon from 'ol/geom/Polygon.js'

const stringifiedTestObject = `{"id":"drawing_feature_2",\
"title":"This is a title",\
"description":"test",\
"featureType":"ANNOTATION",\
"textColor":{"name":"red","fill":"#ff0000","border":"#ffffff"},\
"fillColor":{"name":"red","fill":"#ff0000","border":"#ffffff"},\
"textSize":{"label":"medium_size","textScale":1.5,"iconScale":1},\
"icon":null,\
"iconSize":{"label":"medium_size","textScale":1.5,"iconScale":1}}`

const coordinates = [
[46.50964, 8.06021],
[46.9089, 8.4667],
[46.96141, 7.78555],
[46.50964, 8.06021],
]

const poly = new Polygon([coordinates])
const testFeature = new Feature({
name: 'My Polygon',
editableFeature: stringifiedTestObject,
})
testFeature.setGeometry(poly)

const args = {
id: 'drawing_feature_2',
coordinates: null,
coordinates: coordinates,
title: 'This is a title',
featureType: EditableFeatureTypes.ANNOTATION,
}
const testObject = {
...args,
description: '',
description: 'test',
textColor: RED,
textSize: MEDIUM,
fillColor: RED,
icon: null,
iconSize: MEDIUM,
}
const stringifiedTestObject = `{"id":"drawing_feature_2",\
"coordinates":null,\
"title":"This is a title",\
"description":"",\
"featureType":"ANNOTATION",\
"textColor":{"name":"red","fill":"#ff0000","border":"#ffffff"},\
"fillColor":{"name":"red","fill":"#ff0000","border":"#ffffff"},\
"textSize":{"label":"medium_size","textScale":1.5,"iconScale":1},\
"icon":null,\
"iconSize":{"label":"medium_size","textScale":1.5,"iconScale":1}}`

describe('Validate features api', () => {
describe('Validate serialization and deserialization of the editable feature', () => {
it('Serialize a default editable feature', () => {
const feature = EditableFeature.constructWithObject(args)
const feature = EditableFeature.newFeature(testObject)
expect(feature).to.be.instanceOf(EditableFeature)
const stringified = JSON.stringify(feature.getStrippedObject())
const stringified = JSON.stringify(feature.serialize())
// Cannot directly compare the two strings, as the order is undefined
expect(JSON.parse(stringified)).to.deep.equal(JSON.parse(stringifiedTestObject))
})
it('Deserialize a default editable feature', () => {
const reconstructed = EditableFeature.recreateObject(JSON.parse(stringifiedTestObject))
const editableFeature = testFeature.get('editableFeature')
expect(editableFeature).to.be.not.null
expect(editableFeature).to.be.equal(stringifiedTestObject)

const reconstructed = EditableFeature.deserialize(testFeature)
expect(reconstructed).to.be.instanceOf(EditableFeature)
expect(reconstructed.id).to.be.equal(testObject.id)
expect(reconstructed.coordinates).to.be.equal(testObject.coordinates)
expect(reconstructed.coordinates).to.deep.equal(testObject.coordinates)
expect(reconstructed.title).to.be.equal(testObject.title)
expect(reconstructed.description).to.be.equal(testObject.description)
expect(reconstructed.icon).to.be.equal(testObject.icon)
Expand Down
Loading

0 comments on commit 3c13ebc

Please sign in to comment.