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

Show the shorter version of the empty annotations/notes message when … #611

Merged
merged 1 commit into from
Dec 6, 2017

Conversation

sheetaluk
Copy link
Contributor

…the sidebar tutorial is displayed

and the new note button is enabled.

Fixes #610

@codecov
Copy link

codecov bot commented Nov 30, 2017

Codecov Report

Merging #611 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #611      +/-   ##
==========================================
+ Coverage   90.91%   90.94%   +0.02%     
==========================================
  Files         133      134       +1     
  Lines        5351     5357       +6     
  Branches      931      930       -1     
==========================================
+ Hits         4865     4872       +7     
+ Misses        486      485       -1
Impacted Files Coverage Δ
src/sidebar/components/sidebar-tutorial.js 87.5% <100%> (-2.5%) ⬇️
src/sidebar/util/session-util.js 100% <100%> (ø)
src/sidebar/components/selection-tabs.js 90.47% <100%> (+7.14%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0315976...7a86766. Read the comment docs.

@sheetaluk
Copy link
Contributor Author

@robertknight I think /filters/sidebar-tutorial.js is in the wrong place. Its not really a filter used in templates. Is /util a better place?

/**
* Returns true if the sidebar tutorial has to be shown to a user for a given session.
*/
function show(sessionState) {
Copy link
Member

Choose a reason for hiding this comment

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

  • The preferences property is a non-optional field in the profile type as returned by /api/profile, so you don't need to check for it.

  • Re. your question about where this should go, the src/sidebar/filter directory refers to Angular filters, rather than utility functions. There are two places in the code for this kind of logic:

    1. A simple function in a module in the util/ directory (eg. in say util/session or something). If you do this, please make sure the function name makes sense on its own (eg. shouldShowSidebarTutorial).
    2. A "selector" function in an app state module (eg. src/sidebar/reducers/session in this case) which takes the app state and returns something derived from it.

Also, one related note - the name "session" in various modules is a hangover from when the data came from h's /app endpoint, which returned data about the user's cookie session on the website. At some point we should change it to "profile" everywhere since it comes from /api/profile now and no longer necessarily reflects the user's state on the website (eg. if using third party accounts).

totalAnnotations: '10',
totalNotes: 0,
});
var unavailableMsg = elem[0].querySelectorAll('.annotation-unavailable-message__label')[0];
Copy link
Member

Choose a reason for hiding this comment

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

You can use querySelector(selector) rather than querySelectorAll(selector)[0] if you are only interested in the first element.

assert.isTrue(noteIcon.classList.contains('h-icon-annotate'));
});

it('should not display the new note button when the notes tab is active and the new note button is disabled', function () {
Copy link
Member

Choose a reason for hiding this comment

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

These tests are in a when the sidebar tutorial is not displayed context block, but they apply whether or not the sidebar tutorial is shown, don't they? If so, then they should be outside the context block. Also, don't we already have tests for this?

Copy link
Member

@robertknight robertknight left a comment

Choose a reason for hiding this comment

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

This works as expected. I did encounter some browser-specific (Safari #599, Firefox) issues with the rendering of the "New note" button but these already exist in master.

I left a few comments about the code to address.

…the sidebar tutorial is displayed

and the new note button is enabled.

Fixes #610
@sheetaluk sheetaluk force-pushed the onboarding-tutorial branch from fe2086c to 7a86766 Compare December 5, 2017 16:00
Copy link
Member

@robertknight robertknight left a comment

Choose a reason for hiding this comment

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

This worked as expected when I tested it. I spotted a couple of lines in the tests that look like mistakes. Please let me know when you've had a chance to look through them and make any changes.


assert.include(msg.textContent, 'There are no page notes in this group.');
assert.notInclude(msg.textContent, 'Create one by clicking the');
assert.notInclude(msg.textContent, 'Create one by selecting some text and clicking the');
Copy link
Member

Choose a reason for hiding this comment

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

I think this line was included by mistake? You never need to select text to create a note.

var msg = elem[0].querySelector('.annotation-unavailable-message__label');

assert.include(msg.textContent, 'There are no annotations in this group.');
assert.notInclude(msg.textContent, 'Create one by clicking the');
Copy link
Member

Choose a reason for hiding this comment

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

It looks like this line is a mistake as well, since "Create one by clicking the" is only shown in the notes tab.

Just as a suggestion, it might save a few lines and make the tests more readable to extract out the logic for querying the DOM into a helper function which returns some value to indicate the displayed message that you can then test for. Alternatively if the template "logic" is very simple (eg. hiding/showing different elements depending on some controller methods which return a boolean) you can might be able to get away with just testing the controller method's output in different cases.

Copy link
Member

Choose a reason for hiding this comment

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

Discussed this on Slack. This is a check to make sure that the annotations-related message is not showing.

@sheetaluk sheetaluk merged commit 37ffd90 into master Dec 6, 2017
@sheetaluk sheetaluk deleted the onboarding-tutorial branch December 6, 2017 17:53
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.

2 participants