Skip to content
This repository has been archived by the owner on Nov 29, 2023. It is now read-only.

Commit

Permalink
Merge pull request #56 from uktrade/feature/title-tag
Browse files Browse the repository at this point in the history
Feature/title tag
  • Loading branch information
NickFitz authored May 25, 2021
2 parents 359b8f4 + 69b1d15 commit bfdad45
Show file tree
Hide file tree
Showing 19 changed files with 221 additions and 8 deletions.
19 changes: 19 additions & 0 deletions cypress/fixtures/strategicActionUpdates.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
]
22 changes: 22 additions & 0 deletions cypress/fixtures/strategicActions.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
]
20 changes: 19 additions & 1 deletion cypress/fixtures/supplyChains.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "[email protected]",
"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
}
}
]
7 changes: 4 additions & 3 deletions cypress/integration/home_page_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
)
Expand All @@ -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()
Expand Down
111 changes: 111 additions & 0 deletions cypress/integration/page_titles_spec.js
Original file line number Diff line number Diff line change
@@ -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())
});
});
2 changes: 1 addition & 1 deletion cypress/integration/task_complete_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
21 changes: 21 additions & 0 deletions cypress/support/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/`,
}
}
}
}
};
2 changes: 1 addition & 1 deletion defend_data_capture/supply_chains/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<head>
<meta charset="utf-8">
<title>{% block page_title %}Defend Data Capture{% endblock page_title %}</title>
<title>{% block page_title %}Update supply chain information{% endblock page_title %}</title>
<meta name="robots" content="noindex, nofollow">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<meta name="theme-color" content="#0b0c0c">
Expand Down
3 changes: 2 additions & 1 deletion defend_data_capture/supply_chains/templates/sau_review.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

{% extends "base.html" %}

{% block page_title %}Current monthly update - {{ strategic_action.name }} – {{ supply_chain.name }} – {{ block.super }}{% endblock page_title %}

{% block breadcrumbs %}
<nav class="govuk-breadcrumbs" aria-label="breadcrumbs">
<ol class="govuk-breadcrumbs__list">
Expand Down
3 changes: 2 additions & 1 deletion defend_data_capture/supply_chains/templates/sc_summary.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

{% extends "base.html" %}

{% block page_title %}Summary – {{ supply_chain.name }} – {{ block.super }}{% endblock page_title %}

{% block breadcrumbs %}
<nav class="govuk-breadcrumbs" aria-label="breadcrumbs">
<ol class="govuk-breadcrumbs__list">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{% extends "base.html" %}

{% block page_title %}Strategic actions – {{ supply_chain.name }} – {{ block.super }}{% endblock page_title %}

{% block breadcrumbs %}
<nav class="govuk-breadcrumbs" aria-label="breadcrumbs">
<ol class="govuk-breadcrumbs__list">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{% extends 'base.html' %}

{% block page_title %}{{ strategic_action_update.strategic_action.name }} update – {{ strategic_action_update.supply_chain.name }} – {{ block.super }}{% endblock page_title %}

{% block breadcrumbs %}
{% include "supply_chains/includes/monthly_update_form_breadcrumbs.html" %}
{% endblock breadcrumbs %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{% extends 'supply_chains/monthly_update_form_base.html' %}

{% block page_title %}Update information - {{ block.super }}{% endblock page_title %}

{% block form %}
{% with strategic_action_update.strategic_action.last_submitted_update as previous_update %}
{% if previous_update.content %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{% extends 'supply_chains/monthly_update_form_base.html' %}

{% block page_title %}Revised expected completion date - {{ block.super }}{% endblock page_title %}

{% block form %}
{% include 'supply_chains/includes/existing_completion_date.html' %}
<form method="post" action="">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{% extends 'supply_chains/monthly_update_form_base.html' %}

{% block page_title %}Current delivery status - {{ block.super }}{% endblock page_title %}

{% block form %}
{% include 'supply_chains/includes/existing_completion_date.html' %}
<form method="post" action="">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{% extends 'base.html' %}

{% block page_title %}Check your answers - {{ strategic_action_update.strategic_action.name }} update – {{ strategic_action_update.supply_chain.name }} – {{ block.super }}{% endblock page_title %}

{% block breadcrumbs %}
{% include "supply_chains/includes/monthly_update_form_breadcrumbs.html" %}
{% endblock breadcrumbs %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{% extends 'supply_chains/monthly_update_form_base.html' %}

{% block page_title %}Expected completion date - {{ block.super }}{% endblock page_title %}

{% block form %}
{% include 'supply_chains/includes/existing_completion_date.html' %}
<form method="post" action="">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{% extends "base.html" %}

{% block page_title %}Update complete – {{ view.supply_chain.name }} – {{ block.super }}{% endblock page_title %}

{% block breadcrumbs %}
<nav class="govuk-breadcrumbs" aria-label="breadcrumbs">
<ol class="govuk-breadcrumbs__list">
Expand Down
2 changes: 2 additions & 0 deletions defend_data_capture/supply_chains/templates/task_list.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{% extends "base.html" %}

{% block page_title %}Update {{ view.supply_chain.name }} – {{ block.super }}{% endblock %}

{% block breadcrumbs %}
<nav class="govuk-breadcrumbs" aria-label="breadcrumbs">
<ol class="govuk-breadcrumbs__list">
Expand Down

0 comments on commit bfdad45

Please sign in to comment.