diff --git a/examples/nuxt-app/test/features/maps/maps.feature b/examples/nuxt-app/test/features/maps/maps.feature index f2458a8528..0d0584a39a 100644 --- a/examples/nuxt-app/test/features/maps/maps.feature +++ b/examples/nuxt-app/test/features/maps/maps.feature @@ -119,3 +119,15 @@ Feature: Custom collection map component Given I visit the page "/map" And I wait 2 seconds Then the map matches the image snapshot "map-custom-default-extent" + + @mockserver + Scenario: Map can be viewed fullscreen + Given I load the page fixture with "/maps/basic-page" + And the page endpoint for path "/map" returns the loaded fixture + And I visit the page "/map" + When I click the view fullscreen button + And I wait 100 milliseconds + Then the map should be fullscreen + When I click the exit fullscreen button + And I wait 100 milliseconds + Then the map should not be fullscreen diff --git a/examples/nuxt-app/test/support/step_definitions/index.ts b/examples/nuxt-app/test/support/step_definitions/index.ts index a1e1f39a45..42bbbda2a0 100644 --- a/examples/nuxt-app/test/support/step_definitions/index.ts +++ b/examples/nuxt-app/test/support/step_definitions/index.ts @@ -1,5 +1,7 @@ +import 'cypress-real-events' import '@dpc-sdp/ripple-test-utils/step_definitions' import '@frsource/cypress-plugin-visual-regression-diff' + Cypress.on('uncaught:exception', (err) => { // https://stackoverflow.com/a/50387233 // Ignore Resize observer loop issue in expand search filters for now diff --git a/packages/ripple-test-utils/package.json b/packages/ripple-test-utils/package.json index 9a5d32bcf1..2423718a15 100644 --- a/packages/ripple-test-utils/package.json +++ b/packages/ripple-test-utils/package.json @@ -28,6 +28,7 @@ "@frsource/cypress-plugin-visual-regression-diff": "^3.3.10", "@testing-library/cypress": "^10.0.1", "cypress": "^13.6.6", + "cypress-real-events": "^1.13.0", "mockttp": "^3.9.1", "start-server-and-test": "^2.0.3" } diff --git a/packages/ripple-test-utils/step_definitions/components/maps.ts b/packages/ripple-test-utils/step_definitions/components/maps.ts index a03fce66a3..195acad7c5 100644 --- a/packages/ripple-test-utils/step_definitions/components/maps.ts +++ b/packages/ripple-test-utils/step_definitions/components/maps.ts @@ -237,3 +237,23 @@ Given('the following default extent is used', (dataTable: DataTable) => { ]) }) }) + +When('I click the view fullscreen button', () => { + cy.get('.rpl-map__control button[title="View full screen"]').realClick() +}) + +When('I click the exit fullscreen button', () => { + cy.get('.rpl-map__control button[title="Exit full screen"]').realClick() +}) + +Then('the map should be fullscreen', () => { + cy.document().then((doc) => { + expect(doc.fullscreenElement).to.not.be.null + }) +}) + +Then('the map should not be fullscreen', () => { + cy.document().then((doc) => { + expect(doc.fullscreenElement).to.be.null + }) +}) diff --git a/packages/ripple-ui-maps/src/components/map/RplMap.vue b/packages/ripple-ui-maps/src/components/map/RplMap.vue index 03e64be595..c14c3b7b5e 100644 --- a/packages/ripple-ui-maps/src/components/map/RplMap.vue +++ b/packages/ripple-ui-maps/src/components/map/RplMap.vue @@ -16,7 +16,6 @@ import { watch, nextTick } from 'vue' -import { useFullscreen } from '@vueuse/core' import { withDefaults, defineExpose } from '@vue/composition-api' import { Map } from 'ol' import { Zoom } from 'ol/control' @@ -140,10 +139,14 @@ const selectedPinStyle = (feature, style) => { return style } -const { isFullscreen } = useFullscreen() - -const { onHomeClick, onZoomInClick, onZoomOutClick, onFullScreenClick } = - useMapControls(mapRef) +const { + onHomeClick, + onZoomInClick, + onZoomOutClick, + onFullScreenClick, + isFullScreen, + supportsFullScreen +} = useMapControls(mapRef) const mapFeatures = computed(() => { if (Array.isArray(props.features)) { @@ -288,6 +291,10 @@ onMounted(() => { }) const noResultsRef = ref(null) + +const fullScreenLabel = computed(() => + isFullScreen.value ? 'Exit full screen' : 'View full screen' +)