From 6b761658668e6d6ed3aa3c0293e2e3fbee750d1a Mon Sep 17 00:00:00 2001 From: Peter Hudec Date: Tue, 24 Sep 2024 16:11:37 +0100 Subject: [PATCH] Make the export wins moved banner only appear on the Export tab --- .../components/CompanyLocalHeader/index.jsx | 10 +++++-- .../specs/companies/export-wins-moved-spec.js | 30 +++++++++++++++++-- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/src/client/components/CompanyLocalHeader/index.jsx b/src/client/components/CompanyLocalHeader/index.jsx index 4e5f480167e..0706e6c6199 100644 --- a/src/client/components/CompanyLocalHeader/index.jsx +++ b/src/client/components/CompanyLocalHeader/index.jsx @@ -129,9 +129,9 @@ const DATA_HUB_HAS_MOVED_MESSAGE = ( href={DATA_HUB_HAS_MOVED_LINK} target="_blank" rel="noopener noreferrer" - aria-label="Find out more about historic wins moved to Data Hub" + aria-label="See the export wins announcement" > - find out more + see the export wins announcement . @@ -151,7 +151,11 @@ const CompanyLocalHeader = ({ company.id, company.name )} - flashMessages={[[DATA_HUB_HAS_MOVED_MESSAGE, ...flashMessages]]} + flashMessages={ + breadcrumbs[0].text === 'Exports' + ? [[DATA_HUB_HAS_MOVED_MESSAGE, ...flashMessages]] + : flashMessages + } > diff --git a/test/functional/cypress/specs/companies/export-wins-moved-spec.js b/test/functional/cypress/specs/companies/export-wins-moved-spec.js index f9b986c6026..7847193f398 100644 --- a/test/functional/cypress/specs/companies/export-wins-moved-spec.js +++ b/test/functional/cypress/specs/companies/export-wins-moved-spec.js @@ -3,19 +3,43 @@ const urls = require('../../../../../src/lib/urls') describe('Export wins moved banner', () => { it('There should be a banner informing about export wins moving to Data Hub on the company page', () => { - cy.visit(urls.companies.detail(company.dnbCorp.id)) + cy.visit(urls.companies.exports.index(company.dnbCorp.id)) cy.get('[data-test="status-message"') .should( 'have.text', - 'Historic export wins have now moved to Data Hub, find out more.' + 'Historic export wins have now moved to Data Hub, see the export wins announcement.' ) .within(() => { - cy.contains('a', 'find out more').should( + cy.contains('a', 'see the export wins announcement').should( 'have.attr', 'href', 'https://data-services-help.trade.gov.uk/data-hub/updates/announcements/export-wins-has-moved-to-data-hub/' ) }) }) + + describe("There should't be a banner in the other tabs", () => { + ;[ + 'overview', + 'activity', + 'business-details', + 'contacts', + 'account-management', + 'investments/projects', + 'orders', + ].forEach((slug) => + it(slug, () => { + cy.visit(`/companies/${company.dnbCorp.id}/${slug}`) + + // We need to wait for company name appear... + cy.contains(company.dnbCorp.name) + + // ...so that this waits for whent the data has been loaded and rendered + cy.contains('Historic export wins have now moved to Data Hub').should( + 'not.exist' + ) + }) + ) + }) })