Skip to content

Commit

Permalink
Merge branch 'main' into csf-v3-callout-block-component
Browse files Browse the repository at this point in the history
  • Loading branch information
JamieB-gu committed Oct 21, 2024
2 parents ffec007 + 5dd3a58 commit c2f5bfd
Show file tree
Hide file tree
Showing 406 changed files with 5,379 additions and 8,225 deletions.
5 changes: 2 additions & 3 deletions apps-rendering/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
"dependencies": {
"@aws-sdk/client-ssm": "3.621.0",
"@aws-sdk/credential-providers": "3.621.0",
"@babel/core": "7.25.2",
"@babel/preset-env": "7.25.4",
"@babel/core": "7.25.8",
"@babel/preset-env": "7.25.8",
"@creditkarma/thrift-server-core": "1.0.4",
"@emotion/cache": "11.11.0",
"@emotion/jest": "11.11.0",
Expand Down Expand Up @@ -86,7 +86,6 @@
"eslint-plugin-jsx-a11y": "6.7.1",
"eslint-plugin-react": "7.33.2",
"express": "4.21.0",
"fetch-mock": "9.11.0",
"html-webpack-plugin": "5.6.0",
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
Expand Down
3 changes: 0 additions & 3 deletions apps-rendering/src/articleFormat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ enum ArticleDesign {
Quiz,
Interactive,
PhotoEssay,
PrintShop,
Obituary,
Correction,
FullPageInteractive,
Expand Down Expand Up @@ -215,8 +214,6 @@ const designToString = (design: ArticleDesign): string => {
return 'Interactive';
case ArticleDesign.PhotoEssay:
return 'Photo Essay';
case ArticleDesign.PrintShop:
return 'Print Shop';
case ArticleDesign.Obituary:
return 'Obituary';
case ArticleDesign.Correction:
Expand Down
63 changes: 26 additions & 37 deletions apps-rendering/src/components/Callout/Callout.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
type ArticleFormat,
Pillar,
} from '../../articleFormat';
import fetchMock from 'fetch-mock';
import { campaignDescription, mockCampaign } from 'fixtures/campaign';
import type { ReactElement } from 'react';
import Callout from '.';
Expand All @@ -20,16 +19,30 @@ futureDate.setDate(futureDate.getDate() + 2);
const pastDate = new Date();
pastDate.setDate(pastDate.getDate() - 1);

const mockFetch =
(mockedStatus: number) => (input: RequestInfo, init?: RequestInit) => {
const url = new Request(input).url;

if (
url ===
'https://callouts.code.dev-guardianapis.com/formstack-campaign/submit' &&
init?.method === 'POST'
) {
console.log(`url called: ${url}`);
return Promise.resolve(
new Response(null, { status: mockedStatus }),
);
} else {
return Promise.resolve(
new Response(JSON.stringify({ error: 'Not Found' }), {
status: 404,
}),
);
}
};

const callout = (): ReactElement => {
fetchMock
.restore()
.post(
'https://callouts.code.dev-guardianapis.com/formstack-campaign/submit',
{
status: 201,
body: null,
},
);
global.fetch = mockFetch(201) as unknown as typeof fetch;
return (
<Callout
name={mockCampaign.name}
Expand Down Expand Up @@ -61,15 +74,7 @@ const closedCallout = (): ReactElement => (
/>
);
const nonCollapsableCallout = (): ReactElement => {
fetchMock
.restore()
.post(
'https://callouts.code.dev-guardianapis.com/formstack-campaign/submit',
{
status: 201,
body: null,
},
);
global.fetch = mockFetch(201) as unknown as typeof fetch;
return (
<Callout
isNonCollapsible={true}
Expand All @@ -86,15 +91,7 @@ const nonCollapsableCallout = (): ReactElement => {
);
};
const minimalCallout = (): ReactElement => {
fetchMock
.restore()
.post(
'https://callouts.code.dev-guardianapis.com/formstack-campaign/submit',
{
status: 201,
body: null,
},
);
global.fetch = mockFetch(201) as unknown as typeof fetch;
return (
<>
A callouts prompt, title and description are optional
Expand All @@ -114,15 +111,7 @@ const minimalCallout = (): ReactElement => {
};

const calloutWithFormFailure = (): ReactElement => {
fetchMock
.restore()
.post(
'https://callouts.code.dev-guardianapis.com/formstack-campaign/submit',
{
status: 400,
body: null,
},
);
global.fetch = mockFetch(400) as unknown as typeof fetch;
return (
<Callout
isNonCollapsible={true}
Expand Down
5 changes: 0 additions & 5 deletions apps-rendering/src/components/Layout/Layout.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
newsletterSignUp,
obituary,
photoEssay,
printShop,
quiz,
recipe,
review,
Expand Down Expand Up @@ -143,10 +142,6 @@ export const MatchReportStandardNews = standardLayoutStory(matchReport);
export const MatchReportStandardSpecialReportAlt =
standardLayoutStoryWithSpecialReportAlt(matchReport);

export const PrintShopStandardNews = standardLayoutStory(printShop);
export const PrintShopStandardSpecialReportAlt =
standardLayoutStoryWithSpecialReportAlt(printShop);

export const PhotoEssayStandardNews = standardLayoutStory(photoEssay);
export const PhotoEssayStandardSpecialReportAlt =
standardLayoutStoryWithSpecialReportAlt(photoEssay);
Expand Down
2 changes: 0 additions & 2 deletions apps-rendering/src/components/Layout/StandardLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import type {
MatchReport,
Obituary,
PhotoEssay,
PrintShop,
Profile,
Quiz,
Recipe,
Expand Down Expand Up @@ -94,7 +93,6 @@ interface Props {
| Correction
| Interview
| Recipe
| PrintShop
| PhotoEssay
| Timeline
| Profile;
Expand Down
7 changes: 0 additions & 7 deletions apps-rendering/src/fixtures/item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import type {
NewsletterSignup,
Obituary,
PhotoEssay,
PrintShop,
Quiz,
Recipe,
Review,
Expand Down Expand Up @@ -519,11 +518,6 @@ const correction: Item = {
...fields,
};

const printShop: PrintShop = {
design: ArticleDesign.PrintShop,
...fields,
};

const photoEssay: PhotoEssay = {
design: ArticleDesign.PhotoEssay,
...fields,
Expand Down Expand Up @@ -595,7 +589,6 @@ export {
matchReport,
cartoon,
correction,
printShop,
photoEssay,
recipe,
quiz,
Expand Down
12 changes: 0 additions & 12 deletions apps-rendering/src/item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,6 @@ interface PhotoEssay extends Fields {
body: BodyElement[];
}

interface PrintShop extends Fields {
design: ArticleDesign.PrintShop;
body: BodyElement[];
}

interface Analysis extends Fields {
design: ArticleDesign.Analysis;
body: BodyElement[];
Expand Down Expand Up @@ -212,11 +207,6 @@ interface PhotoEssay extends Fields {
body: BodyElement[];
}

interface PrintShop extends Fields {
design: ArticleDesign.PrintShop;
body: BodyElement[];
}

interface FullPageInteractive extends Fields {
design: ArticleDesign.FullPageInteractive;
body: BodyElement[];
Expand Down Expand Up @@ -260,7 +250,6 @@ type Item =
| Quiz
| NewsletterSignup
| PhotoEssay
| PrintShop
| FullPageInteractive
| Timeline
| Profile
Expand Down Expand Up @@ -680,7 +669,6 @@ export {
Quiz,
PhotoEssay,
Feature,
PrintShop,
Explainer,
Gallery,
Audio,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
ArticleFormat,
ArticleSpecial,
Pillar,
} from '../../src/lib/format';
} from '../../src/lib/articleFormat';
import {
palette as sourcePalette,
space,
Expand Down
2 changes: 1 addition & 1 deletion dotcom-rendering/.storybook/decorators/themeDecorator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
type StoryContext,
type StrictArgs,
} from '@storybook/react';
import { ArticleFormat } from '../../src/lib/format';
import { ArticleFormat } from '../../src/lib/articleFormat';
import type { CSSProperties } from 'react';

const darkStoryCss = css`
Expand Down
2 changes: 1 addition & 1 deletion dotcom-rendering/.storybook/mocks/paletteDeclarations.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ArticleFormat } from '../../src/lib/format';
import { ArticleFormat } from '../../src/lib/articleFormat';
import { paletteDeclarations } from '../../src/palette';

/**
Expand Down
6 changes: 3 additions & 3 deletions dotcom-rendering/.storybook/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { resets } from '@guardian/source/foundations';

import { Lazy } from '../src/components/Lazy';
import { Picture } from '../src/components/Picture';
import { mockRESTCalls } from '../src/lib/mockRESTCalls';
import { mockFetch } from '../src/lib/mockRESTCalls';
import { setABTests } from '../src/lib/useAB';
import { ConfigContextDecorator } from './decorators/configContextDecorator';
import { Preview } from '@storybook/react';
Expand All @@ -22,11 +22,11 @@ import {
Lazy.disabled = isChromatic();
Picture.disableLazyLoading = isChromatic();

global.fetch = mockFetch;

// Fix the date to prevent false negatives
MockDate.set('Sat Jan 1 2022 12:00:00 GMT+0000 (Greenwich Mean Time)');

mockRESTCalls();

setABTests({
api: new AB({
mvtMaxValue: 1_000_000,
Expand Down
2 changes: 1 addition & 1 deletion dotcom-rendering/.storybook/toolbar/globalColourScheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
ArticleDesign,
Pillar,
type ArticleFormat,
} from '../../src/lib/format';
} from '../../src/lib/articleFormat';

const defaultFormat: ArticleFormat = {
display: ArticleDisplay.Standard,
Expand Down
Loading

0 comments on commit c2f5bfd

Please sign in to comment.