;
const discussionMock = parse(discussionApiResponseSchema, discussion);
if (discussionMock.status !== 'ok') throw new Error('Invalid mock');
@@ -71,387 +90,164 @@ const defaultCommentForm = {
previewBody: '',
} satisfies CommentFormProps;
-export const LoggedOutHiddenPicks = () => (
-
- {}}
- apiKey=""
- idApiUrl="https://idapi.theguardian.com"
- page={3}
- filters={filters}
- topLevelCommentCount={
- discussionMock.discussion.topLevelCommentCount
- }
- loading={false}
- comments={discussionMock.discussion.comments}
- topForm={defaultCommentForm}
- replyForm={defaultCommentForm}
- bottomForm={defaultCommentForm}
- reportAbuse={() => Promise.resolve(ok(true))}
- />
-
-);
-LoggedOutHiddenPicks.storyName = 'when logged out, unexpanded and with picks';
-LoggedOutHiddenPicks.decorators = [
- splitTheme([
- {
- ...format,
- theme: Pillar.Culture,
- },
- ]),
-];
-
-export const InitialPage = () => (
-
- {}}
- apiKey=""
- idApiUrl="https://idapi.theguardian.com"
- page={1}
- filters={filters}
- topLevelCommentCount={
- discussionMock.discussion.topLevelCommentCount
- }
- loading={false}
- comments={discussionMock.discussion.comments}
- topForm={defaultCommentForm}
- replyForm={defaultCommentForm}
- bottomForm={defaultCommentForm}
- reportAbuse={() => Promise.resolve(ok(true))}
- />
-
-);
-InitialPage.storyName = 'with initial page set to 1';
-InitialPage.decorators = [
- splitTheme([
- {
- ...format,
- theme: Pillar.Lifestyle,
- },
- ]),
-];
-
-export const LoggedInHiddenNoPicks = () => {
- return (
-
- {}}
- apiKey=""
- idApiUrl="https://idapi.theguardian.com"
- page={3}
- filters={filters}
- topLevelCommentCount={
- discussionMock.discussion.topLevelCommentCount
- }
- loading={false}
- comments={discussionMock.discussion.comments}
- topForm={defaultCommentForm}
- replyForm={{ ...defaultCommentForm }}
- bottomForm={defaultCommentForm}
- reportAbuse={() => Promise.resolve(ok(true))}
- />
-
- );
-};
-LoggedInHiddenNoPicks.storyName =
- 'when logged in, with no picks and not expanded';
-LoggedInHiddenNoPicks.decorators = [splitTheme([format])];
-
-export const LoggedIn = () => {
- return (
-
- {}}
- apiKey=""
- idApiUrl="https://idapi.theguardian.com"
- page={3}
- filters={filters}
- topLevelCommentCount={
- discussionMock.discussion.topLevelCommentCount
- }
- loading={false}
- comments={discussionMock.discussion.comments}
- topForm={defaultCommentForm}
- replyForm={defaultCommentForm}
- bottomForm={defaultCommentForm}
- reportAbuse={() => Promise.resolve(ok(true))}
- />
-
- );
-};
-LoggedIn.storyName = 'when logged in and expanded';
-LoggedIn.decorators = [lightDecorator([format])];
-
-export const LoggedInShortDiscussion = () => {
- return (
-
- {}}
- apiKey=""
- idApiUrl="https://idapi.theguardian.com"
- page={3}
- filters={filters}
- topLevelCommentCount={
- discussionWithTwoComments.discussion.topLevelCommentCount
- }
- loading={false}
- comments={discussionWithTwoComments.discussion.comments}
- topForm={defaultCommentForm}
- replyForm={defaultCommentForm}
- bottomForm={defaultCommentForm}
- reportAbuse={() => Promise.resolve(ok(true))}
- />
-
- );
-};
-LoggedInShortDiscussion.decorators = [splitTheme([format])];
-
-export const LoggedOutHiddenNoPicks = () => (
-
- {}}
- apiKey=""
- idApiUrl="https://idapi.theguardian.com"
- page={3}
- filters={filters}
- topLevelCommentCount={
- discussionMock.discussion.topLevelCommentCount
- }
- loading={false}
- comments={discussionMock.discussion.comments}
- topForm={defaultCommentForm}
- replyForm={defaultCommentForm}
- bottomForm={defaultCommentForm}
- reportAbuse={() => Promise.resolve(ok(true))}
- />
-
-);
-
-LoggedOutHiddenNoPicks.storyName =
- 'when logged out, with no picks and not expanded';
-LoggedOutHiddenNoPicks.decorators = [
- splitTheme([
- {
- ...format,
- theme: Pillar.Sport,
- },
- ]),
-];
-
-export const Closed = () => (
-
- {}}
- apiKey=""
- idApiUrl="https://idapi.theguardian.com"
- page={3}
- filters={filters}
- topLevelCommentCount={
- discussionMock.discussion.topLevelCommentCount
- }
- loading={false}
- comments={discussionMock.discussion.comments}
- topForm={defaultCommentForm}
- replyForm={defaultCommentForm}
- bottomForm={defaultCommentForm}
- reportAbuse={() => Promise.resolve(ok(true))}
- />
-
-);
-Closed.storyName = 'Logged in but closed for comments';
-Closed.decorators = [
- splitTheme([
- {
- ...format,
- theme: Pillar.Lifestyle,
- },
- ]),
-];
-
-export const NoComments = () => (
-
- {}}
- apiKey=""
- idApiUrl="https://idapi.theguardian.com"
- page={3}
- filters={filters}
- topLevelCommentCount={0}
- loading={false}
- comments={[]}
- topForm={defaultCommentForm}
- replyForm={defaultCommentForm}
- bottomForm={defaultCommentForm}
- reportAbuse={() => Promise.resolve(ok(true))}
- />
-
-);
-NoComments.storyName = 'when no comments have been made';
-NoComments.decorators = [
- splitTheme([
- {
- ...format,
- theme: Pillar.Culture,
+export const LoggedOutHiddenPicks = {
+ name: 'When logged out, unexpanded and with picks',
+ args: {
+ shortUrl: discussionMock.discussion.key,
+ baseUrl: 'https://discussion.theguardian.com/discussion-api',
+ isClosedForComments: false,
+ isClosedForRecommendations: false,
+ additionalHeaders: {
+ 'D2-X-UID': 'testD2Header',
+ 'GU-Client': 'testClientHeader',
},
- ]),
-];
-
-export const LegacyDiscussion = () => (
-
- {}}
- apiKey=""
- idApiUrl="https://idapi.theguardian.com"
- page={2}
- filters={filters}
- topLevelCommentCount={
- legacyDiscussionWithoutThreading.discussion.commentCount
- }
- loading={false}
- comments={legacyDiscussionWithoutThreading.discussion.comments}
- topForm={defaultCommentForm}
- replyForm={defaultCommentForm}
- bottomForm={defaultCommentForm}
- reportAbuse={() => Promise.resolve(ok(true))}
- />
-
-);
-LegacyDiscussion.storyName = "a legacy discussion that doesn't allow threading";
-LegacyDiscussion.decorators = [
- splitTheme([
- {
- ...format,
- theme: Pillar.Culture,
- },
- ]),
-];
+ expanded: false,
+ onPermalinkClick: () => {},
+ apiKey: '',
+ idApiUrl: 'https://idapi.theguardian.com',
+ page: 3,
+ filters,
+ topLevelCommentCount: discussionMock.discussion.topLevelCommentCount,
+ loading: false,
+ comments: discussionMock.discussion.comments,
+ topForm: defaultCommentForm,
+ replyForm: defaultCommentForm,
+ bottomForm: defaultCommentForm,
+ reportAbuse: () => Promise.resolve(ok(true)),
+ },
+ decorators: [
+ splitTheme([
+ {
+ ...format,
+ theme: Pillar.Culture,
+ },
+ ]),
+ ],
+} satisfies Story;
+
+export const InitialPage = {
+ ...LoggedOutHiddenPicks,
+ name: 'With initial page set to 1',
+ args: {
+ ...LoggedOutHiddenPicks.args,
+ expanded: true,
+ page: 1,
+ },
+ decorators: [
+ splitTheme([
+ {
+ ...format,
+ theme: Pillar.Lifestyle,
+ },
+ ]),
+ ],
+} satisfies Story;
+
+export const LoggedInHiddenNoPicks = {
+ ...LoggedOutHiddenPicks,
+ name: 'When logged in, with no picks and not expanded',
+ args: {
+ ...LoggedOutHiddenPicks.args,
+ shortUrl: 'p/abc123',
+ user: aUser,
+ },
+ decorators: [splitTheme([format])],
+} satisfies Story;
+
+export const LoggedIn = {
+ ...LoggedInHiddenNoPicks,
+ name: 'When logged in and expanded',
+ args: {
+ ...LoggedOutHiddenPicks.args,
+ expanded: true,
+ },
+ decorators: [splitTheme([format])],
+} satisfies Story;
+
+export const LoggedInShortDiscussion = {
+ ...LoggedInHiddenNoPicks,
+ args: {
+ ...LoggedInHiddenNoPicks.args,
+ shortUrl: discussionWithTwoComments.discussion.key,
+ expanded: true,
+ topLevelCommentCount:
+ discussionWithTwoComments.discussion.topLevelCommentCount,
+ comments: discussionWithTwoComments.discussion.comments,
+ },
+ decorators: [splitTheme([format])],
+} satisfies Story;
+
+export const LoggedOutHiddenNoPicks = {
+ ...LoggedOutHiddenPicks,
+ args: {
+ ...LoggedOutHiddenPicks.args,
+ shortUrl: 'p/abc123',
+ },
+ name: 'When logged out, with no picks and not expanded',
+ decorators: [
+ splitTheme([
+ {
+ ...format,
+ theme: Pillar.Sport,
+ },
+ ]),
+ ],
+} satisfies Story;
+
+export const Closed = {
+ ...LoggedOutHiddenPicks,
+ args: {
+ ...LoggedOutHiddenPicks.args,
+ isClosedForComments: true,
+ user: aUser,
+ expanded: true,
+ },
+ name: 'Logged in but closed for comments',
+ decorators: [
+ splitTheme([
+ {
+ ...format,
+ theme: Pillar.Lifestyle,
+ },
+ ]),
+ ],
+} satisfies Story;
+
+export const NoComments = {
+ ...LoggedOutHiddenPicks,
+ args: {
+ ...LoggedOutHiddenPicks.args,
+ shortUrl: 'p/39f5x',
+ topLevelCommentCount: 0,
+ comments: [],
+ },
+ decorators: [
+ splitTheme([
+ {
+ ...format,
+ theme: Pillar.Culture,
+ },
+ ]),
+ ],
+} satisfies Story;
+
+export const LegacyDiscussion = {
+ ...LoggedOutHiddenPicks,
+ args: {
+ ...LoggedOutHiddenPicks.args,
+ shortUrl: legacyDiscussionWithoutThreading.discussion.key,
+ page: 2,
+ topLevelCommentCount:
+ legacyDiscussionWithoutThreading.discussion.commentCount,
+ comments: legacyDiscussionWithoutThreading.discussion.comments,
+ },
+ name: "A legacy discussion that doesn't allow threading",
+ decorators: [
+ splitTheme([
+ {
+ ...format,
+ theme: Pillar.Culture,
+ },
+ ]),
+ ],
+} satisfies Story;