test: use baseComment and baseAsset in fixtures

This commit is contained in:
Chi Vinh Le
2018-09-27 17:48:10 +02:00
parent 3ffdb09afe
commit ccb6f347ae
11 changed files with 191 additions and 275 deletions
@@ -315,10 +315,10 @@ exports[`cancel edit: edit canceled 1`] = `
>
<time
className="Timestamp-root RelativeTime-root"
dateTime="2018-07-06T18:20:00.000Z"
title="2018-07-06T18:20:00.000Z"
dateTime="2018-07-06T18:24:00.000Z"
title="2018-07-06T18:24:00.000Z"
>
2018-07-06T18:20:00.000Z
2018-07-06T18:24:00.000Z
</time>
</div>
</div>
@@ -754,10 +754,10 @@ exports[`edit a comment: edit form 1`] = `
>
<time
className="Timestamp-root RelativeTime-root"
dateTime="2018-07-06T18:20:00.000Z"
title="2018-07-06T18:20:00.000Z"
dateTime="2018-07-06T18:24:00.000Z"
title="2018-07-06T18:24:00.000Z"
>
2018-07-06T18:20:00.000Z
2018-07-06T18:24:00.000Z
</time>
</div>
</div>
@@ -1193,10 +1193,10 @@ exports[`edit a comment: optimistic response 1`] = `
>
<time
className="Timestamp-root RelativeTime-root"
dateTime="2018-07-06T18:20:00.000Z"
title="2018-07-06T18:20:00.000Z"
dateTime="2018-07-06T18:24:00.000Z"
title="2018-07-06T18:24:00.000Z"
>
2018-07-06T18:20:00.000Z
2018-07-06T18:24:00.000Z
</time>
</div>
</div>
@@ -1568,10 +1568,10 @@ exports[`edit a comment: render stream 1`] = `
>
<time
className="Timestamp-root RelativeTime-root"
dateTime="2018-07-06T18:20:00.000Z"
title="2018-07-06T18:20:00.000Z"
dateTime="2018-07-06T18:24:00.000Z"
title="2018-07-06T18:24:00.000Z"
>
2018-07-06T18:20:00.000Z
2018-07-06T18:24:00.000Z
</time>
</div>
</div>
@@ -1952,10 +1952,10 @@ exports[`edit a comment: server response 1`] = `
>
<time
className="Timestamp-root RelativeTime-root"
dateTime="2018-07-06T18:20:00.000Z"
title="2018-07-06T18:20:00.000Z"
dateTime="2018-07-06T18:24:00.000Z"
title="2018-07-06T18:24:00.000Z"
>
2018-07-06T18:20:00.000Z
2018-07-06T18:24:00.000Z
</time>
</div>
</div>
@@ -2327,10 +2327,10 @@ exports[`shows expiry message: edit form closed 1`] = `
>
<time
className="Timestamp-root RelativeTime-root"
dateTime="2018-07-06T18:20:00.000Z"
title="2018-07-06T18:20:00.000Z"
dateTime="2018-07-06T18:24:00.000Z"
title="2018-07-06T18:24:00.000Z"
>
2018-07-06T18:20:00.000Z
2018-07-06T18:24:00.000Z
</time>
</div>
</div>
@@ -2743,10 +2743,10 @@ exports[`shows expiry message: edit time expired 1`] = `
>
<time
className="Timestamp-root RelativeTime-root"
dateTime="2018-07-06T18:20:00.000Z"
title="2018-07-06T18:20:00.000Z"
dateTime="2018-07-06T18:24:00.000Z"
title="2018-07-06T18:24:00.000Z"
>
2018-07-06T18:20:00.000Z
2018-07-06T18:24:00.000Z
</time>
</div>
</div>
@@ -245,10 +245,10 @@ exports[`loads more comments 1`] = `
>
<time
className="Timestamp-root RelativeTime-root"
dateTime="2018-07-06T18:20:00.000Z"
title="2018-07-06T18:20:00.000Z"
dateTime="2018-07-06T18:24:00.000Z"
title="2018-07-06T18:24:00.000Z"
>
2018-07-06T18:20:00.000Z
2018-07-06T18:24:00.000Z
</time>
</div>
</div>
@@ -315,10 +315,10 @@ exports[`loads more comments 1`] = `
>
<time
className="Timestamp-root RelativeTime-root"
dateTime="2018-07-06T18:14:00.000Z"
title="2018-07-06T18:14:00.000Z"
dateTime="2018-07-06T18:24:00.000Z"
title="2018-07-06T18:24:00.000Z"
>
2018-07-06T18:14:00.000Z
2018-07-06T18:24:00.000Z
</time>
</div>
</div>
@@ -605,10 +605,10 @@ exports[`renders comment stream 1`] = `
>
<time
className="Timestamp-root RelativeTime-root"
dateTime="2018-07-06T18:20:00.000Z"
title="2018-07-06T18:20:00.000Z"
dateTime="2018-07-06T18:24:00.000Z"
title="2018-07-06T18:24:00.000Z"
>
2018-07-06T18:20:00.000Z
2018-07-06T18:24:00.000Z
</time>
</div>
</div>
@@ -394,10 +394,10 @@ exports[`post a comment: optimistic response 1`] = `
>
<time
className="Timestamp-root RelativeTime-root"
dateTime="2018-07-06T18:20:00.000Z"
title="2018-07-06T18:20:00.000Z"
dateTime="2018-07-06T18:24:00.000Z"
title="2018-07-06T18:24:00.000Z"
>
2018-07-06T18:20:00.000Z
2018-07-06T18:24:00.000Z
</time>
</div>
</div>
@@ -838,10 +838,10 @@ exports[`post a comment: server response 1`] = `
>
<time
className="Timestamp-root RelativeTime-root"
dateTime="2018-07-06T18:20:00.000Z"
title="2018-07-06T18:20:00.000Z"
dateTime="2018-07-06T18:24:00.000Z"
title="2018-07-06T18:24:00.000Z"
>
2018-07-06T18:20:00.000Z
2018-07-06T18:24:00.000Z
</time>
</div>
</div>
@@ -1197,10 +1197,10 @@ exports[`renders comment stream 1`] = `
>
<time
className="Timestamp-root RelativeTime-root"
dateTime="2018-07-06T18:20:00.000Z"
title="2018-07-06T18:20:00.000Z"
dateTime="2018-07-06T18:24:00.000Z"
title="2018-07-06T18:24:00.000Z"
>
2018-07-06T18:20:00.000Z
2018-07-06T18:24:00.000Z
</time>
</div>
</div>
@@ -426,10 +426,10 @@ exports[`post a reply: open reply form 1`] = `
>
<time
className="Timestamp-root RelativeTime-root"
dateTime="2018-07-06T18:20:00.000Z"
title="2018-07-06T18:20:00.000Z"
dateTime="2018-07-06T18:24:00.000Z"
title="2018-07-06T18:24:00.000Z"
>
2018-07-06T18:20:00.000Z
2018-07-06T18:24:00.000Z
</time>
</div>
</div>
@@ -1013,10 +1013,10 @@ exports[`post a reply: optimistic response 1`] = `
>
<time
className="Timestamp-root RelativeTime-root"
dateTime="2018-07-06T18:20:00.000Z"
title="2018-07-06T18:20:00.000Z"
dateTime="2018-07-06T18:24:00.000Z"
title="2018-07-06T18:24:00.000Z"
>
2018-07-06T18:20:00.000Z
2018-07-06T18:24:00.000Z
</time>
</div>
</div>
@@ -1463,10 +1463,10 @@ exports[`post a reply: server response 1`] = `
>
<time
className="Timestamp-root RelativeTime-root"
dateTime="2018-07-06T18:20:00.000Z"
title="2018-07-06T18:20:00.000Z"
dateTime="2018-07-06T18:24:00.000Z"
title="2018-07-06T18:24:00.000Z"
>
2018-07-06T18:20:00.000Z
2018-07-06T18:24:00.000Z
</time>
</div>
</div>
@@ -1822,10 +1822,10 @@ exports[`renders comment stream 1`] = `
>
<time
className="Timestamp-root RelativeTime-root"
dateTime="2018-07-06T18:20:00.000Z"
title="2018-07-06T18:20:00.000Z"
dateTime="2018-07-06T18:24:00.000Z"
title="2018-07-06T18:24:00.000Z"
>
2018-07-06T18:20:00.000Z
2018-07-06T18:24:00.000Z
</time>
</div>
</div>
@@ -393,10 +393,10 @@ exports[`renders comment stream 1`] = `
>
<time
className="Timestamp-root RelativeTime-root"
dateTime="2018-07-06T18:14:00.000Z"
title="2018-07-06T18:14:00.000Z"
dateTime="2018-07-06T18:24:00.000Z"
title="2018-07-06T18:24:00.000Z"
>
2018-07-06T18:14:00.000Z
2018-07-06T18:24:00.000Z
</time>
</div>
</div>
@@ -463,10 +463,10 @@ exports[`renders comment stream 1`] = `
>
<time
className="Timestamp-root RelativeTime-root"
dateTime="2018-07-06T18:14:00.000Z"
title="2018-07-06T18:14:00.000Z"
dateTime="2018-07-06T18:24:00.000Z"
title="2018-07-06T18:24:00.000Z"
>
2018-07-06T18:14:00.000Z
2018-07-06T18:24:00.000Z
</time>
</div>
</div>
@@ -535,10 +535,10 @@ exports[`renders comment stream 1`] = `
>
<time
className="Timestamp-root RelativeTime-root"
dateTime="2018-07-06T18:14:00.000Z"
title="2018-07-06T18:14:00.000Z"
dateTime="2018-07-06T18:24:00.000Z"
title="2018-07-06T18:24:00.000Z"
>
2018-07-06T18:14:00.000Z
2018-07-06T18:24:00.000Z
</time>
</div>
</div>
@@ -245,10 +245,10 @@ exports[`renders comment stream 1`] = `
>
<time
className="Timestamp-root RelativeTime-root"
dateTime="2018-07-06T18:20:00.000Z"
title="2018-07-06T18:20:00.000Z"
dateTime="2018-07-06T18:24:00.000Z"
title="2018-07-06T18:24:00.000Z"
>
2018-07-06T18:20:00.000Z
2018-07-06T18:24:00.000Z
</time>
</div>
</div>
@@ -249,10 +249,10 @@ exports[`renders comment stream 1`] = `
>
<time
className="Timestamp-root RelativeTime-root"
dateTime="2018-07-06T18:20:00.000Z"
title="2018-07-06T18:20:00.000Z"
dateTime="2018-07-06T18:24:00.000Z"
title="2018-07-06T18:24:00.000Z"
>
2018-07-06T18:20:00.000Z
2018-07-06T18:24:00.000Z
</time>
</div>
</div>
@@ -569,10 +569,10 @@ exports[`show all replies 1`] = `
>
<time
className="Timestamp-root RelativeTime-root"
dateTime="2018-07-06T18:20:00.000Z"
title="2018-07-06T18:20:00.000Z"
dateTime="2018-07-06T18:24:00.000Z"
title="2018-07-06T18:24:00.000Z"
>
2018-07-06T18:20:00.000Z
2018-07-06T18:24:00.000Z
</time>
</div>
</div>
@@ -639,10 +639,10 @@ exports[`show all replies 1`] = `
>
<time
className="Timestamp-root RelativeTime-root"
dateTime="2018-07-06T18:14:00.000Z"
title="2018-07-06T18:14:00.000Z"
dateTime="2018-07-06T18:24:00.000Z"
title="2018-07-06T18:24:00.000Z"
>
2018-07-06T18:14:00.000Z
2018-07-06T18:24:00.000Z
</time>
</div>
</div>
@@ -5,7 +5,7 @@ import timekeeper from "timekeeper";
import { timeout } from "talk-common/utils";
import { createSinonStub } from "talk-framework/testHelpers";
import { assets, settings, users } from "../fixtures";
import { assets, baseComment, settings, users } from "../fixtures";
import create from "./create";
let testRenderer: ReactTestRenderer;
@@ -39,20 +39,10 @@ beforeEach(() => {
edge: {
cursor: null,
node: {
...baseComment,
id: "comment-x",
author: users[0],
body: "<strong>Hello world! (from server)</strong>",
createdAt: "2018-07-06T18:24:00.000Z",
editing: {
edited: false,
editableUntil: "2018-07-06T18:24:30.000Z",
},
replies: { edges: [], pageInfo: {} },
actionCounts: {
reaction: {
total: 0,
},
},
},
},
clientMutationId: "0",
@@ -84,7 +74,7 @@ it("post a comment", async () => {
.findByProps({ inputId: "comments-postCommentForm-field" })
.props.onChange({ html: "<strong>Hello world!</strong>" });
timekeeper.freeze(new Date("2018-07-06T18:24:00.000Z"));
timekeeper.freeze(new Date(baseComment.createdAt));
testRenderer.root
.findByProps({ id: "comments-postCommentForm-form" })
@@ -5,7 +5,12 @@ import timekeeper from "timekeeper";
import { timeout } from "talk-common/utils";
import { createSinonStub } from "talk-framework/testHelpers";
import { assetWithDeepestReplies, settings, users } from "../fixtures";
import {
assetWithDeepestReplies,
baseComment,
settings,
users,
} from "../fixtures";
import create from "./create";
let testRenderer: ReactTestRenderer;
@@ -39,23 +44,10 @@ beforeEach(() => {
edge: {
cursor: null,
node: {
...baseComment,
id: "comment-x",
author: users[0],
body: "<strong>Hello world! (from server)</strong>",
createdAt: "2018-07-06T18:24:00.000Z",
replies: {
edges: [],
pageInfo: { endCursor: null, hasNextPage: false },
},
editing: {
edited: false,
editableUntil: "2018-07-06T18:24:30.000Z",
},
actionCounts: {
reaction: {
total: 0,
},
},
},
},
clientMutationId: "0",
@@ -102,7 +94,7 @@ it("post a reply", async () => {
})
.props.onChange({ html: "<strong>Hello world!</strong>" });
timekeeper.freeze(new Date("2018-07-06T18:24:00.000Z"));
timekeeper.freeze(new Date(baseComment.createdAt));
testRenderer.root
.findByProps({
id: "comments-replyCommentForm-form-comment-with-deepest-replies-5",
@@ -5,7 +5,7 @@ import timekeeper from "timekeeper";
import { timeout } from "talk-common/utils";
import { createSinonStub } from "talk-framework/testHelpers";
import { assets, settings, users } from "../fixtures";
import { assets, baseComment, settings, users } from "../fixtures";
import create from "./create";
let testRenderer: ReactTestRenderer;
@@ -39,23 +39,10 @@ beforeEach(() => {
edge: {
cursor: null,
node: {
...baseComment,
id: "comment-x",
author: users[0],
body: "<strong>Hello world! (from server)</strong>",
createdAt: "2018-07-06T18:24:00.000Z",
replies: {
edges: [],
pageInfo: { endCursor: null, hasNextPage: false },
},
editing: {
edited: false,
editableUntil: "2018-07-06T18:24:30.000Z",
},
actionCounts: {
reaction: {
total: 0,
},
},
},
},
clientMutationId: "0",
@@ -97,7 +84,7 @@ it("post a reply", async () => {
.findByProps({ inputId: "comments-replyCommentForm-rte-comment-0" })
.props.onChange({ html: "<strong>Hello world!</strong>" });
timekeeper.freeze(new Date("2018-07-06T18:24:00.000Z"));
timekeeper.freeze(new Date(baseComment.createdAt));
testRenderer.root
.findByProps({ id: "comments-replyCommentForm-form-comment-0" })
.props.onSubmit();
+105 -158
View File
@@ -21,127 +21,66 @@ export const users = [
},
];
export const baseComment = {
author: users[0],
body: "Comment Body",
createdAt: "2018-07-06T18:24:00.000Z",
replies: { edges: [], pageInfo: { endCursor: null, hasNextPage: false } },
editing: {
edited: false,
editableUntil: "2018-07-06T18:24:30.000Z",
},
actionCounts: {
reaction: {
total: 0,
},
},
};
export const comments = [
{
...baseComment,
id: "comment-0",
author: users[0],
body: "Joining Too",
createdAt: "2018-07-06T18:24:00.000Z",
replies: { edges: [], pageInfo: { endCursor: null, hasNextPage: false } },
editing: {
edited: false,
editableUntil: "2018-07-06T18:24:30.000Z",
},
actionCounts: {
reaction: {
total: 0,
},
},
},
{
...baseComment,
id: "comment-1",
author: users[1],
body: "What's up?",
createdAt: "2018-07-06T18:20:00.000Z",
replies: { edges: [], pageInfo: { endCursor: null, hasNextPage: false } },
editing: {
edited: false,
editableUntil: "2018-07-06T18:20:30.000Z",
},
actionCounts: {
reaction: {
total: 0,
},
},
},
{
...baseComment,
id: "comment-2",
author: users[2],
body: "Hey!",
createdAt: "2018-07-06T18:14:00.000Z",
replies: { edges: [], pageInfo: { endCursor: null, hasNextPage: false } },
editing: {
edited: false,
editableUntil: "2018-07-06T18:14:30.000Z",
},
actionCounts: {
reaction: {
total: 0,
},
},
},
{
...baseComment,
id: "comment-3",
author: users[2],
body: "Comment Body 3",
createdAt: "2018-07-06T18:14:00.000Z",
replies: { edges: [], pageInfo: { endCursor: null, hasNextPage: false } },
editing: {
edited: false,
editableUntil: "2018-07-06T18:14:30.000Z",
},
actionCounts: {
reaction: {
total: 0,
},
},
},
{
...baseComment,
id: "comment-4",
author: users[2],
body: "Comment Body 4",
createdAt: "2018-07-06T18:14:00.000Z",
replies: { edges: [], pageInfo: { endCursor: null, hasNextPage: false } },
editing: {
edited: false,
editableUntil: "2018-07-06T18:14:30.000Z",
},
actionCounts: {
reaction: {
total: 0,
},
},
},
{
...baseComment,
id: "comment-5",
author: users[2],
body: "Comment Body 5",
createdAt: "2018-07-06T18:14:00.000Z",
replies: { edges: [], pageInfo: { endCursor: null, hasNextPage: false } },
editing: {
edited: false,
editableUntil: "2018-07-06T18:14:30.000Z",
},
actionCounts: {
reaction: {
total: 0,
},
},
},
];
export const assets = [
{
id: "asset-1",
url: "http://localhost/assets/asset-1",
isClosed: false,
comments: {
edges: [
{ node: comments[0], cursor: comments[0].createdAt },
{ node: comments[1], cursor: comments[1].createdAt },
],
pageInfo: {
hasNextPage: false,
},
},
},
];
export const commentWithReplies = {
...baseComment,
id: "comment-with-replies",
author: users[0],
body: "I like yoghurt",
createdAt: "2018-07-06T18:24:00.000Z",
replies: {
edges: [
{ node: comments[3], cursor: comments[3].createdAt },
@@ -151,22 +90,13 @@ export const commentWithReplies = {
hasNextPage: false,
},
},
editing: {
edited: false,
editableUntil: "2018-07-06T18:24:30.000Z",
},
actionCounts: {
reaction: {
total: 0,
},
},
};
export const commentWithDeepReplies = {
...baseComment,
id: "comment-with-deep-replies",
author: users[0],
body: "I like yoghurt",
createdAt: "2018-07-06T18:24:00.000Z",
replies: {
edges: [
{ node: commentWithReplies, cursor: commentWithReplies.createdAt },
@@ -176,112 +106,69 @@ export const commentWithDeepReplies = {
hasNextPage: false,
},
},
editing: {
edited: false,
editableUntil: "2018-07-06T18:24:30.000Z",
},
actionCounts: {
reaction: {
total: 0,
},
},
};
export const assetWithReplies = {
id: "asset-with-replies",
url: "http://localhost/assets/asset-with-replies",
isClosed: false,
comments: {
edges: [
{ node: comments[0], cursor: comments[0].createdAt },
{ node: commentWithReplies, cursor: commentWithReplies.createdAt },
],
pageInfo: {
hasNextPage: false,
},
},
};
export const assetWithDeepReplies = {
id: "asset-with-deep-replies",
url: "http://localhost/assets/asset-with-replies",
isClosed: false,
comments: {
edges: [
{ node: comments[0], cursor: comments[0].createdAt },
{
node: commentWithDeepReplies,
cursor: commentWithDeepReplies.createdAt,
},
],
pageInfo: {
hasNextPage: false,
},
},
};
export const commentWithDeepestReplies = {
...commentWithReplies,
...baseComment,
id: "comment-with-deepest-replies",
body: "body 0",
replies: {
...commentWithReplies.replies,
...baseComment.replies,
edges: [
{
cursor: commentWithReplies.createdAt,
cursor: baseComment.createdAt,
node: {
...commentWithReplies,
...baseComment,
id: "comment-with-deepest-replies-1",
body: "body 1",
replies: {
...commentWithReplies.replies,
...baseComment.replies,
edges: [
{
cursor: commentWithReplies.createdAt,
cursor: baseComment.createdAt,
node: {
...commentWithReplies,
...baseComment,
id: "comment-with-deepest-replies-2",
body: "body 2",
replies: {
...commentWithReplies.replies,
...baseComment.replies,
edges: [
{
cursor: commentWithReplies.createdAt,
cursor: baseComment.createdAt,
node: {
...commentWithReplies,
...baseComment,
id: "comment-with-deepest-replies-3",
body: "body 3",
replies: {
...commentWithReplies.replies,
...baseComment.replies,
edges: [
{
cursor: commentWithReplies.createdAt,
cursor: baseComment.createdAt,
node: {
...commentWithReplies,
...baseComment,
id: "comment-with-deepest-replies-4",
body: "body 4",
replies: {
...commentWithReplies.replies,
...baseComment.replies,
edges: [
{
cursor: commentWithReplies.createdAt,
cursor: baseComment.createdAt,
node: {
...commentWithReplies,
...baseComment,
id: "comment-with-deepest-replies-5",
body: "body 5",
replies: {
...commentWithReplies.replies,
...baseComment.replies,
edges: [
{
cursor:
commentWithReplies.createdAt,
cursor: baseComment.createdAt,
node: {
...commentWithReplies,
...baseComment,
id:
"comment-with-deepest-replies-6",
body: "body 6",
replies: {
...commentWithReplies.replies,
...baseComment.replies,
edges: [],
},
},
@@ -310,10 +197,70 @@ export const commentWithDeepestReplies = {
},
};
export const baseAsset = {
isClosed: false,
comments: {
edges: [],
pageInfo: {
hasNextPage: false,
},
},
};
export const assets = [
{
...baseAsset,
id: "asset-1",
url: "http://localhost/assets/asset-1",
comments: {
edges: [
{ node: comments[0], cursor: comments[0].createdAt },
{ node: comments[1], cursor: comments[1].createdAt },
],
pageInfo: {
hasNextPage: false,
},
},
},
];
export const assetWithReplies = {
...baseAsset,
id: "asset-with-replies",
url: "http://localhost/assets/asset-with-replies",
comments: {
edges: [
{ node: comments[0], cursor: comments[0].createdAt },
{ node: commentWithReplies, cursor: commentWithReplies.createdAt },
],
pageInfo: {
hasNextPage: false,
},
},
};
export const assetWithDeepReplies = {
...baseAsset,
id: "asset-with-deep-replies",
url: "http://localhost/assets/asset-with-replies",
comments: {
edges: [
{ node: comments[0], cursor: comments[0].createdAt },
{
node: commentWithDeepReplies,
cursor: commentWithDeepReplies.createdAt,
},
],
pageInfo: {
hasNextPage: false,
},
},
};
export const assetWithDeepestReplies = {
...baseAsset,
id: "asset-with-deepest-replies",
url: "http://localhost/assets/asset-with-replies",
isClosed: false,
comments: {
edges: [
{