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

fix part of #3954 - LearnerDashboardPage.js #4138

Merged
merged 9 commits into from
Dec 4, 2017

Conversation

aks681
Copy link
Contributor

@aks681 aks681 commented Dec 1, 2017

I made a file LearnerDashboardPage.js that incorporates all the learner page objects.
PTAL @brianrodri

@codecov-io
Copy link

codecov-io commented Dec 1, 2017

Codecov Report

Merging #4138 into develop will decrease coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #4138      +/-   ##
===========================================
- Coverage    43.88%   43.88%   -0.01%     
===========================================
  Files          359      360       +1     
  Lines        22401    22398       -3     
  Branches      3559     3561       +2     
===========================================
- Hits          9831     9829       -2     
+ Misses       12570    12569       -1
Impacted Files Coverage Δ
extensions/visualizations/visualizations.js 10.71% <0%> (-0.83%) ⬇️
...exploration_editor/statistics_tab/StatisticsTab.js 1.8% <0%> (-0.11%) ⬇️
...n_editor/editor_tab/SolutionVerificationService.js 100% <0%> (ø) ⬆️
...tion_editor/StateEditorTutorialFirstTimeService.js 5.26% <0%> (ø)
...ges/exploration_editor/editor_tab/StateSolution.js 1.56% <0%> (+0.06%) ⬆️
...tes/dev/head/components/SolutionEditorDirective.js 2.7% <0%> (+0.2%) ⬆️
.../exploration_editor/editor_tab/ResponsesService.js 41.04% <0%> (+0.69%) ⬆️
...ev/head/pages/exploration_editor/EditorServices.js 39.91% <0%> (+0.88%) ⬆️

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 7fa2bcb...4c3195c. Read the comment docs.

Copy link
Member

@seanlip seanlip left a comment

Choose a reason for hiding this comment

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

Thanks for the changes. I took a review pass -- PTAL.

@@ -56,16 +60,9 @@ describe('Learner dashboard functionality', function() {
browser.waitForAngular();
element(by.css('.protractor-test-create-activity')).click();
// Create new collection.
element(by.css('.protractor-test-create-collection')).click();
learnerDashboardPage.createExploration();
Copy link
Member

Choose a reason for hiding this comment

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

This action is not something that's being done on the learner dashboard page, so it should not be part of the learner dashboard page object.

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, I have removed it

collectionEditor.setObjective('This is a test collection.');
collectionEditor.setCategory('Algebra');
collectionEditor.saveChanges();
learnerDashboardPage.publishExploration();
Copy link
Member

Choose a reason for hiding this comment

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

Ditto. This looks more like a job for the CollectionEditorPage.

Copy link
Contributor Author

@aks681 aks681 Dec 3, 2017

Choose a reason for hiding this comment

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

Done, I have changed it

browser.waitForAngular();
element(by.css('.protractor-test-completed-section')).click();
learnerDashboardPage.completedProfileTest();
Copy link
Member

Choose a reason for hiding this comment

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

If this represents a click, the name of the method should indicate that. E.g. learnerDashboardPage.moveToCompletedSection() or learnerDashboardPage.openCompletedSection() (or whatever the click is actually doing semantically; I can't tell from the name that's being given to it here).

Copy link
Contributor Author

@aks681 aks681 Dec 3, 2017

Choose a reason for hiding this comment

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

Done, I have renamed all occurrences of such names.

general.acceptAlert();
browser.waitForAngular();
general.waitForSystem();
browser.ignoreSynchronization = false;
element(by.css('.protractor-test-incomplete-collection-section')).click();
learnerDashboardPage.incompleteCollectionSection();
Copy link
Member

Choose a reason for hiding this comment

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

Ditto: method names should start with verbs and accurately describe what they do semantically.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, I have renamed it.

'.protractor-test-collection-summary-tile-title')).first(
).getText()).toMatch('Test Collection');
expect(
learnerDashboardPage.summaryTile()
Copy link
Member

Choose a reason for hiding this comment

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

Ditto.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, I have renamed it.

@@ -210,14 +207,14 @@ describe('Learner dashboard functionality', function() {
// Subscribe to both the creators.
browser.get('/profile/creator1learnerDashboard');
browser.waitForAngular();
element(by.css('.protractor-test-subscription-button')).click();
learnerDashboardPage.clickSubscriptionButton();
Copy link
Member

Choose a reason for hiding this comment

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

This name is good -- but this isn't the learnerDashboardPage, it's the profilePage, right?

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, thanks for the suggestions, will make the necessary changes.

@aks681
Copy link
Contributor Author

aks681 commented Dec 3, 2017

@seanlip Did the changes and also added some functions which I missed before.

@seanlip
Copy link
Member

seanlip commented Dec 3, 2017

Thanks @aks681. One request: please could you reply to all comments, following the instructions in step 5 here? In particular, for comments that you've addressed, please reply "Done." -- this helps keep track of which comments have been addressed and which haven't. Thanks!

@aks681
Copy link
Contributor Author

aks681 commented Dec 3, 2017

ok, will do, sorry about that.

general.acceptAlert();
browser.waitForAngular();
general.waitForSystem();
browser.ignoreSynchronization = false;
element(by.css('.protractor-test-incomplete-collection-section')).click();
learnerDashboardPage.navigateToIncompleteCollection();
Copy link
Member

Choose a reason for hiding this comment

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

navigateToIncompleteCollectionSection (you're navigating to a section, not to a collection)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ya, I thought about this, but thought name might become too long. Will change that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

'.protractor-test-collection-summary-tile-title')).first(
).getText()).toMatch('Test Collection');
expect(
learnerDashboardPage.openSummaryTile()
Copy link
Member

Choose a reason for hiding this comment

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

open...() doesn't have a connotation of "return a value". Maybe it should be "getTitleOfSummaryTile()" or similar, though that's just an example -- you'd need to check what exactly is being retrieved here and include that in the method name.

Copy link
Contributor Author

@aks681 aks681 Dec 3, 2017

Choose a reason for hiding this comment

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

Yes, that is what is being retrieved here, will change that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

browser.waitForAngular();
general.waitForSystem();
element(by.css('.protractor-test-subscriptions-section')).click();
learnerDashboardPage.navigateToSubscriptionsSection();
browser.waitForAngular();
expect(element.all(by.css(
Copy link
Member

Choose a reason for hiding this comment

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

I guess this stuff should also be factored into the learner dashboard page?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As it was just after a learnerDashboard.get(), I assumed it to be a part of learner dashboard itself.

Copy link
Member

Choose a reason for hiding this comment

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

That's the point I was making, though. If it's part of the learner dashboard page, shouldn't it be refactored into the LearnerDashboardPage object?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, thats what I did. Is there something more?

Copy link
Member

Choose a reason for hiding this comment

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

What I'm saying is that this line (expect(element.all(by.css(...))).toMatch(...);) should be wrapped in a method on the LearnerDashboardPage object, so that this line changes to something like learnerDashboardPage.someMethodName('creator...'). It doesn't look like that's been done.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, ok, will add that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

element(by.css('.protractor-test-completed-section'));
var feedbackSection =
element(by.css('.protractor-test-feedback-section'));
var completedCollection =
Copy link
Member

Choose a reason for hiding this comment

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

These are sections; their names should end with Section. Ditto below.

Copy link
Contributor Author

@aks681 aks681 Dec 3, 2017

Choose a reason for hiding this comment

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

ok, will change those.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

element(by.css('.protractor-test-incomplete-collection-section'));
var subscriptionsSection =
element(by.css('.protractor-test-subscriptions-section'));
var summaryTile =
Copy link
Member

Choose a reason for hiding this comment

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

Is this the tile, or its title? The CSS name doesn't seem to match the variable name.

It's important to be precise when naming, otherwise developers will get 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.

ok, misread the name, will change that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done


this.navigateToCompletedSection = function() {
completedSection.click();
}
Copy link
Member

Choose a reason for hiding this comment

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

Missing semicolons, here and below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, didn't see those. Will add them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

browser.waitForAngular();
element(by.css('.protractor-test-completed-section')).click();
learnerDashboardPage.navigateToCompletedSection();
Copy link
Member

Choose a reason for hiding this comment

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

Just to check -- is this completed collections, completed explorations, or something else?

Copy link
Contributor Author

@aks681 aks681 Dec 4, 2017

Choose a reason for hiding this comment

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

I think its a section of completed explorations and collections. In LearnerDashboard.js, of /learner_dashboard it is called above the subsection that calls both of them.

general.acceptAlert();
browser.waitForAngular();
general.waitForSystem();
browser.ignoreSynchronization = false;
element(by.css('.protractor-test-incomplete-collection-section')).click();
learnerDashboardPage.navigateToIncompleteCollectionSection();
Copy link
Member

Choose a reason for hiding this comment

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

Let's make this ...IncompleteCollectionsSection (note the plural), since the section contains incomplete collections

Copy link
Contributor Author

@aks681 aks681 Dec 4, 2017

Choose a reason for hiding this comment

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

Done

browser.waitForAngular();
general.waitForSystem();
element(by.css('.protractor-test-completed-collection-section')).click();
learnerDashboardPage.navigateToCompletedCollectionSection();
Copy link
Member

Choose a reason for hiding this comment

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

ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

browser.waitForAngular();
element(by.css('.protractor-test-feedback-section')).click();
learnerDashboardPage.navigateToFeedbackSection();
browser.waitForAngular();
expect(element.all(by.css(
Copy link
Member

Choose a reason for hiding this comment

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

This also seems like something that should be part of the LearnerDashboardPage object?

Basically, anything that involves fiddling around with elements should be part of the page object, so that the protractor test itself doesn't have to mess around with the details.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I added that in the learnerDashboardPage object already. Is there something else?

Copy link
Member

Choose a reason for hiding this comment

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

I don't think it's done, or rather, if it is, then this line should be learnerDashboardPage.something(...). See previous comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, saw it, will add that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Member

@seanlip seanlip 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 looking great, @aks681. Just a couple more things and I think we're done!

* tests.
*/

var collectionEditor = require('./collectionEditor.js');
Copy link
Member

Choose a reason for hiding this comment

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

Why is this here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was there as I was calling it before. Forgot to remove it. Will change that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

general.acceptAlert();
browser.waitForAngular();
general.waitForSystem();
browser.ignoreSynchronization = false;
element(by.css('.protractor-test-incomplete-collection-section')).click();
learnerDashboardPage.navigateToIncompleteCollectionsSection();
browser.waitForAngular();
Copy link
Member

Choose a reason for hiding this comment

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

It might be better to put these browser.waitForAngular() calls at the end of their respective functions in the page object, if they're always going to be called. This will also help simplify the main protractor test.

Ditto for general.waitForSystem(), where relevant.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If there are are other calls to learnerDashboardPage that are repeating for all such instances, shall I put it inside page object also?

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, I don't understand. Could you elaborate / give an example?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

after both instances of navigateToIncompleteCollectionsSection(), expectTitleOfSummaryTileToMatch() is called, so can I put this call as this.expectTitleOfSummaryTileToMatch() inside the navigateToIncompleteCollectionsSection() function?

Copy link
Member

Choose a reason for hiding this comment

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

Ah, I see. No, don't do that.

The way to think about this is that these are the actions a user would do. A user wouldn't really be doing stuff at the level of "wait for angular". But they may take the actions "navigate" and "expect title to match" independently, so these should be independent actions in the page object.

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, thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Member

@seanlip seanlip left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks @aks681!

@aks681
Copy link
Contributor Author

aks681 commented Dec 5, 2017

Thank You!

@aks681 aks681 deleted the refactor_into_page_objects branch December 5, 2017 07:10
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.

5 participants