-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12058 from bbc/WSTEAM1-1349-lite-site-cta
WSTEAM1-1349: Lite Site CTA
- Loading branch information
Showing
28 changed files
with
7,214 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* eslint-disable import/prefer-default-export */ | ||
import { liteEnabledServices } from '#app/components/LiteSiteCta/liteSiteConfig'; | ||
|
||
export const testsForLiteOnly = ({ service, pageType }) => { | ||
describe(`Running testsForLiteOnly for ${service} ${pageType}`, () => { | ||
describe('CTA: Lite', () => { | ||
if (liteEnabledServices.includes(service)) { | ||
it('Clicking the link to the main site should navigate to canonical site', () => { | ||
cy.get('[data-e2e="to-main-site"]').within(() => { | ||
cy.get('a') | ||
.should('have.attr', 'href') | ||
.then($href => { | ||
cy.get('a').click(); | ||
cy.url().should('eq', $href).should('not.contain', '.lite'); | ||
}); | ||
}); | ||
cy.go('back'); | ||
}); | ||
|
||
it('Clicking the link to the Information page should navigate to lite site', () => { | ||
cy.get('[data-e2e="information-page"]').within(() => { | ||
cy.get('a') | ||
.should('have.attr', 'href') | ||
.then($href => { | ||
cy.get('a').click(); | ||
cy.url().should('eq', $href); | ||
}) | ||
.and('contain', '.lite'); | ||
}); | ||
cy.go('back'); | ||
}); | ||
} | ||
}); | ||
}); | ||
}; |
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,16 @@ | ||
import Url from 'url-parse'; | ||
|
||
export default path => { | ||
/** | ||
* Appends .lite to the pathname, before appending query string values | ||
* | ||
* */ | ||
|
||
const urlFromPath = new Url(path); | ||
|
||
if (!urlFromPath.pathname.includes('.lite')) { | ||
urlFromPath.set('pathname', `${urlFromPath.pathname}.lite`); | ||
} | ||
|
||
return urlFromPath.href; | ||
}; |
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,35 @@ | ||
const { default: getLiteUrl } = require('.'); | ||
|
||
describe('getLiteUrl', () => { | ||
[ | ||
'http://localhost:7080', | ||
'https://www.test.bbc.com', | ||
'https://www.bbc.com', | ||
].forEach(baseUrl => { | ||
describe(`with base url ${baseUrl}`, () => { | ||
it('should return lite url', () => { | ||
expect(getLiteUrl(`${baseUrl}/pathname`)).toEqual( | ||
`${baseUrl}/pathname.lite`, | ||
); | ||
}); | ||
|
||
it('should not append .lite to lite path', () => { | ||
expect(getLiteUrl(`${baseUrl}/pathname.lite`)).toEqual( | ||
`${baseUrl}/pathname.lite`, | ||
); | ||
}); | ||
|
||
it('should return lite url for path with query string params', () => { | ||
expect(getLiteUrl(`${baseUrl}/pathname?query_string=value`)).toEqual( | ||
`${baseUrl}/pathname.lite?query_string=value`, | ||
); | ||
}); | ||
|
||
it('should not append .lite to lite path with query string params', () => { | ||
expect( | ||
getLiteUrl(`${baseUrl}/pathname.lite?query_string=value`), | ||
).toEqual(`${baseUrl}/pathname.lite?query_string=value`); | ||
}); | ||
}); | ||
}); | ||
}); |
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.