From 396348ce0bfebfd7a6515d70d829fb0a2353c02b Mon Sep 17 00:00:00 2001 From: nick-funk Date: Mon, 14 Aug 2023 13:37:19 -0600 Subject: [PATCH 1/2] simplify `renders username and body` fixture for speed Make a simple stream with one comment so that the test renderer can initiate faster and avoid stalling out on GitHub CI. Based on my experiments, this makes the test pass and also speeds it up by a factor of more than 10x. --- .../comments/components/CommentContainer.spec.tsx | 10 +++++++++- src/core/client/stream/test/fixtures.ts | 13 +++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/core/client/stream/test/comments/components/CommentContainer.spec.tsx b/src/core/client/stream/test/comments/components/CommentContainer.spec.tsx index 39a41f3b5b..8311cfc920 100644 --- a/src/core/client/stream/test/comments/components/CommentContainer.spec.tsx +++ b/src/core/client/stream/test/comments/components/CommentContainer.spec.tsx @@ -9,6 +9,7 @@ import { import { commenters, settings, + singleCommentStory, stories, storyWithDeletedComments, storyWithReplies, @@ -51,7 +52,14 @@ async function createTestRenderer( afterEach(jest.clearAllMocks); it("renders username and body", async () => { - const { container } = await createTestRenderer(); + const { container } = await createTestRenderer({ + resolvers: { + Query: { + story: () => singleCommentStory, + stream: () => singleCommentStory, + }, + }, + }); const firstComment = stories[0].comments.edges[0].node; const commentElement = await within(container).findByTestId( diff --git a/src/core/client/stream/test/fixtures.ts b/src/core/client/stream/test/fixtures.ts index a961bc8db4..187da7111c 100644 --- a/src/core/client/stream/test/fixtures.ts +++ b/src/core/client/stream/test/fixtures.ts @@ -797,6 +797,19 @@ export const commentsFromStaff = denormalizeComments( ) ); +export const singleCommentStory = denormalizeStory( + createFixture( + { + id: "story-1", + url: "http://localhost/stories/story-1", + comments: { + edges: [{ node: comments[0], cursor: comments[0].createdAt }], + }, + }, + baseStory + ) +); + export const stories = denormalizeStories( createFixtures( [ From 53ece0a6a41a3d1c594fa7ff2b014f33ca060e8f Mon Sep 17 00:00:00 2001 From: nick-funk Date: Mon, 14 Aug 2023 13:38:16 -0600 Subject: [PATCH 2/2] reference singleCommentStory for rest of test --- .../stream/test/comments/components/CommentContainer.spec.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/client/stream/test/comments/components/CommentContainer.spec.tsx b/src/core/client/stream/test/comments/components/CommentContainer.spec.tsx index 8311cfc920..020f091479 100644 --- a/src/core/client/stream/test/comments/components/CommentContainer.spec.tsx +++ b/src/core/client/stream/test/comments/components/CommentContainer.spec.tsx @@ -61,7 +61,7 @@ it("renders username and body", async () => { }, }); - const firstComment = stories[0].comments.edges[0].node; + const firstComment = singleCommentStory.comments.edges[0].node; const commentElement = await within(container).findByTestId( `comment-${firstComment.id}` );