Skip to content

Conversation

kumar303
Copy link
Contributor

@kumar303 kumar303 force-pushed the review-list-saga-iss2608 branch from 440a5f1 to 4c54f30 Compare June 23, 2017 21:50
@kumar303 kumar303 requested a review from tofumatt June 23, 2017 21:51
Copy link
Contributor

@tofumatt tofumatt left a comment

Choose a reason for hiding this comment

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

🎉

This is awesome. Tested it locally and the UX of going from search to add-on to reviews is great. Once we get search hooked up to redux it's gonna feel so natural navigating between pages.

All of my comments are little improvements (most are about the toHaveProps matcher) or nitpicks/minor things. Overall this looks great, super stoked. Thanks so much for all the work porting to sagas.

r+wc

module.exports = {
apiHost: 'https://localhost',
allowErrorSimulation: true,
enableClientConsole: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this make test output (any) noiser? I imagine the aim of setting this to false here was to make tests not output a log of logging stuff.

Copy link
Contributor Author

@kumar303 kumar303 Jun 26, 2017

Choose a reason for hiding this comment

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

the aim of setting this to false here was to make tests not output a log of logging stuff.

I sure hope not because that would be the most cruel trick ever played on a developer. It's 100% essential to see logging in test output. However, I would love to hide the test output for passing tests. Maybe that's possible. As for reducing noise, you can still use --silent.

const { i18n } = this.props;
const timestamp = i18n.moment(review.created).fromNow();

let byLine;
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like byLine is a bit of a niche word... I know that's what this is but reviewAuthor would work equally well for what this is and might be a bit easier to parse.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Byline has been a standard word since the 1950s. Naming it reviewAuthor is awkward because the code already uses a variable named review.userName. Plus, this text contains name and date which makes it more of a byline than just an author name.

throw new Error('params.addonSlug cannot be falsey');
}
if (!reviews || !addon) {
// TODO: add a spinner
Copy link
Contributor

Choose a reason for hiding this comment

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

Hey, we finally did it! 😄

// TODO: add a spinner
return <div>{i18n.gettext('Loading...')}</div>;

// When reviews have not loaded yet, make a list of 4 empty reviews
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

yield put(showLoading());
const api = yield select(getApi);
const response = yield call(getReviews, {
// Hide star ratings (reviews that do not have a body).
Copy link
Contributor

Choose a reason for hiding this comment

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

This could be clarified slightly: "Hide star-only ratings (reviews that do not have a body)".

All ratings have stars, so "star-only" might help the reader grok this a bit faster.

expect(dispatch.firstCall.args[0]).toEqual(expectedAction);
});
const root = render({ location: { query: { page: 3 } } });
expect(root.find(Paginate).prop('currentPage')).toEqual(3);
Copy link
Contributor

Choose a reason for hiding this comment

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

toHaveProp matcher here too.

await sagaTester.waitFor(SET_ADDON_REVIEWS);
mockAmoApi.verify();

expect(sagaTester.getCalledActions()[1]).toEqual(showLoading());
Copy link
Contributor

Choose a reason for hiding this comment

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

In the categories test we did:

    const calledActions = sagaTester.getCalledActions();

    expect(calledActions[0]).toEqual(actions.categoriesFetch());

    [...]

I found it a touch prettier.

expect(ratings[1].props.rating).toEqual(2);
expect(ratings[1].props.readOnly).toEqual(true);
expect(ratings.at(0).prop('rating')).toEqual(1);
expect(ratings.at(0).prop('readOnly')).toEqual(true);
Copy link
Contributor

Choose a reason for hiding this comment

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

toHaveProp here too.

expect(ratings[1].props.readOnly).toEqual(true);
expect(ratings.at(0).prop('rating')).toEqual(1);
expect(ratings.at(0).prop('readOnly')).toEqual(true);
expect(ratings.at(1).prop('rating')).toEqual(2);
Copy link
Contributor

Choose a reason for hiding this comment

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

toHaveProp here too.

expect(ratings.at(0).prop('rating')).toEqual(1);
expect(ratings.at(0).prop('readOnly')).toEqual(true);
expect(ratings.at(1).prop('rating')).toEqual(2);
expect(ratings.at(1).prop('readOnly')).toEqual(true);
Copy link
Contributor

Choose a reason for hiding this comment

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

toHaveProp here too.

@tofumatt
Copy link
Contributor

Oh, just one thing I noticed:

if you load the reviews page from the server seems like we don't dispatch the setViewContext action so it appears under "Explore" rather than "Extensions". You'd rarely run into this because usually you go to a review page from the add-on (which would have already set the right context), but technically we should be dispatching it.

screenshot 2017-06-24 00 01 17

It will be good to start dispatching those largely based on URL.

@kumar303
Copy link
Contributor Author

kumar303 commented Jun 26, 2017

we don't dispatch the setViewContext action

Good catch, fixed. Yeah, once we connect this to the URL then it won't require so much manual dispatch logic.

@kumar303
Copy link
Contributor Author

Thanks for the reviews!

@kumar303 kumar303 merged commit 65d4e80 into mozilla:master Jun 26, 2017
@kumar303 kumar303 deleted the review-list-saga-iss2608 branch June 26, 2017 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Convert add-on review list to sagas
2 participants