From f82b58e447450895218179f679c845a854429cc3 Mon Sep 17 00:00:00 2001 From: David Featherston Date: Thu, 20 Jun 2024 16:31:04 +1000 Subject: [PATCH] feat(@dpc-sdp/ripple-tide-publication): fix print all pages, add no-index and some tests --- .../features/publication/publication.feature | 17 ++ .../publication/sample-print-all.json | 164 ++++++++++++++++++ .../common/shared-elements.ts | 16 ++ .../content-types/publication.ts | 21 ++- .../pages/{[...slug] => [slug]}/print-all.vue | 4 + 5 files changed, 221 insertions(+), 1 deletion(-) create mode 100644 examples/nuxt-app/test/fixtures/publication/sample-print-all.json rename packages/ripple-tide-publication/pages/{[...slug] => [slug]}/print-all.vue (97%) diff --git a/examples/nuxt-app/test/features/publication/publication.feature b/examples/nuxt-app/test/features/publication/publication.feature index 8d7e69ff44..0d7e51d8dc 100644 --- a/examples/nuxt-app/test/features/publication/publication.feature +++ b/examples/nuxt-app/test/features/publication/publication.feature @@ -19,3 +19,20 @@ Feature: Publication page Then the title should be "The Victorian Skills Plan 2022 into 2023 actions and initiatives" And there should be a page link with a title of "Previous" and description text of "Victorian Skills Plan Implementation Update" And there should be a page link with a title of "Next" and description text of "Promoting post-secondary education skills and career pathways" + + @mockserver + Example: Publication print all + Given the endpoint "/api/tide/publication-children" with query "?ids=4a6d9877-326a-4090-8f7d-51c79191c63b&ids=7f608818-51e5-4c42-831a-a51d46a41ff6&ids=3479556d-7daa-4bc4-985a-d0ec1d954713&ids=a805aea1-6b50-4327-b176-ff4468775ad6&ids=c17daa15-9ad8-412d-a049-aa1ef6c668c2&ids=f85fab41-8217-44c4-bb0d-29ab5bc2832c&ids=c83e001c-2429-4c87-a53c-62a96ee426c6&ids=d51a4112-fd63-42cb-91a6-c17057c25242&ids=095e703d-e8cc-4153-9cf4-13e8a4f095c9&ids=ad3fd4c8-60dc-4c0d-a55c-5137766a2056&ids=64d7c641-640d-46e9-9967-7ad49104d744&ids=463ebde6-f906-427e-adaa-e2c7dba9f875&ids=3218f7fa-e189-44a2-8fdb-fc750409c421&ids=c0bf3b7f-1819-4cdb-99e8-4fd50071adac&ids=bf8208e7-bbc7-40cf-b3c0-111e6caabd91&ids=e0ce9cb4-df4f-4ae9-84e6-b1589486cdc8&ids=03b2d101-d6d8-4e55-a3e4-cad2d08f625b&ids=181e7b7e-ad44-4451-843a-044d760aa18e&ids=9c4656a6-3294-4515-8a7e-e15cd32841b6&ids=fadb534c-9598-40d0-a211-ca4b8a7c140a&ids=556bcf1a-46d6-4565-87e5-79e1b4b31cc5&ids=133ddcfa-b7f7-431c-bc85-f59ba8f44eac&ids=ff6440cc-7605-4ff1-b8a1-f25a5797549f&ids=f197320e-e9e3-46c8-b402-43ddd409599a&ids=e6cdf8c8-c19a-419b-9bb1-22a0938bba58&ids=cf1bfe5d-929e-44e2-a542-18d8b9fcd234&ids=16ef10ae-d3e4-4217-9508-eb4981336a3e" returns fixture "/publication/sample-print-all" with status 200 + When I visit the print all page "/victorian-skills-plan-2023-implementation-update/print-all" + Then the in page navigation should include + | title | url | + | The Victorian Skills Plan 2022 into 2023 actions and initiatives | /victorian-skills-plan-2023-implementation-update/2022-victorian-skills-plan-actions-and-initiatives | + | Promoting post-secondary education skills and career pathways | /victorian-skills-plan-2023-implementation-update/promoting-post-secondary-education-skills-and-career | + | Lifting participation in education and training | /victorian-skills-plan-2023-implementation-update/lifting-participation-education-and-training | + | Delivering the right skills for the jobs of today and tomorrow | /victorian-skills-plan-2023-implementation-update/delivering-right-skills-jobs-today-and-tomorrow | + | The Victorian Skills Plan supports action on skills | /victorian-skills-plan-2023-implementation-update/action-on-skills | + | Victorian Training Awards 2023 School-based Apprentice of the Year winner | /victorian-skills-plan-2023-implementation-update/victorian-training-awards-2023-school-based-apprentice | + | Start the VET journey at school | /victorian-skills-plan-2023-implementation-update/start-vet-journey-school | + | Victorian Training Awards 2023 Koorie Student of the Year winner | /victorian-skills-plan-2023-implementation-update/victorian-training-awards-2023-koorie-student-year-winner | + | Victorian Training Awards 2023 Koorie Student of the Year finalists | /victorian-skills-plan-2023-implementation-update/victorian-training-awards-2023-koorie-student-year-finalists | + And the print dialog should be shown diff --git a/examples/nuxt-app/test/fixtures/publication/sample-print-all.json b/examples/nuxt-app/test/fixtures/publication/sample-print-all.json new file mode 100644 index 0000000000..1cc0a1b902 --- /dev/null +++ b/examples/nuxt-app/test/fixtures/publication/sample-print-all.json @@ -0,0 +1,164 @@ +[ + { + "header": { + "title": "The Victorian Skills Plan 2022 into 2023 actions and initiatives", + "summary": "The 25 initiatives scheduled to start in year one are well underway." + } + }, + { + "header": { + "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" + } + }, + { + "header": { + "title": "Lifting participation in education and training", + "summary": "The second priority area's actions and initiatives from the Victorian Skills Plan 2022." + } + }, + { + "header": { + "title": "Delivering the right skills for the jobs of today and tomorrow", + "summary": "The third priority area's actions and initiatives from the Victorian Skills Plan 2022." + } + }, + { + "header": { + "title": "The Victorian Skills Plan supports action on skills", + "summary": "Learn what's been achieved since the Victorian Skills Plan for 2022 into 2023 was implemented." + } + }, + { + "header": { + "title": "Victorian Training Awards 2023 School-based Apprentice of the Year winner", + "summary": "Joachim has benefitted by participating in a school-based apprenticeship." + } + }, + { + "header": { + "title": "Start the VET journey at school", + "summary": "Improvements including a strengthened VET Delivered To School Students system have increased access to VET options for schools." + } + }, + { + "header": { + "title": "Victorian Training Awards 2023 Koorie Student of the Year winner", + "summary": "Pearl pursued her dream of becoming a nurse through a Diploma of Nursing." + } + }, + { + "header": { + "title": "Victorian Training Awards 2023 Koorie Student of the Year finalists", + "summary": "Kurin is a passionate social justice advocate and Jenaya plans to become a Koorie engagement support officer." + } + }, + { + "header": { + "title": "Enable learners and workers to make informed skills and career choices", + "summary": "Using intelligence gathered through various resources, the Victorian Skills Authority has helped learners understand their options and advised employers on upskilling." + } + }, + { + "header": { + "title": "Expand opportunities and approaches for students to put theory into practice during their course", + "summary": "Practical placement officers have been funded for all Victorian TAFE Network providers to assist students seeking placements." + } + }, + { + "header": { + "title": "Initiatives in focus – GOTAFE", + "summary": "GOTAFE ran a successful program that placed Certificate IV in Mental Health students in aged care residential facilities." + } + }, + { + "header": { + "title": "Build foundation skills to enhance workforce participation", + "summary": "Accredited and pre-accredited foundation skills support skill development across a range of areas to enable individuals to participate in education and training, work and life." + } + }, + { + "header": { + "title": "Victorian Training Awards 2023 Community Training Provider of the Year finalist", + "summary": "Mountain District Learning Centre engages young people through an alternative learning program." + } + }, + { + "header": { + "title": "Victorian Learn Local Awards 2022 Pre-accredited Learner (skills for work) winner", + "summary": "Adult community education programs helped Felimon Asel find employment." + } + }, + { + "header": { + "title": "Bridge the gender gap", + "summary": "Attracting more women into the labour force and increasing the number of female workers, is critical." + } + }, + { + "header": { + "title": "Victorian Training Awards 2023 Industry Collaboration winner", + "summary": "Attracting women to electrical trades was the goal of Women in Apprenticeships Victoria Electrical (WAVE). " + } + }, + { + "header": { + "title": "Victorian Training Awards 2023 Vocational Student of the Year winner", + "summary": "How TAFE helped Barbara step into her dream career." + } + }, + { + "header": { + "title": "Build skills to support Victoria's clean economy intentions", + "summary": "There are many initiatives in place to support the Clean Economy Workforce Development Strategy. " + } + }, + { + "header": { + "title": "Kangan Institute electric vehicle lab", + "summary": "A new purpose-built electric vehicle (EV) lab will help bridge the emerging skills gap of specially trained technicians in Australia." + } + }, + { + "header": { + "title": "Create innovative solutions to support future skills development", + "summary": "How the skills system is keeping up with changing occupations and shifts in industries and jobs." + } + }, + { + "header": { + "title": "Initiatives in focus – Murrindindi", + "summary": "The Victorian Skills Authority and Murrindindi Aged and Disability Workforce used place-based engagement to increase staff retention." + } + }, + { + "header": { + "title": "Align qualifications to new needs", + "summary": "Using existing skills classification tools, the Victorian Skills Authority is exploring approaches to better describe changing skills demand in the Victorian economy." + } + }, + { + "header": { + "title": "Drive for higher skills and progression through education and training", + "summary": "The Victorian Skills Authority is progressing reforms in the skills and training system." + } + }, + { + "header": { + "title": "Victorian Training Awards 2023 Teacher or Trainer of the Year winner", + "summary": "Thomas Patterson transitioned into VET teaching to share his knowledge and skills with students." + } + }, + { + "header": { + "title": "Build the VET workforce", + "summary": "The Victorian Skills Authority has commenced work on the VET Workforce Development Strategy through a range of initiatives." + } + }, + { + "header": { + "title": "Expand re-skilling and up-skilling opportunities through skill sets", + "summary": "The Victorian Skills Authority's Industry Advisory Groups and Skills and Jobs Centres have played an important part in supporting learners up-skill through skills sets." + } + } +] 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 cb9f3bb8ab..d28b2e372a 100644 --- a/packages/ripple-test-utils/step_definitions/common/shared-elements.ts +++ b/packages/ripple-test-utils/step_definitions/common/shared-elements.ts @@ -250,3 +250,19 @@ Given('the site sections share links are set to included WhatsApp', () => { ) }) }) + +Then('the in page navigation should include', (dataTable: DataTable) => { + const table = dataTable.hashes() + + cy.get('.rpl-in-page-navigation li').as('links') + + table.forEach((row, i: number) => { + cy.get('@links') + .eq(i) + .then((link) => { + cy.wrap(link).as('link') + cy.get('@link').find('a').first().should('have.attr', 'href', row.url) + cy.get('@link').find('.rpl-list__label').first().contains(row.title) + }) + }) +}) 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 0ecfa78c83..f955e2e3bd 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,23 @@ -import { Then } from '@badeball/cypress-cucumber-preprocessor' +import { Then, When } from '@badeball/cypress-cucumber-preprocessor' + +When('I visit the print all page {string}', (route: string) => { + cy.visit(route, { + failOnStatusCode: false, + onBeforeLoad: (win) => { + cy.stub(win, 'print') + } + }) + cy.get('body', { + timeout: 20000 + }).should('have.attr', 'data-nuxt-hydrated', 'true') + cy.wait(200) +}) + +Then('the print dialog should be shown', () => { + cy.window().then((win) => { + expect(win.print).to.be.calledOnce + }) +}) Then( 'there should be a page link with a title of {string} and description text of {string}', diff --git a/packages/ripple-tide-publication/pages/[...slug]/print-all.vue b/packages/ripple-tide-publication/pages/[slug]/print-all.vue similarity index 97% rename from packages/ripple-tide-publication/pages/[...slug]/print-all.vue rename to packages/ripple-tide-publication/pages/[slug]/print-all.vue index 1425e66736..a7668437b4 100644 --- a/packages/ripple-tide-publication/pages/[...slug]/print-all.vue +++ b/packages/ripple-tide-publication/pages/[slug]/print-all.vue @@ -36,6 +36,10 @@ const childPages = await useTidePublicationChildren( onMounted(() => { window.print() }) + +useHead({ + meta: [{ name: 'robots', content: 'noindex' }] +})