Update reaction types (#1068)
Resolves #1054
Added "ROCKET" and "EYES" to the list of reaction types.
Added "ROCKET" as a valid cred signal, kept "EYES" invisible.
My approach was to use `git git grep THUMBS_UP '*.js'`
and `git grep ThumbsUp '*.js'` to find all the relevant files,
as suggested in #1054
**Test Plan**
1) Inspecting Sourcecred/Mission's UI:
[#13] contains: GOT 🚀 FROM 1 user
@BrianLitwin contains: REACTED 🚀 TO 1 issue
@BrianLitwin contains: REACTED 🚀 TO #13
2) Yarn Test passes
3) `github/edges.test` includes a snapshot test to verify
that we can create an edge using ROCKET
4) @wchargin also noted that:
```sh
diff -u <(git grep -c 'THUMBS_UP' '*.js') <(git grep -c 'ROCKET' '*.js')
diff -u <(git grep -c 'ThumbsUp' '*.js') <(git grep -c 'Rocket' '*.js')
```
passes.
`graphql/mirror.test` now includes "ROCKET" and "EYES" in the example
GithubSchema, but their inclusion has no effect
on any tests.
**Screenshots**
1.
<img width="378" alt="screenshot 2019-01-22 09 02 12" src="https://user-images.githubusercontent.com/26695477/51540428-6c87b600-1e24-11e9-8334-1d9d993dce01.png">
2.
<img width="525" alt="screenshot 2019-01-22 09 02 41" src="https://user-images.githubusercontent.com/26695477/51540472-84f7d080-1e24-11e9-8847-245c0c09ddd6.png">
<br>
Shoutout to [this comment], which saved me an untold amount of head-scratching,
and also @Decentralion's help debugging in the Issue thread.
[#13]: https://github.com/sourcecred/mission/issues/13
[this comment]: e0762303d4/src/plugins/github/graphqlTypes.test.js (L13-L15)
This commit is contained in:
parent
e0762303d4
commit
61266cace7
|
@ -50,6 +50,8 @@ describe("graphql/mirror", () => {
|
||||||
"HOORAY",
|
"HOORAY",
|
||||||
"CONFUSED",
|
"CONFUSED",
|
||||||
"HEART",
|
"HEART",
|
||||||
|
"ROCKET",
|
||||||
|
"EYES",
|
||||||
]),
|
]),
|
||||||
Repository: s.object({
|
Repository: s.object({
|
||||||
id: s.id(),
|
id: s.id(),
|
||||||
|
|
|
@ -237,6 +237,49 @@ Object {
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`plugins/github/edges createEdge works for "reactsRocket" 1`] = `
|
||||||
|
Object {
|
||||||
|
"addressParts": Array [
|
||||||
|
"sourcecred",
|
||||||
|
"github",
|
||||||
|
"REACTS",
|
||||||
|
"ROCKET",
|
||||||
|
"5",
|
||||||
|
"sourcecred",
|
||||||
|
"github",
|
||||||
|
"USERLIKE",
|
||||||
|
"USER",
|
||||||
|
"decentralion",
|
||||||
|
"8",
|
||||||
|
"sourcecred",
|
||||||
|
"github",
|
||||||
|
"COMMENT",
|
||||||
|
"PULL",
|
||||||
|
"sourcecred",
|
||||||
|
"example-github",
|
||||||
|
"5",
|
||||||
|
"396430464",
|
||||||
|
],
|
||||||
|
"dstParts": Array [
|
||||||
|
"sourcecred",
|
||||||
|
"github",
|
||||||
|
"COMMENT",
|
||||||
|
"PULL",
|
||||||
|
"sourcecred",
|
||||||
|
"example-github",
|
||||||
|
"5",
|
||||||
|
"396430464",
|
||||||
|
],
|
||||||
|
"srcParts": Array [
|
||||||
|
"sourcecred",
|
||||||
|
"github",
|
||||||
|
"USERLIKE",
|
||||||
|
"USER",
|
||||||
|
"decentralion",
|
||||||
|
],
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`plugins/github/edges createEdge works for "reactsThumbsUp" 1`] = `
|
exports[`plugins/github/edges createEdge works for "reactsThumbsUp" 1`] = `
|
||||||
Object {
|
Object {
|
||||||
"addressParts": Array [
|
"addressParts": Array [
|
||||||
|
|
|
@ -56,7 +56,8 @@ class GraphCreator {
|
||||||
if (
|
if (
|
||||||
content === Reactions.THUMBS_UP ||
|
content === Reactions.THUMBS_UP ||
|
||||||
content === Reactions.HEART ||
|
content === Reactions.HEART ||
|
||||||
content === Reactions.HOORAY
|
content === Reactions.HOORAY ||
|
||||||
|
content === Reactions.ROCKET
|
||||||
) {
|
) {
|
||||||
this.graph.addEdge(
|
this.graph.addEdge(
|
||||||
createEdge.reacts(content, user, reactable.address())
|
createEdge.reacts(content, user, reactable.address())
|
||||||
|
|
|
@ -138,6 +138,15 @@ const reactsHoorayEdgeType = Object.freeze({
|
||||||
prefix: E.Prefix.reactsHooray,
|
prefix: E.Prefix.reactsHooray,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const reactsRocketEdgeType = Object.freeze({
|
||||||
|
forwardName: "reacted 🚀 to",
|
||||||
|
backwardName: "got 🚀 from",
|
||||||
|
defaultForwardWeight: 1,
|
||||||
|
// TODO(#811): Probably change this to 0
|
||||||
|
defaultBackwardWeight: 1 / 32,
|
||||||
|
prefix: E.Prefix.reactsRocket,
|
||||||
|
});
|
||||||
|
|
||||||
const edgeTypes = Object.freeze([
|
const edgeTypes = Object.freeze([
|
||||||
authorsEdgeType,
|
authorsEdgeType,
|
||||||
hasParentEdgeType,
|
hasParentEdgeType,
|
||||||
|
@ -147,6 +156,7 @@ const edgeTypes = Object.freeze([
|
||||||
reactsThumbsUpEdgeType,
|
reactsThumbsUpEdgeType,
|
||||||
reactsHeartEdgeType,
|
reactsHeartEdgeType,
|
||||||
reactsHoorayEdgeType,
|
reactsHoorayEdgeType,
|
||||||
|
reactsRocketEdgeType,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
export const declaration: PluginDeclaration = Object.freeze({
|
export const declaration: PluginDeclaration = Object.freeze({
|
||||||
|
|
|
@ -39,6 +39,7 @@ export const Prefix = Object.freeze({
|
||||||
reactsThumbsUp: githubEdgeAddress(REACTS_TYPE, Reactions.THUMBS_UP),
|
reactsThumbsUp: githubEdgeAddress(REACTS_TYPE, Reactions.THUMBS_UP),
|
||||||
reactsHeart: githubEdgeAddress(REACTS_TYPE, Reactions.HEART),
|
reactsHeart: githubEdgeAddress(REACTS_TYPE, Reactions.HEART),
|
||||||
reactsHooray: githubEdgeAddress(REACTS_TYPE, Reactions.HOORAY),
|
reactsHooray: githubEdgeAddress(REACTS_TYPE, Reactions.HOORAY),
|
||||||
|
reactsRocket: githubEdgeAddress(REACTS_TYPE, Reactions.ROCKET),
|
||||||
});
|
});
|
||||||
|
|
||||||
export type AuthorsAddress = {|
|
export type AuthorsAddress = {|
|
||||||
|
|
|
@ -82,6 +82,12 @@ describe("plugins/github/edges", () => {
|
||||||
nodeExamples.user(),
|
nodeExamples.user(),
|
||||||
nodeExamples.issueComment()
|
nodeExamples.issueComment()
|
||||||
),
|
),
|
||||||
|
reactsRocket: () =>
|
||||||
|
createEdge.reacts(
|
||||||
|
Reactions.ROCKET,
|
||||||
|
nodeExamples.user(),
|
||||||
|
nodeExamples.pullComment()
|
||||||
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
describe("createEdge", () => {
|
describe("createEdge", () => {
|
||||||
|
|
|
@ -320,7 +320,8 @@ export class GraphView {
|
||||||
if (
|
if (
|
||||||
reactionType !== Reactions.THUMBS_UP &&
|
reactionType !== Reactions.THUMBS_UP &&
|
||||||
reactionType !== Reactions.HEART &&
|
reactionType !== Reactions.HEART &&
|
||||||
reactionType !== Reactions.HOORAY
|
reactionType !== Reactions.HOORAY &&
|
||||||
|
reactionType !== Reactions.ROCKET
|
||||||
) {
|
) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Invariant: Edge ${stringify(
|
`Invariant: Edge ${stringify(
|
||||||
|
|
|
@ -133,24 +133,30 @@ export type Reaction = {|
|
||||||
|
|
||||||
export type ReactionContent =
|
export type ReactionContent =
|
||||||
| "CONFUSED"
|
| "CONFUSED"
|
||||||
|
| "EYES"
|
||||||
| "HEART"
|
| "HEART"
|
||||||
| "HOORAY"
|
| "HOORAY"
|
||||||
| "LAUGH"
|
| "LAUGH"
|
||||||
|
| "ROCKET"
|
||||||
| "THUMBS_DOWN"
|
| "THUMBS_DOWN"
|
||||||
| "THUMBS_UP";
|
| "THUMBS_UP";
|
||||||
|
|
||||||
export const ReactionContent$Values: {|
|
export const ReactionContent$Values: {|
|
||||||
+CONFUSED: "CONFUSED",
|
+CONFUSED: "CONFUSED",
|
||||||
|
+EYES: "EYES",
|
||||||
+HEART: "HEART",
|
+HEART: "HEART",
|
||||||
+HOORAY: "HOORAY",
|
+HOORAY: "HOORAY",
|
||||||
+LAUGH: "LAUGH",
|
+LAUGH: "LAUGH",
|
||||||
|
+ROCKET: "ROCKET",
|
||||||
+THUMBS_DOWN: "THUMBS_DOWN",
|
+THUMBS_DOWN: "THUMBS_DOWN",
|
||||||
+THUMBS_UP: "THUMBS_UP",
|
+THUMBS_UP: "THUMBS_UP",
|
||||||
|} = Object.freeze({
|
|} = Object.freeze({
|
||||||
CONFUSED: "CONFUSED",
|
CONFUSED: "CONFUSED",
|
||||||
|
EYES: "EYES",
|
||||||
HEART: "HEART",
|
HEART: "HEART",
|
||||||
HOORAY: "HOORAY",
|
HOORAY: "HOORAY",
|
||||||
LAUGH: "LAUGH",
|
LAUGH: "LAUGH",
|
||||||
|
ROCKET: "ROCKET",
|
||||||
THUMBS_DOWN: "THUMBS_DOWN",
|
THUMBS_DOWN: "THUMBS_DOWN",
|
||||||
THUMBS_UP: "THUMBS_UP",
|
THUMBS_UP: "THUMBS_UP",
|
||||||
});
|
});
|
||||||
|
|
|
@ -25,6 +25,8 @@ export default function schema(): Schema.Schema {
|
||||||
"HOORAY",
|
"HOORAY",
|
||||||
"CONFUSED",
|
"CONFUSED",
|
||||||
"HEART",
|
"HEART",
|
||||||
|
"ROCKET",
|
||||||
|
"EYES",
|
||||||
]),
|
]),
|
||||||
Repository: s.object({
|
Repository: s.object({
|
||||||
id: s.id(),
|
id: s.id(),
|
||||||
|
|
Loading…
Reference in New Issue