Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Show committer avatar as well as author in the PR commit view #876

Merged
merged 14 commits into from
Jun 2, 2017
Merged

Show committer avatar as well as author in the PR commit view #876

merged 14 commits into from
Jun 2, 2017

Conversation

z0al
Copy link
Contributor

@z0al z0al commented May 26, 2017

Fixes #774

Todo list

  • Retrieve committer info
  • Show committer's avatar in the commit view
  • Fix design (e.g. pull avatars to the right as GitHub does)
  • Add tests

z0al added 3 commits May 26, 2017 08:12
Basic rendering of the committer of the commits in the PR view. We only render if `authoredByCommitter` isn't true
We now only show committer only if it's not GitHub (noreply@github.com), which happens when you commit on GitHub
@z0al
Copy link
Contributor Author

z0al commented May 26, 2017

I can't see why Travis is failing here. However, everything is OK in my fork Travis test result

@simurai
Copy link
Contributor

simurai commented May 26, 2017

Fix design (e.g. pull avatars to the right as GitHub does)

Switched to a table layout so that the avatars line up. Example:

screen shot 2017-05-26 at 5 45 05 pm

Here another PR to test: atom/atom#13453

I can't see why Travis is failing here.

My commit seemed to fix it, but the failing was probably unrelated.

@z0al
Copy link
Contributor Author

z0al commented May 26, 2017

Switched to a table layout so that the avatars line up

@simurai I was trying to do the same locally, but I wouldn't make it perfect like your work, good CSS lesson ;)

but the failing was probably unrelated.

Good to know, thanks

@z0al
Copy link
Contributor Author

z0al commented May 26, 2017

@simurai Oops, looks like we broke something, just noticed it when testing against atom/atom#13453

screenshot from 2017-05-26 14-42-38

I will fix it this time 😄

@kuychaco
Copy link
Contributor

Yeah, apologies about the Travis failure. We have some flakey tests. We can restart the failing job for you if needed

Thanks for taking this on :)

@z0al
Copy link
Contributor Author

z0al commented May 26, 2017

I would like to add some tests for Commit container, but I can't figure out how!

I tried this code (after I dug into commits-container.test.js) to check how things work:

describe('CommitContainer', function() {
  it('renders a header with one user name', function() {
    const item = {
      author: {name: 'FirstName', avatarUrl: '', user: {login: 'FirstLogin'}},
      committer: {name: 'GitHub', avatarUrl: '', user: null},
      authoredByCommitter: true,
      oid: 'xxx',
      messageHeadline: ':smile: it\'s fun',
      messageHeadlineHTML: 'fake html',
    };
    const app = <Commit item={item} />;
    const instance = shallow(app);
    assert.match(instance.text(), /FirstLogin/);
  });
});

But the assertion fails with:

AssertionError: assert.match(instance.text(), /FirstLogin/): expected '<Octicon />xxx' to match /FirstLogin/

Any hint ? It's my first time to play with Relay and Enzyme

@z0al
Copy link
Contributor Author

z0al commented May 29, 2017

Ping @kuychaco :)

@BinaryMuse
Copy link
Contributor

Sorry I haven't had a chance to dig into this — first day back after a holiday in the US.

I would like to add some tests for Commit container

I don't know if it's relevant to your failure or not, but the containers are responsible for reaching into the Relay store and such to fetch data from GraphQL. It's likely we'll want to separately export the non-containerized React component and test that directly instead.

@z0al
Copy link
Contributor Author

z0al commented May 30, 2017

Oh, my bad I meant Commit component.

It's likely we'll want to separately export the non-containerized React component and test that directly instead.

Isn't it already done in Commits component @BinaryMuse? Actually, I was trying to do the same with the Commit component.

I think I will give it another shot and see if I can manage it to work

Thanks

@BinaryMuse
Copy link
Contributor

@ahmed-taj Ah I see, I'm sorry for the misinformation.

In the example you posted above, FirstLogin will never actually appear in the component's text because it's not rendered as text — it's rendered as an attribute of one of the images. For this test, you'll likely want to use one of Enzyme's other methods; here's a list of the ones provided by shallow instances: https://github.com/airbnb/enzyme/blob/master/docs/api/shallow.md

For example, to ensure that there's an image with the title attribute 'FirstLogin', you could use:

assert.isTrue(instance.containsMatchingElement(<img title="FirstLogin" />));

@z0al z0al changed the title [WIP] Show committer avatar as well as author in the PR commit view Show committer avatar as well as author in the PR commit view Jun 2, 2017
@z0al
Copy link
Contributor Author

z0al commented Jun 2, 2017

I think it's ready for review now!

@BinaryMuse BinaryMuse self-assigned this Jun 2, 2017
Copy link
Contributor

@BinaryMuse BinaryMuse left a comment

Choose a reason for hiding this comment

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

Fantastic job on this! The tests look ✨. Thank you so much for your contribution!

}
if (commit.committer.name === 'GitHub' && commit.committer.user === null) {
return true;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice! I actually had no clue this was how it worked.

I dug into the GItHub.com source code a bit and found that the committer name will be "GitHub Enterprise" if we're running on GitHub enterprise. The noreply address is also based off the domain of the Enterprise install. I'm going to see if I can get a field added called authoredViaWeb or something that matches the internal check we do, but until then this works great. 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm going to see if I can get a field added called authoredViaWeb or something that matches the internal check we do

This would be perfect 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants