mentionsAuthorReference: remove legacy GraphQL dep (#963)
Summary: This test has data in the old format, and uses the `RelationalView` method that automatically translates it. As we prepare to delete that code, we upgrade the underlying format of this test data. The end code is nicer to read, too (e.g., we don’t need the `connection` helper function). Recommend reviewing with `git show -b`. Test Plan: Running `yarn test` suffices. wchargin-branch: mentionsAuthorReference-remove-legacy-graphql
This commit is contained in:
parent
b77db72c1d
commit
2e0b17cef7
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
import * as RV from "../relationalView";
|
import * as RV from "../relationalView";
|
||||||
import * as N from "../nodes";
|
import * as N from "../nodes";
|
||||||
import type {ConnectionJSON} from "../graphql";
|
import type {Repository} from "../graphqlTypes";
|
||||||
import deepEqual from "lodash.isequal";
|
import deepEqual from "lodash.isequal";
|
||||||
|
|
||||||
import {findMentionsAuthorReferences} from "./mentionsAuthorReference";
|
import {findMentionsAuthorReferences} from "./mentionsAuthorReference";
|
||||||
|
@ -10,15 +10,6 @@ import {findMentionsAuthorReferences} from "./mentionsAuthorReference";
|
||||||
describe("plugins/github/heuristics/mentionsAuthorReference", () => {
|
describe("plugins/github/heuristics/mentionsAuthorReference", () => {
|
||||||
function exampleRelationalView(): RV.RelationalView {
|
function exampleRelationalView(): RV.RelationalView {
|
||||||
const view = new RV.RelationalView();
|
const view = new RV.RelationalView();
|
||||||
function connection<T>(nodes: $ReadOnlyArray<T>): ConnectionJSON<T> {
|
|
||||||
return {
|
|
||||||
nodes,
|
|
||||||
pageInfo: {
|
|
||||||
endCursor: "cursor:ignored",
|
|
||||||
hasNextPage: false,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const authors = {
|
const authors = {
|
||||||
steven: () => ({
|
steven: () => ({
|
||||||
|
@ -61,69 +52,77 @@ describe("plugins/github/heuristics/mentionsAuthorReference", () => {
|
||||||
return `${issueUrl(issueNumber)}#issuecomment-${commentNumber}`;
|
return `${issueUrl(issueNumber)}#issuecomment-${commentNumber}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = {
|
const repository: Repository = {
|
||||||
repository: {
|
__typename: "Repository",
|
||||||
id: "repo:my-repo",
|
id: "repo:my-repo",
|
||||||
issues: connection([
|
issues: [
|
||||||
{
|
{
|
||||||
|
__typename: "Issue",
|
||||||
id: "issue:1",
|
id: "issue:1",
|
||||||
url: issueUrl(1),
|
url: issueUrl(1),
|
||||||
number: 1,
|
number: 1,
|
||||||
title: "calling into the void",
|
title: "calling into the void",
|
||||||
body: "hi @amethyst",
|
body: "hi @amethyst",
|
||||||
author: authors.steven(),
|
author: authors.steven(),
|
||||||
comments: connection([]),
|
comments: [],
|
||||||
reactions: connection([]),
|
reactions: [],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
__typename: "Issue",
|
||||||
id: "issue:2",
|
id: "issue:2",
|
||||||
number: 2,
|
number: 2,
|
||||||
url: issueUrl(2),
|
url: issueUrl(2),
|
||||||
title: "an issue with many types of references",
|
title: "an issue with many types of references",
|
||||||
body: "it is me, @steven\n\nPaired with: @pearl",
|
body: "it is me, @steven\n\nPaired with: @pearl",
|
||||||
author: authors.steven(),
|
author: authors.steven(),
|
||||||
reactions: connection([]),
|
reactions: [],
|
||||||
comments: connection([
|
comments: [
|
||||||
{
|
{
|
||||||
|
__typename: "IssueComment",
|
||||||
id: "comment:2_1",
|
id: "comment:2_1",
|
||||||
url: issueCommentUrl(2, 1),
|
url: issueCommentUrl(2, 1),
|
||||||
body: "parry parry thrust @pearl\nparry parry thrust @steven",
|
body: "parry parry thrust @pearl\nparry parry thrust @steven",
|
||||||
author: authors.holo(),
|
author: authors.holo(),
|
||||||
reactions: connection([]),
|
reactions: [],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
__typename: "IssueComment",
|
||||||
id: "comment:2_2",
|
id: "comment:2_2",
|
||||||
url: issueCommentUrl(2, 2),
|
url: issueCommentUrl(2, 2),
|
||||||
body: "@holo-pearl: stop!",
|
body: "@holo-pearl: stop!",
|
||||||
author: authors.steven(),
|
author: authors.steven(),
|
||||||
reactions: connection([]),
|
reactions: [],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
__typename: "IssueComment",
|
||||||
id: "comment:2_3",
|
id: "comment:2_3",
|
||||||
url: issueCommentUrl(2, 3),
|
url: issueCommentUrl(2, 3),
|
||||||
body: "@amethyst @garnet why aren't you helping",
|
body: "@amethyst @garnet why aren't you helping",
|
||||||
author: authors.pearl(),
|
author: authors.pearl(),
|
||||||
reactions: connection([]),
|
reactions: [],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
__typename: "IssueComment",
|
||||||
id: "comment:2_4",
|
id: "comment:2_4",
|
||||||
url: issueCommentUrl(2, 4),
|
url: issueCommentUrl(2, 4),
|
||||||
body: "@amethyst! come quickly, @amethyst!",
|
body: "@amethyst! come quickly, @amethyst!",
|
||||||
author: authors.garnet(),
|
author: authors.garnet(),
|
||||||
reactions: connection([]),
|
reactions: [],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
__typename: "IssueComment",
|
||||||
id: "comment:2_5",
|
id: "comment:2_5",
|
||||||
url: issueCommentUrl(2, 5),
|
url: issueCommentUrl(2, 5),
|
||||||
body: "i am busy fighting @boomerang-blade guy",
|
body: "i am busy fighting @boomerang-blade guy",
|
||||||
author: authors.amethyst(),
|
author: authors.amethyst(),
|
||||||
reactions: connection([]),
|
reactions: [],
|
||||||
},
|
},
|
||||||
]),
|
],
|
||||||
},
|
},
|
||||||
]),
|
],
|
||||||
pulls: connection([
|
pullRequests: [
|
||||||
{
|
{
|
||||||
|
__typename: "PullRequest",
|
||||||
id: "pull:3",
|
id: "pull:3",
|
||||||
url: "https://github.com/my-owner/my-repo/pulls/3",
|
url: "https://github.com/my-owner/my-repo/pulls/3",
|
||||||
number: 3,
|
number: 3,
|
||||||
|
@ -132,12 +131,12 @@ describe("plugins/github/heuristics/mentionsAuthorReference", () => {
|
||||||
mergeCommit: null,
|
mergeCommit: null,
|
||||||
additions: 0,
|
additions: 0,
|
||||||
deletions: 0,
|
deletions: 0,
|
||||||
reactions: connection([]),
|
reactions: [],
|
||||||
comments: connection([]),
|
comments: [],
|
||||||
author: authors.steven(),
|
author: authors.steven(),
|
||||||
reviews: connection([]),
|
reviews: [],
|
||||||
},
|
},
|
||||||
]),
|
],
|
||||||
url: "https://github.com/my-owner/my-repo",
|
url: "https://github.com/my-owner/my-repo",
|
||||||
name: "my-repo",
|
name: "my-repo",
|
||||||
owner: {
|
owner: {
|
||||||
|
@ -147,9 +146,8 @@ describe("plugins/github/heuristics/mentionsAuthorReference", () => {
|
||||||
url: "https://github.com/my-owner",
|
url: "https://github.com/my-owner",
|
||||||
},
|
},
|
||||||
defaultBranchRef: null,
|
defaultBranchRef: null,
|
||||||
},
|
|
||||||
};
|
};
|
||||||
view.addData(data);
|
view.addRepository(repository);
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue