Skip to content

Commit

Permalink
simplify renders username and body fixture for speed
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nick-funk committed Aug 14, 2023
1 parent 2e7424f commit 396348c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
import {
commenters,
settings,
singleCommentStory,
stories,
storyWithDeletedComments,
storyWithReplies,
Expand Down Expand Up @@ -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(
Expand Down
13 changes: 13 additions & 0 deletions src/core/client/stream/test/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,19 @@ export const commentsFromStaff = denormalizeComments(
)
);

export const singleCommentStory = denormalizeStory(
createFixture<GQLStory>(
{
id: "story-1",
url: "http://localhost/stories/story-1",
comments: {
edges: [{ node: comments[0], cursor: comments[0].createdAt }],
},
},
baseStory
)
);

export const stories = denormalizeStories(
createFixtures<GQLStory>(
[
Expand Down

0 comments on commit 396348c

Please sign in to comment.