diff --git a/examples/nuxt-app/test/features/site/shared-elements.feature b/examples/nuxt-app/test/features/site/shared-elements.feature index 0f967b88eb..6fea7fa727 100644 --- a/examples/nuxt-app/test/features/site/shared-elements.feature +++ b/examples/nuxt-app/test/features/site/shared-elements.feature @@ -83,6 +83,28 @@ Feature: Shared site elements | Demo Topic | /topic/demo-topic | | Demo Tag | /tags/demo-tag | + @mockserver + Scenario: Content Rating (visible) + Given the site endpoint returns fixture "/site/shared-elements" with status 200 + And I load the page fixture with "/landingpage/home" + And the content rating form is enabled + Then the page endpoint for path "/page" returns the loaded fixture + + Given I visit the page "/page" + Then the content rating form should be displayed + And I click the content rating option labelled "Yes" + Then the content rating form should display the custom text "Test custom rating text." + + @mockserver + Scenario: Content Rating (hidden) + Given the site endpoint returns fixture "/site/shared-elements" with status 200 + And I load the page fixture with "/landingpage/home" + And the content rating form is disabled + Then the page endpoint for path "/page" returns the loaded fixture + + Given I visit the page "/page" + Then the content rating form should not be displayed + @mockserver Scenario: Footer Given the site endpoint returns fixture "/site/shared-elements" with status 200 diff --git a/examples/nuxt-app/test/fixtures/site/shared-elements.json b/examples/nuxt-app/test/fixtures/site/shared-elements.json index c36fd0fd43..4a4c9fa138 100644 --- a/examples/nuxt-app/test/fixtures/site/shared-elements.json +++ b/examples/nuxt-app/test/fixtures/site/shared-elements.json @@ -5,6 +5,7 @@ "acknowledgementHeader": "The Victorian Government acknowledges Aboriginal Traditional Owners of Country throughout Victoria and pays respect to their cultures and Elders past, present and emerging.", "acknowledgementFooter": "Test footer acknowledgement", "copyrightHtml": "

Test footer copyright html

", + "contentRatingText": "

Test custom rating text.

", "footerLogos": [ { "alt": "Test logo 1", diff --git a/packages/nuxt-ripple/components/TideBaseLayout.vue b/packages/nuxt-ripple/components/TideBaseLayout.vue index 127e820deb..6d89d9a48d 100644 --- a/packages/nuxt-ripple/components/TideBaseLayout.vue +++ b/packages/nuxt-ripple/components/TideBaseLayout.vue @@ -63,6 +63,7 @@ diff --git a/packages/nuxt-ripple/components/TideContentRating.vue b/packages/nuxt-ripple/components/TideContentRating.vue index 0c5c456264..eccfdf2e08 100644 --- a/packages/nuxt-ripple/components/TideContentRating.vue +++ b/packages/nuxt-ripple/components/TideContentRating.vue @@ -3,10 +3,12 @@ import { onMounted, ref } from 'vue' interface Props { siteSectionName: string + contentRatingText: string } withDefaults(defineProps(), { - siteSectionName: '' + siteSectionName: '', + contentRatingText: '' }) // This is an actual webform that exists in drupal @@ -78,14 +80,11 @@ onMounted(() => { matches: 'You must enter between 1 and 500 words' }" /> - -

- If you need a response, please use our - contact us form. -

-
+ getImageFromField(src, 'field_bottom_corner_graphic') }, + contentRatingText: (src: any) => { + return src.hasOwnProperty('field_additional_comment') + ? getBodyFromField(src, 'field_additional_comment') + : '

If you need a response, please use our contact us form.

' + }, acknowledgementFooter: 'field_acknowledgement_to_country', copyrightHtml: (src: any) => { return getBody(src.field_site_footer_text?.processed) diff --git a/packages/ripple-test-utils/step_definitions/common/shared-elements.ts b/packages/ripple-test-utils/step_definitions/common/shared-elements.ts index d28b2e372a..a2bcdf325c 100644 --- a/packages/ripple-test-utils/step_definitions/common/shared-elements.ts +++ b/packages/ripple-test-utils/step_definitions/common/shared-elements.ts @@ -241,6 +241,37 @@ Then('the quick exit should not be displayed', () => { cy.get('.rpl-primary-nav__quick-exit').should('not.exist') }) +Then('the content rating form should be displayed', () => { + cy.get('.tide-content-rating').should('be.visible') +}) + +Then('the content rating form should not be displayed', () => { + cy.get('.tide-content-rating').should('not.exist') +}) + +Then( + 'the content rating form should display the custom text {string}', + (text: string) => { + cy.get('.tide-content-rating__text').should('have.text', text) + } +) + +Then('I click the content rating option labelled {string}', (label: string) => { + cy.get('.tide-content-rating label').contains(label).click() +}) + +Given('the content rating form is enabled', () => { + cy.get('@pageFixture').then((response) => { + set(response, 'showContentRating', true) + }) +}) + +Given('the content rating form is disabled', () => { + cy.get('@pageFixture').then((response) => { + set(response, 'showContentRating', false) + }) +}) + Given('the site sections share links are set to included WhatsApp', () => { cy.get('@pageFixture').then((response) => { set( diff --git a/packages/ripple-tide-api/types.d.ts b/packages/ripple-tide-api/types.d.ts index c80ca213e7..e9886d7ebe 100644 --- a/packages/ripple-tide-api/types.d.ts +++ b/packages/ripple-tide-api/types.d.ts @@ -30,6 +30,7 @@ export interface TideSiteData { top?: TideImageField bottom?: TideImageField } + contentRatingText?: string acknowledgementHeader?: string acknowledgementFooter: string copyrightHtml: string