diff --git a/cypress/fixtures/strategicActionUpdates.json b/cypress/fixtures/strategicActionUpdates.json index bbee36d2..7c2c2f2d 100644 --- a/cypress/fixtures/strategicActionUpdates.json +++ b/cypress/fixtures/strategicActionUpdates.json @@ -110,5 +110,24 @@ "supply_chain": "a69d5624-1316-49a6-8a1a-4ac935ad13e3", "slug": "04-2021" } + }, + { + "model": "supply_chains.strategicactionupdate", + "pk": "ae9a9de0-1e98-4c36-96bd-1cc98b0eaf51", + "fields": { + "status": "completed", + "submission_date": null, + "date_created": "2021-05-21", + "content": "Created for the page title tests.", + "implementation_rag_rating": null, + "reason_for_delays": "", + "changed_value_for_target_completion_date": null, + "reason_for_completion_date_change": "", + "changed_value_for_is_ongoing": false, + "user": "8ffdf4f4-ea0d-4727-947c-f741f0ac6959", + "strategic_action": "94de03d1-416e-438b-92f5-2dfcd5f531af", + "supply_chain": "3dcb2693-5ce7-420b-bfcf-ee70be2921fc", + "slug": "05-2021" + } } ] diff --git a/cypress/fixtures/strategicActions.json b/cypress/fixtures/strategicActions.json index 7fd8d54e..c2b6fa70 100644 --- a/cypress/fixtures/strategicActions.json +++ b/cypress/fixtures/strategicActions.json @@ -450,5 +450,27 @@ "supply_chain": "a69d5624-1316-49a6-8a1a-4ac935ad13e3", "slug": "mu-form-test-5" } + }, + { + "model": "supply_chains.strategicaction", + "pk": "94de03d1-416e-438b-92f5-2dfcd5f531af", + "fields": { + "name": "SA Title Test", + "start_date": "2021-04-01", + "description": "For hanging an SAU for testing page titles from", + "impact": "None", + "category": "expand", + "geographic_scope": "uk_wide", + "supporting_organisations": "", + "is_ongoing": false, + "target_completion_date": "2021-12-31", + "is_archived": false, + "archived_date": null, + "archived_reason": "", + "specific_related_products": "", + "other_dependencies": "", + "supply_chain": "3dcb2693-5ce7-420b-bfcf-ee70be2921fc", + "slug": "sa-title-test" + } } ] diff --git a/cypress/fixtures/supplyChains.json b/cypress/fixtures/supplyChains.json index 754da857..04564b40 100644 --- a/cypress/fixtures/supplyChains.json +++ b/cypress/fixtures/supplyChains.json @@ -94,5 +94,23 @@ "risk_severity_status_disagree_reason": "", "slug": "supply-chain-6" } -} +}, + { + "model": "supply_chains.supplychain", + "pk": "3dcb2693-5ce7-420b-bfcf-ee70be2921fc", + "fields": { + "name": "Supply Chain 7", + "last_submission_date": "2021-04-01", + "gov_department": "15fb0d63-2ee6-4652-8acd-222bd2718703", + "contact_name": "nobody", + "contact_email": "nobody@trade.gov.uk", + "vulnerability_status": "low", + "vulnerability_status_disagree_reason": "", + "risk_severity_status": "low", + "risk_severity_status_disagree_reason": "", + "slug": "supply-chain-7", + "is_archived": false, + "archived_date": null + } + } ] diff --git a/cypress/integration/home_page_spec.js b/cypress/integration/home_page_spec.js index b949523d..e4d13a8b 100644 --- a/cypress/integration/home_page_spec.js +++ b/cypress/integration/home_page_spec.js @@ -24,9 +24,10 @@ describe('The Home Page', () => { ) cy.get('p').contains("It's important to keep your departmental action plan records up to date. This is so we can work towards constantly improving the UK's supply chain resilience.") cy.get('h2').contains('Complete your monthly update') + cy.get('li').invoke('text').should('match', /You need to complete your monthly update for \d+ supply chains/) cy.lastWorkingDay().then(deadline => { - cy.get('li').contains( `You need to complete your monthly update for 5 supply chains by ${deadline}`) - }) + cy.get('li:first-of-type').invoke('text').should('match', new RegExp(`\\s*You need to complete your monthly update for \\d+ supply chains by\\s*${deadline}\\s*`)) + }) cy.get('li').contains( 'Select a supply chain to provide your regular monthly update or to update wider details.' ) @@ -49,7 +50,7 @@ describe('The Home Page', () => { it('displays second page of supply chains after clicking Next', () => { cy.contains('Next').click() cy.url().should('eq', Cypress.config('baseUrl') + '/?page=2') - cy.get('tbody').find('tr').should('have.length', 1) + cy.get('tbody').find('tr').should('have.length', 2) }) it('displays first page of supply chains after clicking Previous', () => { cy.contains('Previous').click() diff --git a/cypress/integration/page_titles_spec.js b/cypress/integration/page_titles_spec.js new file mode 100644 index 00000000..1ff9d4e7 --- /dev/null +++ b/cypress/integration/page_titles_spec.js @@ -0,0 +1,111 @@ +import supplyChains from '../fixtures/supplyChains.json'; +import strategicActions from '../fixtures/strategicActions.json'; +import strategicActionUpdates from '../fixtures/strategicActionUpdates.json'; + +const supplyChain = supplyChains.find((supplyChain) => supplyChain.fields.slug === 'supply-chain-7'); +const strategicAction = strategicActions.find((strategicAction) => strategicAction.fields.supply_chain === supplyChain.pk && strategicAction.fields.slug === 'sa-title-test') +const strategicActionUpdate = strategicActionUpdates.find((strategicActionUpdate) => strategicActionUpdate.fields.strategic_action === strategicAction.pk && strategicActionUpdate.fields.slug === '05-2021'); + +import { urlBuilder } from "../support/utils.js" + +const urls = urlBuilder(supplyChain, strategicAction, strategicActionUpdate); + +const expectedTitles = { + home: () => 'Update supply chain information', + supplyChain: { + taskList: () => `Update ${supplyChain.fields.name} – ${expectedTitles.home()}`, + summary: () => `Summary – ${supplyChain.fields.name} – ${expectedTitles.home()}`, + strategicActions: { + summary: () => `Strategic actions – ${supplyChain.fields.name} – ${expectedTitles.home()}`, + update: { + info: () => `Update information - ${strategicAction.fields.name} update – ${supplyChain.fields.name} – ${expectedTitles.home()}`, + timing: () => `Expected completion date - ${strategicAction.fields.name} update – ${supplyChain.fields.name} – ${expectedTitles.home()}`, + status: () => `Current delivery status - ${strategicAction.fields.name} update – ${supplyChain.fields.name} – ${expectedTitles.home()}`, + revisedTiming: () => `Revised expected completion date - ${strategicAction.fields.name} update – ${supplyChain.fields.name} – ${expectedTitles.home()}`, + confirm: () => `Check your answers - ${strategicAction.fields.name} update – ${supplyChain.fields.name} – ${expectedTitles.home()}`, + review: () => `Current monthly update - ${strategicAction.fields.name} – ${supplyChain.fields.name} – ${expectedTitles.home()}`, + } + }, + updateComplete: () => `Update complete – ${supplyChain.fields.name} – ${expectedTitles.home()}`, + } +}; + + +describe('The Home Page', () => { + it('has the correct title', () => { + cy.visit(urls.home); + cy.title().should('equal', expectedTitles.home()); + }); +}); + +describe('The Task List page', () => { + it('has the correct title', () => { + cy.visit(urls.supplyChain.taskList); + cy.title().should('equal', expectedTitles.supplyChain.taskList()) + }); +}); + +describe('The Supply Chain Summary page', () => { + it('has the correct title', () => { + cy.visit(urls.supplyChain.summary); + cy.title().should('equal', expectedTitles.supplyChain.summary()) + }); +}); + +describe('The Strategic Actions Summary page', () => { + it('has the correct title', () => { + cy.visit(urls.supplyChain.strategicActions.summary); + cy.title().should('equal', expectedTitles.supplyChain.strategicActions.summary()) + }); +}); + +describe('The Strategic Action Update Info page', () => { + it('has the correct title', () => { + cy.visit(urls.supplyChain.strategicActions.update.info); + cy.title().should('equal', expectedTitles.supplyChain.strategicActions.update.info()) + }); +}); + +describe('The Strategic Action Update Timing page', () => { + it('has the correct title', () => { + cy.visit(urls.supplyChain.strategicActions.update.timing); + cy.title().should('equal', expectedTitles.supplyChain.strategicActions.update.timing()) + }); +}); + +describe('The Strategic Action Update Status page', () => { + it('has the correct title', () => { + cy.visit(urls.supplyChain.strategicActions.update.status); + cy.title().should('equal', expectedTitles.supplyChain.strategicActions.update.status()) + }); +}); + +describe('The Strategic Action Update Revised Timing page', () => { + it('has the correct title', () => { + cy.visit(urls.supplyChain.strategicActions.update.revisedTiming); + cy.title().should('equal', expectedTitles.supplyChain.strategicActions.update.revisedTiming()) + }); +}); + +describe('The Strategic Action Update Check Your Answers page', () => { + it('has the correct title', () => { + cy.visit(urls.supplyChain.strategicActions.update.confirm); + cy.title().should('equal', expectedTitles.supplyChain.strategicActions.update.confirm()) + }); +}); + +describe('The Strategic Action Update Complete page', () => { + it('has the correct title', () => { + cy.visit(urls.supplyChain.taskList); + cy.mainForm().submitButton().click() + cy.title().should('equal', expectedTitles.supplyChain.updateComplete()) + }); +}); + +describe('The Strategic Action Update Review page', () => { + it('has the correct title', () => { + cy.visit(urls.supplyChain.taskList); + cy.get(`#updates .govuk-link[href="${urls.supplyChain.strategicActions.update.review}"]`).click() + cy.title().should('equal', expectedTitles.supplyChain.strategicActions.update.review()) + }); +}); diff --git a/cypress/integration/task_complete_spec.js b/cypress/integration/task_complete_spec.js index e7449369..6cb0544d 100644 --- a/cypress/integration/task_complete_spec.js +++ b/cypress/integration/task_complete_spec.js @@ -38,7 +38,7 @@ describe('The Supply Chain TaskComplete Page', () => { ) }) it('displays the correct inset text', () => { - cy.get('div').contains(`You have given updates for 1 of 6 supply chains.`) + cy.get('h2 + p').invoke('text').should('match', /You have given updates for\s+\d+ of \d+ supply chains./) }) it('displays the correct link back to home', () => { cy.get('p').contains( diff --git a/cypress/support/utils.js b/cypress/support/utils.js index 0a33a26c..68d12a57 100644 --- a/cypress/support/utils.js +++ b/cypress/support/utils.js @@ -14,3 +14,24 @@ cy.forms = { }) } } + +export function urlBuilder(supplyChain, strategicAction, strategicActionUpdate) { + return { + home: Cypress.config('baseUrl'), + supplyChain: { + taskList: `${Cypress.config('baseUrl')}/${supplyChain.fields.slug}/`, + summary: `${Cypress.config('baseUrl')}/${supplyChain.fields.slug}/summary/`, + strategicActions: { + summary: `${Cypress.config('baseUrl')}/${supplyChain.fields.slug}/strategic-actions/`, + update: { + info: `${Cypress.config('baseUrl')}/${supplyChain.fields.slug}/${strategicAction.fields.slug}/updates/${strategicActionUpdate.fields.slug}/info/`, + timing: `${Cypress.config('baseUrl')}/${supplyChain.fields.slug}/${strategicAction.fields.slug}/updates/${strategicActionUpdate.fields.slug}/timing/`, + status: `${Cypress.config('baseUrl')}/${supplyChain.fields.slug}/${strategicAction.fields.slug}/updates/${strategicActionUpdate.fields.slug}/delivery-status/`, + revisedTiming: `${Cypress.config('baseUrl')}/${supplyChain.fields.slug}/${strategicAction.fields.slug}/updates/${strategicActionUpdate.fields.slug}/revised-timing/`, + confirm: `${Cypress.config('baseUrl')}/${supplyChain.fields.slug}/${strategicAction.fields.slug}/updates/${strategicActionUpdate.fields.slug}/confirm/`, + review: `/${supplyChain.fields.slug}/${strategicAction.fields.slug}/updates/${strategicActionUpdate.fields.slug}/review/`, + } + } + } + } +}; diff --git a/defend_data_capture/supply_chains/templates/base.html b/defend_data_capture/supply_chains/templates/base.html index d7712430..73082818 100644 --- a/defend_data_capture/supply_chains/templates/base.html +++ b/defend_data_capture/supply_chains/templates/base.html @@ -5,7 +5,7 @@
-