Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
21 changes: 2 additions & 19 deletions front/cypress/components/MapScorePopup.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,7 @@ describe("MapscorePopup Component", () => {
beforeEach(() => {
setActivePinia(createPinia())
})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pas de possibilité d'ajouter un test ici parce que le fait d'utiliser la fonction navigator.clipboard.writeText(value) lève une erreur au niveau de cypress. C'est bien documenté ici et ça doit être résolu par eux

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Relou


it("MapPopUp when selectedDataType is PLANTABILITY", () => {
const mapStore = useMapStore()
mapStore.selectedDataType = DataType.PLANTABILITY

mount(MapscorePopup, {
props: {
index: "0.81",
lat: 45.76,
lng: 4.85
}
})
cy.contains("8/10")
cy.contains("45.76")
cy.contains("4.85")
cy.contains("Plantabilité élevée")
})

it("MapPopUp when selectedDataType is LOCAL_CLIMATE_ZONES", () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

J'ai supprimé l'un des deux tests parce qu'ils vérifient la même chose

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Le format des PopUp selon la source de données n'est pas le même, et le traitement à partir de la donnée récupérée index non plus.

Je crois que ça servrait aussi à tester que la popup correspondait bien à la source

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merci @ludovicdmt pour la vigilance 🙏

it("renders correctly", () => {
const mapStore = useMapStore()
mapStore.selectedDataType = DataType.LOCAL_CLIMATE_ZONES

Expand All @@ -40,5 +22,6 @@ describe("MapscorePopup Component", () => {
})
cy.contains("LCZ")
cy.contains("Sol imperméable naturel ou artificiel")
cy.contains("12.34° N, 56.78° E")
})
})
13 changes: 13 additions & 0 deletions front/cypress/components/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"isolatedModules": false,
"types": [
"cypress"
]
},
"extends": "@vue/tsconfig/tsconfig.dom.json",
"include": [
"./**/*",
"../support/**/*"
]
}
1 change: 1 addition & 0 deletions front/cypress/support/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
declare namespace Cypress {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Chainable<Subject = any> {
mapClosePopup(): void
getBySel(selector: string, ...args: any[]): Chainable
Expand Down
21 changes: 10 additions & 11 deletions front/src/components/map/popup/ClimateZoneScorePopupContent.vue
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
<script setup lang="ts">
import { getZoneDesc, getZoneColor } from "@/utils/climateZones"

defineProps({
index: {
required: true,
type: String
}
})
</script>
<template>
<div data-cy="lcz-score-popup">
<div class="flex items-center gap-2 w-full">
Expand All @@ -11,14 +21,3 @@
</div>
</div>
</template>

<script setup lang="ts">
import { getZoneDesc, getZoneColor } from "@/utils/climateZones"

const props = defineProps({
index: {
required: true,
type: String
}
})
</script>
28 changes: 26 additions & 2 deletions front/src/components/map/popup/MapScorePopup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import PlantabilityScorePopup from "@/components/map/popup/PlantabilityScorePopu
import ClimateZoneScorePopup from "@/components/map/popup/ClimateZoneScorePopupContent.vue"
import { useMapStore } from "@/stores/map"
import { DataType } from "@/utils/enum"
import { computed } from "vue"
import { copyToClipboard } from "@/utils/clipboard"

const mapStore = useMapStore()
defineProps({
const props = defineProps({
index: {
required: true,
type: String
Expand All @@ -19,6 +21,8 @@ defineProps({
type: Number
}
})

const coords = computed(() => `${props.lat.toFixed(2)}° N, ${props.lng.toFixed(2)}° E`)
</script>

<template>
Expand All @@ -33,6 +37,26 @@ defineProps({
:index="index.toString()"
/>
</div>
<div class="text-light-green text-right">{{ lat.toFixed(2) }}° N, {{ lng.toFixed(2) }}° E</div>
<div class="w-full flex justify-end">
<button
class="text-light-green text-md cursor-pointer flex items-center"
data-cy="copy-coords-button"
@click="copyToClipboard(coords)"
>
{{ coords }}
<svg
width="32"
height="34"
viewBox="0 0 32 34"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M19.9315 20.3371V11.6619C19.9315 11.0164 19.3878 10.5 18.7381 10.5H11.1934C10.5436 10.5 10 11.0293 10 11.6619V20.3242C10 20.9697 10.5436 21.4861 11.1934 21.4861H18.7249C19.3878 21.4861 19.9182 20.9568 19.9182 20.3242L19.9315 20.3371ZM11.021 20.3371V11.6619C11.021 11.5715 11.1006 11.494 11.1934 11.494H18.7249C18.7249 11.494 18.8177 11.507 18.8442 11.5457C18.8707 11.5844 18.8972 11.6231 18.8972 11.6619V20.3242C18.8972 20.3242 18.884 20.4146 18.8442 20.4404C18.8044 20.4662 18.7646 20.4921 18.7249 20.4921H11.1934C11.1006 20.4921 11.021 20.4146 11.021 20.3242V20.3371ZM21.9867 13.0045V22.3381C21.9867 22.9836 21.4431 23.5 20.7934 23.5H12.5724C12.2939 23.5 12.0552 23.2805 12.0552 22.9965C12.0552 22.7125 12.2807 22.493 12.5724 22.493H20.7934C20.7934 22.493 20.8862 22.4801 20.9127 22.4414C20.9392 22.4027 20.9657 22.364 20.9657 22.3252V13.0045C20.9657 12.7334 21.1912 12.501 21.4829 12.501C21.7746 12.501 22 12.7205 22 13.0045H21.9867Z"
fill="#B5B5B5"
/>
</svg>
</button>
</div>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Au niveau UX il manque pour moi :

  • Un message "Copié!" qui apparaît au clic
  • Un message "Copier les coordonées" qui apparaît au survol (pour indiquer plus clairement ce que va faire le clic)

Copy link
Contributor Author

@QuentinMadura QuentinMadura Mar 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

J'ai ajouté (en quick-win) un "Copié" au clic qui je dois l'avouer n'est pas très satisfaisant.
En terme d'améliorations (mais pas maintenant), je verrai :

  • Lorsque l'on clique, un toast s'affiche pour nous indiquer qu'on a bien copié les coordonnées
  • Au survol, un tooltip apparaît pour nous indiquer "copier les coordonnées"

Qu'en penses-tu @ludovicdmt ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je viens de voir ça et de le tester.
Moi ça me convient en l'état et que je rédige un ticket pour les améliorations plus tard.
Merci Quentin !

</div>
</template>
3 changes: 3 additions & 0 deletions front/src/utils/clipboard.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const copyToClipboard = (value: string) => {
if (navigator.clipboard) navigator.clipboard.writeText(value)
}