Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reactions to issue, commit comment and review payload #1405

Merged
merged 30 commits into from
Jul 8, 2016

Conversation

martinscholz83
Copy link
Contributor

fixed #1296
fixed #1297
fixed #1298

Add reactions into payloads for issue, commit comment and review payloads.

@@ -117,9 +117,9 @@ public class TheGetAllForRepositoryMethod
&& d["sort"] == "created"
&& d["filter"] == "assigned"), Arg.Any<string>())
.Returns(Task.Factory.StartNew<IApiResponse<List<Issue>>>(() => firstPageResponse));
gitHubClient.Connection.Get<List<Issue>>(secondPageUrl, Arg.Any<Dictionary<string,string>>(), null)
gitHubClient.Connection.Get<List<Issue>>(secondPageUrl, Arg.Any<Dictionary<string,string>>(), Arg.Is<string>(s => s == "application/vnd.github.squirrel-girl-preview"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can simplify Arg.Is<string>(s => s == "application/vnd.github.squirrel-girl-preview") to just "application/vnd.github.squirrel-girl-preview"


Assert.True(retrieved.Id > 0);
Assert.Equal(1, retrieved.Reactions.TotalCount);
Assert.Equal(0, retrieved.Reactions.Plus1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given we had issues with the Plus1 and Minus1 on the other reactions stuff, It'd be good to ensure our integration test covers deserializing all reaction summary fields.

How had would it be to have a unique value for each of the reactions, eg 5x Plus1's, 4x Minus1's, 3x Hooray, 2x Heart, 1x Laugh, 0x Confused ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That i have proposed in an old comment in Stand-Alone-Reaction-Client but it was rejected because of not necessary 😐

Copy link
Contributor Author

@martinscholz83 martinscholz83 Jun 23, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like this ?

        Confused = 0,
        Laugh = 1,
        Heart = 2,
        Hooray = 3,
        [Parameter(Value = "+1")]
        Plus1 = 4,
        [Parameter(Value = "-1")]
        Minus1 = 5,        

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean have that number of each reaction on an issue then the integration test can retrieve that issue and check each one is desetialzed properly by asserting the unique number

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you give me an example. I think I have a Blackout 😵

Copy link
Contributor

@ryangribble ryangribble Jun 23, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i meant that we would setup an issue comment somewhere on github that has 5 users react with ":confused:" and 4 users react with ":heart:" and 3 users react with ":+1:" etc, then the integration test would check each of these.

var retrieved = await _github.Repository.Comment.Get("octokit", "octokit.net", commentId);

Assert.Equals(5, received.Reactions.Confused);
Assert.Equals(4, received.Reactions.Heart);
Assert.Equals(3, received.Reactions.Plus1);
etc

But it was just a thought and it's not a particularly good one because it cant be setup in code easily (as you would need up to 5 individual test users to be able to create the reactions) and even setting one up manually involves co-ordination of multiple people and is then also able to start failing if any other user ever added an unwanted reaction to it!

So let's just settle for the integration test

  • creating a repository/issue/comment (you are already doing this)
  • adding 1 reaction of each type to it (currently you only add 1 reactoin type, so we dont know if we are failing to deserialize any of the other fields in the reaction summary part of the payload)
  • assert each reaction in the response payload had a count of 1 and total had a count of 6

at least that tests all fields deserialized ok

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Then i would implement loops like in #1402 for reaction types.

@ryangribble
Copy link
Contributor

Looking good! For consistency, it would be great if you could add an integration test that tests all reaction types, to the original IssueComment reaction payload work that was done on previous PR? 😀

@martinscholz83
Copy link
Contributor Author

@ryangribble
Copy link
Contributor

Yeah I reckon replacing that test with your one that creates a repo/issue/comment, then adds each reaction type today it, then retrieves them and checks the fields

…eactions-payload

# Conflicts:

#	Octokit.Tests.Integration/Clients/PullRequestReviewCommentsClientTests.cs
#	Octokit.Tests/Clients/PullRequestReviewCommentsClientTests.cs
@martinscholz83
Copy link
Contributor Author

unit tests are failing after merge. should i rollback?

@martinscholz83
Copy link
Contributor Author

Is there something more to do with this request?

@shiftkey
Copy link
Member

shiftkey commented Jul 7, 2016

unit tests are failing after merge. should i rollback?

It looks like some upstream changes needed to have the preview API applied - this is the commit which fixes it for me, feel free to cherry-pick it in:

shiftkey@7e94dbc

Looking at the integration tests now to confirm this is all that's needed...

@@ -230,6 +254,14 @@ public IssuesClientTests()
Assert.True(retrieved.Any(i => i.Number == issue2.Number));
Assert.True(retrieved.Any(i => i.Number == issue3.Number));
Assert.True(retrieved.Any(i => i.Number == issue4.Number));
var issue = retrieved[0];
Assert.Equal(4, issue.Reactions.TotalCount);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reactions created above are one-per-issue. So we only expect 1 here, not 4. Or perhaps we can simplify the test?

@shiftkey
Copy link
Member

shiftkey commented Jul 7, 2016

I'm seeing a few integration tests fail with this exception:

  • Octokit.ForbiddenException : Insufficient scopes for reacting to this Issue.

Examples:

  • IssuesClientTests.CanDeserializeIssue
  • PullRequestReviewCommentReactionsClientTests.CanCreateReaction

Not sure whether this is related to my setup or something I need to investigate further.

[IntegrationTest]
public async Task CanDeserializeIssueCommentWhenGettingAllForRepository()
{
var comments = await _issueCommentsClient.GetAllForRepository("alfhenrik-test", "repo-with-issue-comment-reactions");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somewhat related - we have other tests here which use this repository, but this repository doesn't seem to exist any more cc @alfhenrik

martinscholz83 and others added 3 commits July 7, 2016 08:29
…eactions-payload

# Conflicts:
#	Octokit.Tests.Integration/Clients/IssueCommentsClientTests.cs
@martinscholz83
Copy link
Contributor Author

@shiftkey i have cherry-pick your commit. test are now passing 👍

@martinscholz83
Copy link
Contributor Author

These failing integration test was my mistake 😯

Also applied preview header to a couple of repositoryId based calls that were added by another PR
@ryangribble
Copy link
Contributor

There are still some failing unit tests with missing preview header. Also I noticed a couple of new repositoryId based calls from other merged PRs now also needed the preview header applied.

If you cherry pick this commit TattsGroup@1185da2 it should hopefully get everything green 👍

Also applied preview header to a couple of repositoryId based calls that were added by another PR
@ryangribble
Copy link
Contributor

ryangribble commented Jul 7, 2016

And here is a commit showing what I meant with tidying up the reaction payloads tests, handling Get and GetAll methods and covering all reaction types:
TattsGroup@e319f0e

Something like this could be done for the other 3 clients (Issues, PullRequestReviewComments, CommitComments)

Actually ive almost got all of them done, Ill send a PR to your branch 😀

@martinscholz83
Copy link
Contributor Author

I wasn't able to merge your request. So i have to create a branch of yours, resolve conflicts, and then create a pull request internally. Very confusing 😕. But now all should be fine

@ryangribble
Copy link
Contributor

Not sure what you mean as the PR merged ok?

Anyway hopefully it's all good now. Can you run the new integration tests to confirm they work for you?

@martinscholz83
Copy link
Contributor Author

I think the conflict came from your pull request. Because in the meantime i have made a change in my branch:see_no_evil: Tests run perfectly!!

@ryangribble
Copy link
Contributor

woohoo!

LGTM

@ryangribble ryangribble merged commit 72e30a7 into octokit:master Jul 8, 2016
@ryangribble ryangribble added this to the Reactions Support milestone Jul 8, 2016
@martinscholz83
Copy link
Contributor Author

🎉 🎉
funny

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants