From aef2f683ae762805de56737d6fe72e1fe39a6cd2 Mon Sep 17 00:00:00 2001 From: David Featherston Date: Mon, 1 Jul 2024 17:22:01 +1000 Subject: [PATCH 1/2] feat(@dpc-sdp/ripple-tide-publication): update details and add tests --- .../features/publication/publication.feature | 10 ++++ .../publication/sample-publication.json | 6 +-- .../step_definitions/content-types/listing.ts | 1 - .../content-types/publication.ts | 46 ++++++++++++++++++- .../components/TidePublicationBody.vue | 35 ++++++++------ .../components/TidePublicationChapters.vue | 2 +- 6 files changed, 79 insertions(+), 21 deletions(-) diff --git a/examples/nuxt-app/test/features/publication/publication.feature b/examples/nuxt-app/test/features/publication/publication.feature index 0d7e51d8dc..d50e93c1b1 100644 --- a/examples/nuxt-app/test/features/publication/publication.feature +++ b/examples/nuxt-app/test/features/publication/publication.feature @@ -12,6 +12,16 @@ Feature: Publication page Example: Publication parent When I visit the page "/victorian-skills-plan-2023-implementation-update" Then the title should be "Victorian Skills Plan Implementation Update" + And the publication details should include the following items + | term | description | + | Published by: | DPC | + | Date: | 24 Oct 2023 | + | Copyright: | All rights reserved. | + And the publication should display the following chapters + | title | content | url | + | The Victorian Skills Plan 2022 into 2023 actions and initiatives | The 25 initiatives scheduled to start in year one are well underway. | /victorian-skills-plan-2023-implementation-update/2022-victorian-skills-plan-actions-and-initiatives | + | Promoting post-secondary education skills and career pathways | The first priority area's actions and initiatives from the Victorian Skills Plan 2022. | /victorian-skills-plan-2023-implementation-update/promoting-post-secondary-education-skills-and-career | + | Lifting participation in education and training | The second priority area's actions and initiatives from the Victorian Skills Plan 2022. | /victorian-skills-plan-2023-implementation-update/lifting-participation-education-and-training | @mockserver Example: Publication child diff --git a/examples/nuxt-app/test/fixtures/publication/sample-publication.json b/examples/nuxt-app/test/fixtures/publication/sample-publication.json index 44e7c9c571..bbe43d6238 100644 --- a/examples/nuxt-app/test/fixtures/publication/sample-publication.json +++ b/examples/nuxt-app/test/fixtures/publication/sample-publication.json @@ -89,9 +89,9 @@ "showInPageNav": false, "inPageNavHeadingLevel": "h2", "details": { - "author": "", + "author": "DPC", "date": "2023-10-24T11:00:00+11:00", - "copyright": null + "copyright": "All rights reserved." }, "chapters": [ { @@ -103,7 +103,7 @@ { "id": "7f608818-51e5-4c42-831a-a51d46a41ff6", "title": "Promoting post-secondary education skills and career pathways", - "summary": "The first priority area's actions and initiatives from the Victorian Skills Plan 2022.\r\n", + "summary": "The first priority area's actions and initiatives from the Victorian Skills Plan 2022.", "url": "/victorian-skills-plan-2023-implementation-update/promoting-post-secondary-education-skills-and-career" }, { diff --git a/packages/ripple-test-utils/step_definitions/content-types/listing.ts b/packages/ripple-test-utils/step_definitions/content-types/listing.ts index 1993ce7035..9da13a9b94 100644 --- a/packages/ripple-test-utils/step_definitions/content-types/listing.ts +++ b/packages/ripple-test-utils/step_definitions/content-types/listing.ts @@ -136,7 +136,6 @@ Then( cy.get(`[data-component-type="search-result"]`) .eq(i) .then((item) => { - cy.log(item) cy.wrap(item).should('contain', row.title) if (row.url) { diff --git a/packages/ripple-test-utils/step_definitions/content-types/publication.ts b/packages/ripple-test-utils/step_definitions/content-types/publication.ts index f955e2e3bd..dd5efbe2c3 100644 --- a/packages/ripple-test-utils/step_definitions/content-types/publication.ts +++ b/packages/ripple-test-utils/step_definitions/content-types/publication.ts @@ -1,4 +1,4 @@ -import { Then, When } from '@badeball/cypress-cucumber-preprocessor' +import { DataTable, Then, When } from '@badeball/cypress-cucumber-preprocessor' When('I visit the print all page {string}', (route: string) => { cy.visit(route, { @@ -26,3 +26,47 @@ Then( cy.get('.rpl-page-links__link-text').contains(desc).should('exist') } ) + +Then( + 'the publication details should include the following items', + (dataTable: DataTable) => { + const table = dataTable.hashes() + + cy.get(`.tide-publication__details dt`).as('items') + + table.forEach((row, i: number) => { + cy.get('@items') + .eq(i) + .then((item) => { + cy.wrap(item).as('item') + + cy.get('@item').contains(row.term) + cy.get('@item').next('dd').contains(row.description) + }) + }) + } +) + +Then( + 'the publication should display the following chapters', + (dataTable: DataTable) => { + const table = dataTable.hashes() + + cy.get(`.tide-publication__chapters li`).as('items') + + table.forEach((row, i: number) => { + cy.get('@items') + .eq(i) + .then((item) => { + cy.wrap(item).as('item') + + cy.get('@item').find('a').as('link') + cy.get('@link').contains(row.title) + cy.get('@link').should('have.attr', 'href', row.url) + cy.get('@item') + .find('.rpl-card__content') + .should('have.text', row.content) + }) + }) + } +) diff --git a/packages/ripple-tide-publication/components/TidePublicationBody.vue b/packages/ripple-tide-publication/components/TidePublicationBody.vue index 9563b8125b..c4106c4a54 100644 --- a/packages/ripple-tide-publication/components/TidePublicationBody.vue +++ b/packages/ripple-tide-publication/components/TidePublicationBody.vue @@ -29,22 +29,27 @@ interface IRplDescriptionListItem { } const processed = computed(() => { - if (!props.details) return [] + const list: Array = [] - const out: Array = [] - for (const [key, value] of Object.entries(props.details)) { - let val = value - if (val) { - if (key === 'date') { - const published = new Date(props.details.date) - val = formatDate(published) - } - out.push({ - term: key[0].toUpperCase() + key.substring(1) + ':', - description: val - }) - } + if (props.details?.author) { + list.push({ + term: 'Published by:', + description: props.details.author + }) } - return out + if (props.details?.date) { + list.push({ + term: 'Date:', + description: formatDate(new Date(props.details.date)) + }) + } + if (props.details?.copyright) { + list.push({ + term: 'Copyright:', + description: props.details.copyright + }) + } + + return list }) diff --git a/packages/ripple-tide-publication/components/TidePublicationChapters.vue b/packages/ripple-tide-publication/components/TidePublicationChapters.vue index 3364b1dd08..e2190c051f 100644 --- a/packages/ripple-tide-publication/components/TidePublicationChapters.vue +++ b/packages/ripple-tide-publication/components/TidePublicationChapters.vue @@ -3,7 +3,7 @@ export default { name: 'TidePublicationChapters' }