-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Conversation
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
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.
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(); |
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.
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.
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, I have removed it
collectionEditor.setObjective('This is a test collection.'); | ||
collectionEditor.setCategory('Algebra'); | ||
collectionEditor.saveChanges(); | ||
learnerDashboardPage.publishExploration(); |
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.
Ditto. This looks more like a job for the CollectionEditorPage.
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.
Done, I have changed it
browser.waitForAngular(); | ||
element(by.css('.protractor-test-completed-section')).click(); | ||
learnerDashboardPage.completedProfileTest(); |
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.
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).
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.
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(); |
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.
Ditto: method names should start with verbs and accurately describe what they do semantically.
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.
Done, I have renamed it.
'.protractor-test-collection-summary-tile-title')).first( | ||
).getText()).toMatch('Test Collection'); | ||
expect( | ||
learnerDashboardPage.summaryTile() |
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.
Ditto.
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.
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(); |
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.
This name is good -- but this isn't the learnerDashboardPage, it's the profilePage, right?
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, thanks for the suggestions, will make the necessary changes.
@seanlip Did the changes and also added some functions which I missed before. |
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(); |
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.
navigateToIncompleteCollectionSection (you're navigating to a section, not to a collection)
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.
Ya, I thought about this, but thought name might become too long. Will change that.
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.
Done
'.protractor-test-collection-summary-tile-title')).first( | ||
).getText()).toMatch('Test Collection'); | ||
expect( | ||
learnerDashboardPage.openSummaryTile() |
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.
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.
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.
Yes, that is what is being retrieved here, will change that.
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.
Done
browser.waitForAngular(); | ||
general.waitForSystem(); | ||
element(by.css('.protractor-test-subscriptions-section')).click(); | ||
learnerDashboardPage.navigateToSubscriptionsSection(); | ||
browser.waitForAngular(); | ||
expect(element.all(by.css( |
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 guess this stuff should also be factored into the learner dashboard page?
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.
As it was just after a learnerDashboard.get(), I assumed it to be a part of learner dashboard itself.
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'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?
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.
Yes, thats what I did. Is there something more?
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.
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.
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.
Oh, ok, will add that
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.
Done
element(by.css('.protractor-test-completed-section')); | ||
var feedbackSection = | ||
element(by.css('.protractor-test-feedback-section')); | ||
var completedCollection = |
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.
These are sections; their names should end with Section
. Ditto below.
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, will change those.
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.
Done
element(by.css('.protractor-test-incomplete-collection-section')); | ||
var subscriptionsSection = | ||
element(by.css('.protractor-test-subscriptions-section')); | ||
var summaryTile = |
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.
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.
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, misread the name, will change that
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.
Done
|
||
this.navigateToCompletedSection = function() { | ||
completedSection.click(); | ||
} |
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.
Missing semicolons, here and below.
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.
Oh, didn't see those. Will add them.
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.
Done
browser.waitForAngular(); | ||
element(by.css('.protractor-test-completed-section')).click(); | ||
learnerDashboardPage.navigateToCompletedSection(); |
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.
Just to check -- is this completed collections, completed explorations, or something else?
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 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(); |
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.
Let's make this ...IncompleteCollectionsSection (note the plural), since the section contains incomplete collections
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.
Done
browser.waitForAngular(); | ||
general.waitForSystem(); | ||
element(by.css('.protractor-test-completed-collection-section')).click(); | ||
learnerDashboardPage.navigateToCompletedCollectionSection(); |
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.
ditto
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.
Done
browser.waitForAngular(); | ||
element(by.css('.protractor-test-feedback-section')).click(); | ||
learnerDashboardPage.navigateToFeedbackSection(); | ||
browser.waitForAngular(); | ||
expect(element.all(by.css( |
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.
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.
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.
Yes, I added that in the learnerDashboardPage object already. Is there something else?
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 don't think it's done, or rather, if it is, then this line should be learnerDashboardPage.something(...). See previous comment.
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.
Yes, saw it, will add that.
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.
Done
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.
This is looking great, @aks681. Just a couple more things and I think we're done!
* tests. | ||
*/ | ||
|
||
var collectionEditor = require('./collectionEditor.js'); |
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.
Why is this here?
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.
It was there as I was calling it before. Forgot to remove it. Will change that.
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.
Done
general.acceptAlert(); | ||
browser.waitForAngular(); | ||
general.waitForSystem(); | ||
browser.ignoreSynchronization = false; | ||
element(by.css('.protractor-test-incomplete-collection-section')).click(); | ||
learnerDashboardPage.navigateToIncompleteCollectionsSection(); | ||
browser.waitForAngular(); |
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.
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.
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.
If there are are other calls to learnerDashboardPage that are repeating for all such instances, shall I put it inside page object also?
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.
Sorry, I don't understand. Could you elaborate / give an example?
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.
after both instances of navigateToIncompleteCollectionsSection(), expectTitleOfSummaryTileToMatch() is called, so can I put this call as this.expectTitleOfSummaryTileToMatch() inside the navigateToIncompleteCollectionsSection() function?
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.
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.
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, thanks.
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.
Done
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.
LGTM. Thanks @aks681!
Thank You! |
I made a file LearnerDashboardPage.js that incorporates all the learner page objects.
PTAL @brianrodri