-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add reactions to issue, commit comment and review payload #1405
Conversation
@@ -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")) |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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 😐
There was a problem hiding this comment.
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,
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 😵
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
Looking good! For consistency, it would be great if you could add an integration test that tests all reaction types, to the original |
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
unit tests are failing after merge. should i rollback? |
Is there something more to do with this request? |
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: 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); |
There was a problem hiding this comment.
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?
I'm seeing a few integration tests fail with this exception:
Examples:
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"); |
There was a problem hiding this comment.
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
…eactions-payload # Conflicts: # Octokit.Tests.Integration/Clients/IssueCommentsClientTests.cs
@shiftkey i have cherry-pick your commit. test are now passing 👍 |
These failing integration test was my mistake 😯 |
Also applied preview header to a couple of repositoryId based calls that were added by another PR
There are still some failing unit tests with missing preview header. Also I noticed a couple of new 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
Actually ive almost got all of them done, Ill send a PR to your branch 😀 |
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 |
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? |
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!! |
fixed #1296
fixed #1297
fixed #1298
Add reactions into payloads for issue, commit comment and review payloads.