Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[R20-1985] add custom content rating text #1250

Merged
merged 3 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
22 changes: 22 additions & 0 deletions examples/nuxt-app/test/features/site/shared-elements.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions examples/nuxt-app/test/fixtures/site/shared-elements.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "<p>Test <strong>footer</strong> copyright html</p>",
"contentRatingText": "<p>Test custom rating text.</p>",
"footerLogos": [
{
"alt": "Test logo 1",
Expand Down
1 change: 1 addition & 0 deletions packages/nuxt-ripple/components/TideBaseLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
<slot name="belowBody"></slot>
<TideContentRating
v-if="showContentRating"
:contentRatingText="site?.contentRatingText"
:siteSectionName="siteSection ? siteSection.name : ''"
/>
</template>
Expand Down
17 changes: 8 additions & 9 deletions packages/nuxt-ripple/components/TideContentRating.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import { onMounted, ref } from 'vue'

interface Props {
siteSectionName: string
contentRatingText: string
}

withDefaults(defineProps<Props>(), {
siteSectionName: ''
siteSectionName: '',
contentRatingText: ''
})

// This is an actual webform that exists in drupal
Expand Down Expand Up @@ -78,14 +80,11 @@ onMounted(() => {
matches: 'You must enter between 1 and 500 words'
}"
/>
<RplContent>
<p>
If you need a response, please use our
<RplTextLink url="/contact-us"
>contact us form</RplTextLink
>.
</p>
</RplContent>
<RplContent
v-if="contentRatingText"
:html="contentRatingText"
class="tide-content-rating__text"
/>
<FormKit
v-if="value.was_this_page_helpful"
type="RplFormActions"
Expand Down
6 changes: 6 additions & 0 deletions packages/nuxt-ripple/mapping/site/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
getImageFromField,
getBody,
getBodyFromField,
getMediaPath,
getLinkFromField,
getSiteKeyValues,
Expand Down Expand Up @@ -43,6 +44,11 @@ export default {
bottom: (src: any) =>
getImageFromField(src, 'field_bottom_corner_graphic')
},
contentRatingText: (src: any) => {
return src.hasOwnProperty('field_additional_comment')
? getBodyFromField(src, 'field_additional_comment')
: '<p>If you need a response, please use our <a href="/contact-us" class="rpl-text-link rpl-u-focusable-inline">contact us form</a>.</p>'
},
acknowledgementFooter: 'field_acknowledgement_to_country',
copyrightHtml: (src: any) => {
return getBody(src.field_site_footer_text?.processed)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions packages/ripple-tide-api/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface TideSiteData {
top?: TideImageField
bottom?: TideImageField
}
contentRatingText?: string
acknowledgementHeader?: string
acknowledgementFooter: string
copyrightHtml: string
Expand Down
Loading