Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hoc loading error states #1589

Merged
merged 62 commits into from
May 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
4003180
Render page header and styles for Loading and Error states
sareh Mar 28, 2019
a29d3d2
Merge remote-tracking branch 'origin' into loading-state-mvp
sareh Mar 28, 2019
a521a30
Add snapshot unit tests for loading and error states
sareh Mar 28, 2019
2eee026
Change order of contexts & styles to enable reusability of the Contai…
sareh Mar 29, 2019
384dffa
Ensure Error and Loading states have the consent banner - so require …
sareh Mar 29, 2019
e1e6ead
Merge branch 'latest' into loading-state-mvp
sareh Mar 29, 2019
e885f23
Merge branch 'latest' into loading-state-mvp
sareh Mar 29, 2019
94a23e2
Merge branch 'latest' into loading-state-mvp
sareh Apr 1, 2019
1dabe93
Move check for articleData
sareh Apr 1, 2019
181436f
ensure bbcOrigin prop is optional
sareh Apr 1, 2019
1dd8747
Update snapshot
sareh Apr 1, 2019
593d1cd
Merge branch 'latest' into loading-state-mvp
sareh Apr 1, 2019
eeaa1d8
Move deconstruction to start
sareh Apr 1, 2019
a280405
Merge branch 'latest' into loading-state-mvp
sareh Apr 2, 2019
364d785
Merge branch 'latest' into loading-state-mvp
Apr 3, 2019
cbcc48e
Merge branch 'latest' into loading-state-mvp
sareh Apr 9, 2019
e0c0b67
Merge branch 'latest' into loading-state-mvp
thekp Apr 11, 2019
d279e8a
add default props for article wrapper and try/catch for data validator
Apr 11, 2019
78dde63
update snapshots
Apr 11, 2019
9570f1e
Merge branch 'latest' of github.com:bbc/simorgh into loading-state-mvp
Apr 11, 2019
3aedf7a
Merge branch 'loading-state-mvp' of github.com:bbc/simorgh into loadi…
Apr 11, 2019
ec150ac
testing the idea of using HOC for sahred Loading and error states
Apr 12, 2019
73884aa
Move page wrapper to /Layouts, add withData HOC
Apr 12, 2019
ca05e68
Remove imported hooks
Apr 12, 2019
f08c70f
Remove ES5 function syntax
Apr 14, 2019
0fa47e0
Return default error component with 500 status
Apr 14, 2019
b460c3d
Updsting withData HOC
Apr 15, 2019
7e63db8
Merge remote-tracking branch 'origin/latest' into hoc-loading-error-s…
Apr 15, 2019
3d7b577
Updating withData HOC
Apr 15, 2019
8c2945b
Add snapshot tests for new HOC components
Apr 16, 2019
081344f
Merge branch 'latest' of github.com:bbc/simorgh into hoc-loading-erro…
Apr 16, 2019
4e73424
Add compose to helpers dir and refference the author
Apr 16, 2019
ffef5dd
use full render instead of shallow render
Apr 16, 2019
8f9c3c5
Remove recompose dependancy
Apr 16, 2019
f2b39dc
use correct case for naming imports
Apr 17, 2019
06ebe4d
Fixing missing isAmp prop and updating snapshots
Apr 23, 2019
f9ec31f
Merge branch 'latest' of github.com:bbc/simorgh into hoc-loading-erro…
Apr 23, 2019
7a1773a
Update snapshots and use deepget to get status or define a default
Apr 23, 2019
6cb338f
Merge branch 'latest' into hoc-loading-error-states
Apr 23, 2019
b84f0f6
reduce error checking complexity around the data object
Apr 23, 2019
19297a9
Merge branch 'hoc-loading-error-states' of github.com:bbc/simorgh int…
Apr 23, 2019
901eb4d
Merge branch 'latest' of github.com:bbc/simorgh into hoc-loading-erro…
Apr 23, 2019
d8367b7
Add method to return true if assetData and 200 status is returned
Apr 23, 2019
04702ff
Updating snapshots
Apr 23, 2019
56c99f5
Move proptypes outside of the component they check
Apr 24, 2019
bcd80fd
Removing unused import
Apr 24, 2019
752ff16
Merge branch 'latest' into hoc-loading-error-states
Apr 24, 2019
7247ef4
Remove default prop for BBCOrigin and set as required
Apr 24, 2019
dd679ce
Update src/app/containers/PageHandlers/withPageWrapper.jsx
Apr 24, 2019
db7805c
Update src/app/containers/PageHandlers/withPageWrapper.jsx
Apr 24, 2019
6859597
Updating snapshots
Apr 24, 2019
6748371
Merge branch 'hoc-loading-error-states' of github.com:bbc/simorgh int…
Apr 24, 2019
3726919
Update src/app/containers/PageHandlers/withData.jsx
Apr 25, 2019
deedd19
Update ArticleContainer tests with mocks of HOC
Apr 29, 2019
33c3bf2
merged in latest and fixed conflicts
Apr 29, 2019
e22b30d
Merge branch 'hoc-loading-error-states' of github.com:bbc/simorgh int…
Apr 29, 2019
86d7f77
remove unneeded if statement
Apr 29, 2019
3604057
Remove isRequired for bbcOrigin prop
Apr 29, 2019
41e9a35
Merge branch 'latest' into hoc-loading-error-states
Apr 29, 2019
5f64100
Merge in latest and refactor to use pageData, isAmp and service values
May 11, 2019
0a15398
Merge branch 'latest' into hoc-loading-error-states
jamesbrumpton May 13, 2019
824571d
Merge branch 'latest' into hoc-loading-error-states
May 14, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions src/app/Layouts/defaultPageWrapper.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React, { Fragment } from 'react';
import { node, string, bool } from 'prop-types';
import Helmet from 'react-helmet';
import HeaderContainer from '../containers/Header';
import FooterContainer from '../containers/Footer';
import { ServiceContextProvider } from '../contexts/ServiceContext';
import { RequestContextProvider } from '../contexts/RequestContext';
import GlobalStyle from '../lib/globalStyles';
import ConsentBanner from '../containers/ConsentBanner';

const PageWrapper = ({ bbcOrigin, children, service, isAmp }) => (
<Fragment>
<GlobalStyle />
<RequestContextProvider
platform={isAmp ? 'amp' : 'canonical'}
bbcOrigin={bbcOrigin}
>
<ServiceContextProvider service={service}>
<Helmet>
<link rel="manifest" href={`/${service}/articles/manifest.json`} />
</Helmet>
<ConsentBanner />
<HeaderContainer />
{children}
<FooterContainer />
</ServiceContextProvider>
</RequestContextProvider>
</Fragment>
);

PageWrapper.propTypes = {
bbcOrigin: string,
children: node.isRequired,
service: string.isRequired,
isAmp: bool.isRequired,
};

PageWrapper.defaultProps = {
bbcOrigin: null,
};

PageWrapper.defaultProps = {};

export default PageWrapper;
335 changes: 17 additions & 318 deletions src/app/containers/Article/__snapshots__/index.test.jsx.snap
Original file line number Diff line number Diff line change
@@ -1,324 +1,23 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`ArticleContainer Component 200 status code should render correctly for news 1`] = `
<React.Fragment>
<GlobalStyleComponent />
<ServiceContextProvider
service="news"
exports[`ArticleContainer Component Composing the Article Container using the page handlers should compose articleContainer with the Page Handler in the correct order 1`] = `
<div
id="PageWrapperContainer"
>
<div
id="LoadingContainer"
>
<RequestContextProvider
bbcOrigin="https://www.bbc.co.uk"
platform="canonical"
<div
id="ErrorContainer"
>
<HelmetWrapper
defer={true}
encodeSpecialCharacters={true}
<div
id="DataContainer"
>
<link
href="/news/articles/manifest.json"
rel="manifest"
/>
</HelmetWrapper>
<ConsentBanner />
<HeaderContainer />
<ArticleMain
articleData={
Object {
"content": Object {
"model": Object {
"blocks": Array [
Object {
"model": Object {
"blocks": Array [
Object {
"model": Object {
"blocks": Array [
Object {
"model": Object {
"blocks": Array [
Object {
"model": Object {
"attributes": Array [],
"text": "Article Headline",
},
"type": "fragment",
},
],
"text": "Article Headline",
},
"type": "paragraph",
},
],
},
"type": "text",
},
],
},
"type": "headline",
},
Object {
"model": Object {
"blocks": Array [
Object {
"model": Object {
"blocks": Array [
Object {
"model": Object {
"attributes": Array [],
"text": "A paragraph.",
},
"type": "fragment",
},
],
"text": "A paragraph.",
},
"type": "paragraph",
},
],
},
"type": "text",
},
],
},
},
"metadata": Object {
"created": 1514808060000,
"createdBy": "News",
"firstPublished": 1514808060000,
"id": "urn:bbc:ares::article:c0000000001o",
"lastPublished": 1514811600000,
"lastUpdated": 1514815200000,
"locators": Object {
"optimoUrn": "urn:bbc:optimo:asset:c0000000001o",
},
"passport": Object {
"category": "news",
"genre": null,
"home": "http://www.bbc.co.uk/ontologies/passport/home/News",
"language": "en-gb",
},
"tags": Object {
"about": Array [
Object {
"curationType": Array [
"vivo-stream",
],
"thingId": "2351f2b2-ce36-4f44-996d-c3c4f7f90eaa",
"thingLabel": "Royal Wedding 2018",
"thingSameAs": Array [
"http://dbpedia.org/resource/Queen_Victoria",
"http://rdf.freebase.com/ns/m.0cw10",
],
"thingType": Array [
"Thing",
"Event",
],
"thingUri": "http://www.bbc.co.uk/things/2351f2b2-ce36-4f44-996d-c3c4f7f90eaa#id",
"topicId": "cpwpy79d6dxt",
"topicName": "Royal Wedding 2018",
},
Object {
"curationType": Array [
"vivo-stream",
],
"thingId": "803eaeb9-c0c3-4f1b-9a66-90efac3df2dc",
"thingLabel": "Duchess of Sussex",
"thingSameAs": Array [],
"thingType": Array [
"Person",
],
"thingUri": "http://www.bbc.co.uk/things/803eaeb9-c0c3-4f1b-9a66-90efac3df2dc#id",
"topicId": "cg3mq45zq4xt",
"topicName": "Duchess of Sussex",
},
],
"mentions": Array [
Object {
"thingId": "1efbf3e5-b330-49a1-b531-b507ab027c96",
"thingLabel": "Queen Victoria",
"thingType": Array [
"Person",
"Thing",
],
"thingUri": "http://www.bbc.co.uk/things/1efbf3e5-b330-49a1-b531-b507ab027c96#id",
},
],
},
"type": "article",
},
"promo": Object {
"headlines": Object {
"promoHeadline": "Article Headline for Promo",
"seoHeadline": "Article Headline for SEO",
},
"id": "urn:bbc:ares::article:c0000000001o",
"locators": Object {
"optimoUrn": "urn:bbc:optimo:asset:c0000000001o",
},
"summary": "Article summary.",
"timestamp": 1514811600000,
},
}
}
/>
<FooterContainer />
</RequestContextProvider>
</ServiceContextProvider>
</React.Fragment>
`;

exports[`ArticleContainer Component 200 status code should render correctly for persian 1`] = `
<React.Fragment>
<GlobalStyleComponent />
<ServiceContextProvider
service="persian"
>
<RequestContextProvider
bbcOrigin="https://www.bbc.co.uk"
platform="canonical"
>
<HelmetWrapper
defer={true}
encodeSpecialCharacters={true}
>
<link
href="/persian/articles/manifest.json"
rel="manifest"
/>
</HelmetWrapper>
<ConsentBanner />
<HeaderContainer />
<ArticleMain
articleData={
Object {
"content": Object {
"model": Object {
"blocks": Array [
Object {
"model": Object {
"blocks": Array [
Object {
"model": Object {
"blocks": Array [
Object {
"model": Object {
"blocks": Array [
Object {
"model": Object {
"attributes": Array [],
"text": "سرصفحه مقاله",
},
"type": "fragment",
},
],
"text": "سرصفحه مقاله",
},
"type": "paragraph",
},
],
},
"type": "text",
},
],
},
"type": "headline",
},
Object {
"model": Object {
"blocks": Array [
Object {
"model": Object {
"blocks": Array [
Object {
"model": Object {
"attributes": Array [],
"text": "یک پاراگراف.",
},
"type": "fragment",
},
],
"text": "یک پاراگراف.",
},
"type": "paragraph",
},
],
},
"type": "text",
},
],
},
},
"metadata": Object {
"created": 1514808060000,
"createdBy": "Persian",
"firstPublished": 1514808060000,
"id": "urn:bbc:ares::article:cyddjz5058wo",
"lastPublished": 1514811600000,
"lastUpdated": 1514815200000,
"locators": Object {
"optimoUrn": "urn:bbc:optimo:asset:cyddjz5058wo",
},
"passport": Object {
"category": "news",
"genre": null,
"home": "http://www.bbc.co.uk/ontologies/passport/home/Persian",
"language": "fa",
},
"tags": Object {
"about": null,
"mentions": null,
},
"type": "article",
},
"promo": Object {
"headlines": Object {
"promoHeadline": "سرصفحه مقاله برای ارتقاء",
"seoHeadline": "سرصفحه مقاله",
},
"id": "urn:bbc:ares::article:cyddjz5058wo",
"locators": Object {
"optimoUrn": "urn:bbc:optimo:asset:cyddjz5058wo",
},
"summary": "خلاصه مقاله",
"timestamp": 1514811600000,
},
}
}
/>
<FooterContainer />
</RequestContextProvider>
</ServiceContextProvider>
</React.Fragment>
`;

exports[`ArticleContainer Component no data or bbcOrigin should render correctly 1`] = `null`;

exports[`ArticleContainer Component non-200 status code should render correctly 1`] = `
<React.Fragment>
<GlobalStyleComponent />
<ServiceContextProvider
service="news"
>
<RequestContextProvider
bbcOrigin="https://www.bbc.co.uk"
platform="canonical"
>
<HelmetWrapper
defer={true}
encodeSpecialCharacters={true}
>
<link
href="/news/articles/manifest.json"
rel="manifest"
/>
</HelmetWrapper>
<ConsentBanner />
<HeaderContainer />
<ErrorMain
status={451}
/>
<FooterContainer />
</RequestContextProvider>
</ServiceContextProvider>
</React.Fragment>
<div>
ArticleMain
</div>
</div>
</div>
</div>
</div>
`;
Loading