diff --git a/front/cypress/components/MapScorePopup.cy.ts b/front/cypress/components/MapScorePopup.cy.ts index d2182bea..c9668408 100644 --- a/front/cypress/components/MapScorePopup.cy.ts +++ b/front/cypress/components/MapScorePopup.cy.ts @@ -10,7 +10,7 @@ describe("MapscorePopup Component", () => { setActivePinia(createPinia()) }) - it("MapPopUp when selectedDataType is PLANTABILITY", () => { + it(`renders correctly when the selected map data type is ${DataType.PLANTABILITY}`, () => { const mapStore = useMapStore() mapStore.selectedDataType = DataType.PLANTABILITY @@ -27,7 +27,7 @@ describe("MapscorePopup Component", () => { cy.contains("Plantabilité élevée") }) - it("MapPopUp when selectedDataType is LOCAL_CLIMATE_ZONES", () => { + it(`renders correctly when the selected map data type is ${DataType.LOCAL_CLIMATE_ZONES}`, () => { const mapStore = useMapStore() mapStore.selectedDataType = DataType.LOCAL_CLIMATE_ZONES @@ -40,5 +40,6 @@ describe("MapscorePopup Component", () => { }) cy.contains("LCZ") cy.contains("Sol imperméable naturel ou artificiel") + cy.contains("12.34° N, 56.78° E") }) }) diff --git a/front/cypress/components/tsconfig.json b/front/cypress/components/tsconfig.json new file mode 100644 index 00000000..e9967176 --- /dev/null +++ b/front/cypress/components/tsconfig.json @@ -0,0 +1,13 @@ +{ + "compilerOptions": { + "isolatedModules": false, + "types": [ + "cypress" + ] + }, + "extends": "@vue/tsconfig/tsconfig.dom.json", + "include": [ + "./**/*", + "../support/**/*" + ] +} diff --git a/front/cypress/support/index.d.ts b/front/cypress/support/index.d.ts index 1791a501..a6e061cc 100644 --- a/front/cypress/support/index.d.ts +++ b/front/cypress/support/index.d.ts @@ -1,4 +1,5 @@ declare namespace Cypress { + // eslint-disable-next-line @typescript-eslint/no-unused-vars interface Chainable { mapClosePopup(): void getBySel(selector: string, ...args: any[]): Chainable diff --git a/front/src/components/map/popup/ClimateZoneScorePopupContent.vue b/front/src/components/map/popup/ClimateZoneScorePopupContent.vue index fc5e8713..1bed81df 100644 --- a/front/src/components/map/popup/ClimateZoneScorePopupContent.vue +++ b/front/src/components/map/popup/ClimateZoneScorePopupContent.vue @@ -1,3 +1,13 @@ + - - diff --git a/front/src/components/map/popup/MapScorePopup.vue b/front/src/components/map/popup/MapScorePopup.vue index 3e18ea79..909d1adb 100644 --- a/front/src/components/map/popup/MapScorePopup.vue +++ b/front/src/components/map/popup/MapScorePopup.vue @@ -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, ref } from "vue" +import { copyToClipboard } from "@/utils/clipboard" const mapStore = useMapStore() -defineProps({ +const props = defineProps({ index: { required: true, type: String @@ -19,6 +21,16 @@ defineProps({ type: Number } }) +const message = ref("") +const coords = computed(() => `${props.lat.toFixed(2)}° N, ${props.lng.toFixed(2)}° E`) + +const copy = (text: string) => { + message.value = "Copié !" + copyToClipboard(text) + setTimeout(() => { + message.value = "" + }, 2000) +} diff --git a/front/src/utils/clipboard.ts b/front/src/utils/clipboard.ts new file mode 100644 index 00000000..8c6ba481 --- /dev/null +++ b/front/src/utils/clipboard.ts @@ -0,0 +1,3 @@ +export const copyToClipboard = (value: string) => { + if (navigator.clipboard) navigator.clipboard.writeText(value) +}