-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d9d4271
commit 5bc140b
Showing
9 changed files
with
364 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
import React from 'react' | ||
import { Link } from 'govuk-react' | ||
import { Link as ReactRouterLink } from 'react-router-dom/cjs/react-router-dom' | ||
|
||
import { DefaultLayout } from '../../components' | ||
import urls from '../../../lib/urls' | ||
import SummaryTable from '../../components/SummaryTable' | ||
import ExportWin from '../../components/Resource/ExportWin' | ||
|
||
import { ExportWinTitle, ExportWinsLink, VerticalSpacer } from './Details' | ||
|
||
const toYesNo = (val) => { | ||
if (val === undefined || val === null) return | ||
return val ? 'Yes' : 'No' | ||
} | ||
|
||
const CustomerFeedback = ({ | ||
match: { | ||
params: { winId }, | ||
}, | ||
}) => ( | ||
<DefaultLayout | ||
heading="Customer feedback" | ||
pageTitle={<ExportWinTitle id={winId} />} | ||
breadcrumbs={[ | ||
{ | ||
link: urls.dashboard.index(), | ||
text: 'Home', | ||
}, | ||
{ | ||
link: urls.companies.exportWins.index(), | ||
text: 'Export wins', | ||
}, | ||
{ | ||
text: <ExportWinTitle id={winId} />, | ||
link: urls.companies.exportWins.details(winId), | ||
}, | ||
{ text: 'Customer feedback' }, | ||
]} | ||
> | ||
<ExportWin id={winId} progressBox={true}> | ||
{(_, win) => { | ||
const response = win?.customer_response || {} | ||
return ( | ||
<> | ||
<SummaryTable caption="1. To what extent did our support help in?"> | ||
<SummaryTable.Row heading="Securing the win overall?"> | ||
{response.our_support?.name} | ||
</SummaryTable.Row> | ||
<SummaryTable.Row heading="Gaining access to contacts?"> | ||
{response.access_to_contacts?.name} | ||
</SummaryTable.Row> | ||
<SummaryTable.Row heading="Getting information or improved understanding of this country?"> | ||
{response.access_to_information?.name} | ||
</SummaryTable.Row> | ||
<SummaryTable.Row heading="Improving your profile or credibility in the country?"> | ||
{response.improved_profile?.name} | ||
</SummaryTable.Row> | ||
<SummaryTable.Row heading="Having confidence to explore or expand in the country?"> | ||
{response.gained_confidence?.name} | ||
</SummaryTable.Row> | ||
<SummaryTable.Row heading="Developing or nurturing critical relationships?"> | ||
{response.developed_relationships?.name} | ||
</SummaryTable.Row> | ||
<SummaryTable.Row heading="Overcoming a problem in the country (eg legal, regulatory, commercial)"> | ||
{response.overcame_problem?.name} | ||
</SummaryTable.Row> | ||
</SummaryTable> | ||
<SummaryTable caption="2. About this win"> | ||
<SummaryTable.Row heading="The win involved a foreign government or state-owned enterprise (eg as an intermediary or facilitator)"> | ||
{toYesNo(response.involved_state_enterprise)} | ||
</SummaryTable.Row> | ||
<SummaryTable.Row heading="Our support was a prerequisite to generate this value"> | ||
{toYesNo(response.interventions_were_prerequisite)} | ||
</SummaryTable.Row> | ||
<SummaryTable.Row heading="Our support helped you achieve this win more quickly"> | ||
{toYesNo(response.support_improved_speed)} | ||
</SummaryTable.Row> | ||
<SummaryTable.Row heading="It enabled you to expand into a new market"> | ||
{toYesNo(response.has_enabled_expansion_into_new_market)} | ||
</SummaryTable.Row> | ||
<SummaryTable.Row heading="It enabled you to maintain or expand in an existing market"> | ||
{toYesNo(response.has_enabled_expansion_into_existing_market)} | ||
</SummaryTable.Row> | ||
<SummaryTable.Row heading="It enabled you to increase exports as a proportion of your turnover"> | ||
{toYesNo(response.has_increased_exports_as_percent_of_turnover)} | ||
</SummaryTable.Row> | ||
<SummaryTable.Row heading="If you hadn't achieved this win, your company might have stopped exporting"> | ||
{toYesNo(response.company_was_at_risk_of_not_exporting)} | ||
</SummaryTable.Row> | ||
<SummaryTable.Row heading="Apart from this win, you already have plans to export in the next 12 months"> | ||
{toYesNo(response.has_explicit_export_plans)} | ||
</SummaryTable.Row> | ||
</SummaryTable> | ||
<SummaryTable caption="3. Your export experience"> | ||
<SummaryTable.Row heading="Apart from this win, when did your company last export goods or services?"> | ||
{response.last_export?.name} | ||
</SummaryTable.Row> | ||
</SummaryTable> | ||
<SummaryTable caption="4. Marketing"> | ||
<SummaryTable.Row heading="Would you be willing for DBT/Exporting is GREAT to feature your success in marketing materials?"> | ||
{response.case_study_willing?.name} | ||
</SummaryTable.Row> | ||
<SummaryTable.Row heading="How did you first hear about DBT(or it predecessor, DIT)?"> | ||
{response.marketing_source?.name} | ||
</SummaryTable.Row> | ||
</SummaryTable> | ||
</> | ||
) | ||
}} | ||
</ExportWin> | ||
<VerticalSpacer> | ||
<ExportWinsLink /> | ||
<Link as={ReactRouterLink} to={urls.companies.exportWins.details(winId)}> | ||
Back | ||
</Link> | ||
</VerticalSpacer> | ||
</DefaultLayout> | ||
) | ||
|
||
export default CustomerFeedback |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
134 changes: 134 additions & 0 deletions
134
test/component/cypress/specs/ExportWins/CustomerFeedback.cy.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
/* eslint-disable prettier/prettier */ | ||
import React from 'react' | ||
|
||
import { | ||
assertSummaryTableStrict, | ||
assertBreadcrumbs, | ||
} from '../../../../functional/cypress/support/assertions' | ||
import CustomerFeedback from '../../../../../src/client/modules/ExportWins/CustomerFeedback' | ||
import { createTestProvider } from '../provider' | ||
|
||
const toYesNo = x => | ||
x ? 'Yes' : 'No' | ||
|
||
const dummyExportWin = (prefix, booleans) => ({ | ||
id: `${prefix}-id`, | ||
name_of_export: `${prefix}-name_of_export`, | ||
country: { | ||
name: `${prefix}-country`, | ||
}, | ||
customer_response: { | ||
our_support: { name: `${prefix}-our_support` }, | ||
access_to_contacts: { name: `${prefix}-access_to_contacts` }, | ||
access_to_information: { name: `${prefix}-access_to_information` }, | ||
improved_profile: { name: `${prefix}-improved_profile` }, | ||
gained_confidence: { name: `${prefix}-gained_confidence` }, | ||
developed_relationships: { name: `${prefix}-developed_relationships` }, | ||
overcame_problem: { name: `${prefix}-overcame_problem` }, | ||
|
||
involved_state_enterprise: booleans, | ||
interventions_were_prerequisite: booleans, | ||
support_improved_speed: booleans, | ||
has_enabled_expansion_into_new_market: booleans, | ||
has_enabled_expansion_into_existing_market: booleans, | ||
has_increased_exports_as_percent_of_turnover: booleans, | ||
company_was_at_risk_of_not_exporting: booleans, | ||
has_explicit_export_plans: booleans, | ||
|
||
last_export: { name: `${prefix}-last_export` }, | ||
case_study_willing: { name: `${prefix}-case_study_willing` }, | ||
marketing_source: { name: `${prefix}-marketing_source` }, | ||
}, | ||
}) | ||
|
||
describe('ExportWins/CustomerFeedback', () => { | ||
;[ | ||
{testTitle: 'All true', win: dummyExportWin('all-true', true)}, | ||
{testTitle: 'All false', win: dummyExportWin('all-false', false)}, | ||
].forEach(({testTitle, win}) => { | ||
it(testTitle, () => { | ||
const Provider = createTestProvider({ | ||
'Export Win': () => Promise.resolve(win), | ||
TASK_GET_REMINDER_SUMMARY: () => Promise.resolve(), | ||
}) | ||
cy.mount( | ||
<Provider> | ||
<CustomerFeedback match={{ params: { winId: win.id } }} /> | ||
</Provider> | ||
) | ||
|
||
assertBreadcrumbs({ | ||
Home: '/', | ||
'Export wins': '/exportwins', | ||
[`${win.name_of_export} to ${win.country.name}`]: `/exportwins/${win.id}/details`, | ||
'Customer feedback': null, | ||
}) | ||
|
||
cy.contains('h1', /^\s*Customer feedback\s*$/) | ||
|
||
assertSummaryTableStrict({ | ||
caption: '1. To what extent did our support help in?', | ||
rows: [ | ||
['Securing the win overall?', win.customer_response.our_support.name], | ||
['Gaining access to contacts?', win.customer_response.access_to_contacts.name], | ||
['Getting information or improved understanding of this country?', win.customer_response.access_to_information.name], | ||
['Improving your profile or credibility in the country?', win.customer_response.improved_profile.name], | ||
['Having confidence to explore or expand in the country?', win.customer_response.gained_confidence.name], | ||
['Developing or nurturing critical relationships?', win.customer_response.developed_relationships.name], | ||
['Overcoming a problem in the country (eg legal, regulatory, commercial)', win.customer_response.overcame_problem.name], | ||
], | ||
}) | ||
|
||
assertSummaryTableStrict({ | ||
caption: '2. About this win', | ||
rows: [ | ||
['The win involved a foreign government or state-owned enterprise (eg as an intermediary or facilitator)', toYesNo(win.customer_response.involved_state_enterprise)], | ||
['Our support was a prerequisite to generate this value', toYesNo(win.customer_response.interventions_were_prerequisite)], | ||
['Our support helped you achieve this win more quickly', toYesNo(win.customer_response.support_improved_speed)], | ||
['It enabled you to expand into a new market', toYesNo(win.customer_response.has_enabled_expansion_into_new_market)], | ||
['It enabled you to maintain or expand in an existing market', toYesNo(win.customer_response.has_enabled_expansion_into_existing_market)], | ||
['It enabled you to increase exports as a proportion of your turnover', toYesNo(win.customer_response.has_increased_exports_as_percent_of_turnover)], | ||
["If you hadn't achieved this win, your company might have stopped exporting", toYesNo(win.customer_response.company_was_at_risk_of_not_exporting)], | ||
['Apart from this win, you already have plans to export in the next 12 months', toYesNo(win.customer_response.has_explicit_export_plans)], | ||
], | ||
}) | ||
|
||
assertSummaryTableStrict({ | ||
caption: '3. Your export experience', | ||
rows: [ | ||
['Apart from this win, when did your company last export goods or services?', win.customer_response.last_export.name], | ||
], | ||
}) | ||
|
||
assertSummaryTableStrict({ | ||
caption: '4. Marketing', | ||
rows: [ | ||
['Would you be willing for DBT/Exporting is GREAT to feature your success in marketing materials?', win.customer_response.case_study_willing.name], | ||
['How did you first hear about DBT(or it predecessor, DIT)?', win.customer_response.marketing_source.name], | ||
], | ||
}) | ||
|
||
// Assert captions appear in a particular order | ||
;[ | ||
'1. To what extent did our support help in?', | ||
'2. About this win', | ||
'3. Your export experience', | ||
'4. Marketing', | ||
].forEach((heading, i) => { | ||
cy.get('caption').eq(i).should('have.text', heading) | ||
}) | ||
|
||
// This little trick ensures that we are not accidentally | ||
// making assertions about the "Export wins" link in breadcrumbs | ||
cy.contains('Export winsBack') | ||
.within(() => { | ||
cy.contains('a', 'Export wins') | ||
.should('have.attr', 'href', '/exportwins') | ||
|
||
cy.contains('a', 'Back') | ||
.should('have.attr', 'href', `/exportwins/${win.id}/details`) | ||
}) | ||
}) | ||
|
||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.